Jaideep M. More

software engineer


Asymmetric Cryptography

References:

  • 11.5 RSA
  • 12 Digital Signatures

Setting of Public Key Encryption

Public key techniques enable parties to communicate privately without having agreed on any secret information in advance.

Public key encryption is asymmetric. One party generates a pair of keys (pk,sk)(pk, sk) called the public key and the secret key. Public key is used to encrypt the message and secret key is used to decrypt the cipher text.

This encryption scheme removes the need for key exchange.

The main disadvantage of public-key encryption is that it is roughly 2x to 3x orders of magnitude slower the private key encryption. Thus, when private key encryption is an option then typically it should be used.

Syntax of Public Key Encryption:

Gen\text{Gen}takes as input the security parameter 1n1^n and outputs a pair of keys ⟨pk,sk⟩\langle pk, sk \rangle
c←Encpk(m)c \leftarrow \text{Enc}_{pk}(m)Enc\text{Enc} takes as input a public key pkpk of the receiver and a message mm and outputs a cipher text cc
m:=Decsk(c)m := \text{Dec}_{sk}(c)Dec\text{Dec} takes as input a private key sksk and a cipher text cc and outputs a message mm or a special symbol ⊥\bot denoting failure

Security Discussion

Security against CPA:

What is CPA?

If a public key encryption scheme has indistinguishable encryptions in the presence of an eavesdropper then the scheme is CPA secure

Multiple Encryptions:

If public key encryption scheme is CPA-secure then it also has indistinguishable multiple encryptions.

an immediate consequence of this is that a CPA-secure public key encryption scheme for fixed length messages implies a public key encryption scheme for arbitrary length messages satisfying the same notion of security.

Security against CCA:

What is CCA?

Broadly speaking, in the public key setting there are two classes of chosen ciphertext attacks:

  1. A\mathcal{A} might send a modified ciphertext c′c^\prime to R\mathcal{R} on behalf of S\mathcal{S}. Although it is unlikely that A\mathcal{A} would be able to obtain the entire decryption m′m^\prime of c′c^\prime, it might still be possible for A\mathcal{A} to obtain some information about m′m^\prime based on the subsequent behaviour of R\mathcal{R}.
  2. A\mathcal{A} might send a modified ciphertext c′c^\prime to R\mathcal{R} in its own name and might obtain the entire decryption for c′c^\prime.

Impossibility of perfectly secret public key encryption:

What is perfect secrecy?

In contrast to the private key setting, perfectly secret public key encryption is impossible.

Hybrid Encryption and KEM/DEM paradigms:

Public key cryptography is 2 to 3 times slower than private key encryption schemes. Is it possible to do better by using private key encryption in tandem with public key encryption schemes.

This improves efficiency because private key encryption is faster and improves bandwidth because private key schemes have lower ciphertext expansion.

The basic idea is to use a public key encryption to obtain a shared key kk and then encrypt the message mm using a private key encryption scheme and key kk

The sender would share the key kk by

  1. Choosing a uniform value kk
  2. encrypting kk using a public key encryption scheme A more direct approach is to use a public key primitive called KEM - key encapsulation mechanism to accomplish both in a single step.

KEM has three algorithms:

Gen\text{Gen}Takes as input a security parameter 1n1^n and outputs a public-private key pair (pk,sk)(pk, sk)
Encaps\text{Encaps}Takes as input a public key pkpk and the security parameter 1n1^n. It outputs a cipher text cc and a key k∈{0,1}l(n)k \in \{0, 1\}^{l(n)}
Decaps\text{Decaps}takes as input a private key sksk and a ciphertext cc, and outputs a key kk or a special symbol ⊥\bot denoting failure.

Any public-key encryption scheme trivially gives a KEM by choosing a random key kk and encrypting it.

RSA

The Factoring Assumption:

Let GenModulus\text{GenModulus} be polynomial time algorithm that on input outputs (N,p,q)(N, p, q) such that N=p⋅qN = p \cdot q and pp and qq are both n-bit primes.

Factoring experiment

  1. Run GenModulus(1n)\text{GenModulus}(1^n) to obtain (N,p,q)(N, p, q).
  2. A\mathcal{A} is given NN, and outputs p′,q′>1p^′,q^′ \gt 1.
  3. The output of the experiment is defined to be 11 if p′⋅q′=Np^′ \cdot q^′ = N, and 00 otherwise.

RSA Assumption

The factoring problem has been studied for hundreds of years without an efficient algorithm being found.

This has motivated a search for other problems whose difficulty is related to the hardness of factoring.

RSA experiment:

  1. Run GenRSA(1n)\text{GenRSA}(1^n) to obtain (N,e,d)(N, e, d).
  2. Choose a uniform y∈ZN∗y \in \mathbb{Z}^∗_N .
  3. A\mathcal{A} is given (N,e,y)(N,e,y) and outputs x∈ZN∗x \in \mathbb{Z}^∗_N.
  4. The output of the experiment is defined to be 11 if xe=ymod  Nx^e = y \mod N, and 00 otherwise.

in the above experiment to find xx, the adversary must know dd. then,

  • x≡ydmod  Nx \equiv y^d \mod N
  • xe≡(yd)e≡yd⋅e≡ymod  Nx^e \equiv (y^d)^e \equiv y^{d \cdot e} \equiv y \mod N

So how can an adversary calculate dd?

  • We know for xe⋅d≡xmod  Nx^{e \cdot d} \equiv x \mod N to hold
  • d≡e−1mod  ϕ(N)d \equiv e^{-1} \mod \phi(N)
  • an adversary knows e,Ne, N.
  • Calculating ϕ(N)\phi(N) for a vary large composite number should be expensive
  • But if i am able to obtain prime factorization of NN into pp and qq then ϕ(N)=(p−1)⋅(q−1)\phi(N) = (p-1) \cdot (q-1)
  • However, the prime factorization is difficult as discsussed in Factoring Assumption

Plain RSA:

Plain RSA Encryption:

Let GenRSA\text{GenRSA} be as in the text. Define a public-key encryption scheme as follows:

  • Gen\text{Gen}: on input 1n1^n run GenRSA(1n)\text{GenRSA}(1^n) to obtain N,e,dN, e, d. The public key is ⟨N,e⟩\langle N, e \rangle and the private key is ⟨N,d⟩\langle N, d \rangle.

  • Enc\text{Enc}: on input a public key pk=⟨N,e⟩pk = \langle N, e \rangle and a message m∈ZN∗m \in \mathbb{Z}^∗_N, compute the ciphertext

    c:=memod  Nc := m^e\mod N
  • Dec\text{Dec}: on input a private key sk=⟨N,d⟩sk = \langle N, d \rangle and a ciphertext c∈ZN∗c \in \mathbb{Z}^∗_N, compute the message

    m:=cdmod  Nm := c^d \mod N

Digital Signatures

Integrity and Authenticity in the public-key setting is provided using digital signature schemes.

Signature schemes allow a signer S\mathcal{S} who has established a public key pkpk to “sign” a message using the associated private key sksk in such a way that anyone who knows pkpk (and knows that this public key was established by S\mathcal{S}) can verify that the message originated from S\mathcal{S} and was not modified in transit.

Comparison to MACs:

Both message authentication codes and digital signature schemes are used to ensure the authenticity of transmitted message. However, there are important advantages of digital signatures over MACs as follows:

  1. A qualitative advantage that digital signatures have as compared to MACs is that signatures are publicly verifiable.
  2. Digital signature schemes also provide the very important property of non repudiation. that means that once S\mathcal{S} signs a message he cannot later deny having done so. MACs simply cannot provide non-repudiation.
  3. MACs have the advantage of being shorted and roughly 2 to 3 orders of magnitude more efficient than digital signatures.

Digital Signature Syntax:

A (digital) signature scheme consists of three probabilistic polynomial-time algorithms (Gen,Sign,Vrfy)(\text{Gen}, \text{Sign}, \text{Vrfy}) such that:

Gen\text{Gen}takes as input a security parameter 1n1^n and outputs a pair of keys (pk,sk)(pk, sk)
Sign\text{Sign}takes as input a private key sksk and a message mm from some message space. It outputs a signature σ\sigma, and we write this as σ←Signsk(m)\sigma \leftarrow \text{Sign}_{sk}(m).
Vrfy\text{Vrfy}The deterministic verification algorithm Vrfy\text{Vrfy} takes as input a public key pkpk, a message mm, and a signature σ\sigma. It outputs a bit bb, b:=Vrfypk(m,σ)b := \text{Vrfy}_{pk}(m, \sigma).

Hash and Sign Paradigm:

The intuition behind the hash-and-sign approach is straightforward. Say we have a signature scheme for messages of length ll, and wish to sign a (longer) message m∈{0,1}∗m \in \{0,1\}^∗. Rather than sign mm itself, we can instead use a hash function HH to hash the message down to a fixed-length digest of length ll, and then sign the resulting digest.