Chapter-5-PKE & RSA
Chapter-5-PKE & RSA
➢ Plaintext: This is the readable message or data that is fed into the algorithm as input.
➢ Public and private keys: This is a pair of keys that have been selected so that if one is
used for encryption, the other is used for decryption. The exact transformations performed
by the algorithm depend on the public or private key that is provided as input.
➢ Decryption algorithm: This algorithm accepts the ciphertext and the matching key and
produces the original plaintext.
Principles of public-key
Cryptosystems
Principles of public-key
Cryptosystems
Principles of public-key
Cryptosystems
• The essential steps are the following:
1. Each user generates a pair of keys to be used for the encryption and
decryption of messages.
2. Each user places one of the two keys in a public register or other accessible
file. This is the public key. The companion key is kept private. Each user
maintains a collection of public keys obtained from others.
4. When Alice receives the message, she decrypts it using her private key. No
other recipient can decrypt the message because only Alice knows Alice’s
private key.
Principles of public-key
Cryptosystems
• There is some source A that produces a message in plaintext, X = [𝑿𝟏 , 𝑿𝟐 , 𝑿𝟑 … 𝑿𝒎 ].
• B generates a related pair of keys: a public key, 𝑷𝑼𝒃 , and a private key, 𝑷𝑹𝒃 .
• 𝑃𝑅𝑏 is known only to B, whereas 𝑃𝑈𝑏 is publicly available and therefore accessible by A.
• With the message X and the encryption key 𝑃𝑈𝑏 as input, A forms the ciphertext Y =
[𝒀𝟏 , 𝒀𝟐 , 𝒀𝟑 … 𝒀𝒎 ] Y = E(𝑷𝑼𝒃 , X)
• The intended receiver, in possession of the matching private key, is able to invert the
transformation: X = D(𝑷𝑹𝒃 ,Y)
Principles of public-key
Cryptosystems
• An adversary, observing Y and having access to 𝑷𝑼𝒃 , but not having access
to 𝑷𝑹𝒃 or X, must attempt to recover X and/or 𝑷𝑹𝒃 . It is assumed that the
adversary does have knowledge of the encryption (E) and decryption (D)
algorithms. If the adversary is interested only in this particular message,
then the focus of effort is to recover X by generating a plaintext estimate Xn
Principles of public-key
Cryptosystems
Principles of public-key
Cryptosystems
• In this case, A prepares a message to B and encrypts it using A’s private key
before transmitting it.
• Because the message was encrypted using A’s private key, only A could have
prepared the message.
• Z = E(PUb, E(PRa,X))
• X = D(PUa, D(PRb,Z))
Applications for Public-Key
cryptosystem
• We can classify the use of public-key cryptosystems into three
categories
Encryption/decryption: The sender encrypts a message with the recipient’s
public key, and the recipient decrypts the message with the recipient’s private
key.
Digital signature: The sender “signs” a message with its private key. Signing
is achieved by a cryptographic algorithm applied to the message or to a small
block of data that is a function of the message.
Key exchange: Two sides cooperate to exchange a session key, which is a
secret key for symmetric encryption generated for use for a particular
transaction (or session) and valid for a short period of time. Several different
approaches are possible, involving the private key(s) of one or both parties;
Applications for Public-Key
cryptosystem
Requirements for Public-Key
cryptosystem
The conditions that such algorithms must fulfill:
• It is computationally easy for a party B to generate a key pair (public key PUb, private key
PRb).
• It is computationally easy for a sender A, knowing the public key and the message to be
encrypted, M, to generate the corresponding ciphertext: C = E(PUb, M)
• It is computationally easy for the receiver B to decrypt the resulting ciphertext using the
private key to recover the original message: M = D(PRb, C) = D[PRb, E(PUb, M)]
• It is computationally infeasible for an adversary, knowing the public key, PUb, to determine
the private key, PRb.
• It is computationally infeasible for an adversary, knowing the public key, PUb, and a
ciphertext, C, to recover the original message, M. We can add a sixth requirement that,
although useful, is not necessary for all public-key applications:
The two keys can be applied in either order: M = D[PUb, E(PRb, M)] = D[PRb, E(PUb, M)]
RSA Algorithm
• Developed in 1977 by Ron Rivest, Adi Shamir, and Len Adleman at MIT and first
published in 1978
➢ The RSA scheme is a cipher in which the plaintext and ciphertext are integers between
0 and n - 1 for some n.
➢A typical size for n is 1024 bits, or 309 decimal digits. That is, n is less than 2(1024).
• The private key consists of {d, n} and the public key consists of {e, n}.
• Suppose that user A has published its public key and that user B wishes to
send the message M to A.
• Then B calculates C = Me mod n and transmits C. On receipt of this
ciphertext, user A decrypts by calculating M = Cd mod n.
RSA Algorithm
RSA Example:
• Select two prime numbers, p = 17 and q = 11
• Calculate n = pq = 17 * 11 = 187.
• Select e such that e is relatively prime to Ф(n) = 160 and less than Ф(n); we
choose e = 7.
• Determine d such that de = 1 (mod 160) and d < 160. The correct value is d =
23, because 23 * 7 = 161 = (1 * 160) + 1; d can be calculated using the
extended Euclid’s algorithm
• The resulting keys are public key PU = {7, 187} and private key PR = {23,
187}
RSA Example:
• The example shows the use of these keys for a plaintext input of M = 88. For
encryption, we need to calculate C = 88 7 mod 187. Exploiting the properties
of modular arithmetic, we can do this as follows.
RSA Example:
RSA Example:
Diffie-Hellman Key Exchange
• The purpose of the algorithm is to enable two users to securely exchange a
key that can then be used for subsequent symmetric encryption of messages.
The algorithm itself is limited to the exchange of secret values.
That is, if a is a primitive root of the prime number p, then the numbers:
are distinct and consist of the integers from 1 through p - 1 in some permutation.
Diffie-Hellman Key Exchange
Example of primitive root:
• 2 mod 5=2
• 22 mod 5 = 4 mod 5 =4
• 23 mod 5 = 8 mod 5 = 3
• 24 mod 5 = 16 mod 5 = 1
Diffie-Hellman Key Exchange
• For this scheme, there are two publicly known numbers: a prime number q and an
integer a that is a primitive root of q.
• Each side keeps the X value private and makes the Y value available publicly to
the other side.
• Thus, 𝑿𝑨 is A’s private key and 𝒀𝑨 is A’s corresponding public key, and similarly
for B.
Diffie-Hellman Key Exchange
• User A computes the key as 𝑲 = 𝒀𝑩 𝑿𝑨 𝒎𝒐𝒅 𝒒 and user B computes the key as 𝑲 = 𝒀𝑨 𝑿𝑩 𝒎𝒐𝒅 𝒒 .
• Example:
Key exchange is based on the use of the prime number q = 353 and a primitive root of 353, in
this case a = 3.
A and B select private keys 𝑿𝑨 = 97 and 𝑿𝑩 = 233, respectively. Each computes its public key:
After they exchange public keys, each can compute the common secret key:
Diffie-Hellman Key Exchange
Diffie-Hellman Key Exchange
Man in the middle attack:
Suppose Alice and Bob wish to exchange keys, and Darth is the adversary.
The attack proceeds as follows:
Diffie-Hellman Key Exchange
ELGAMAL CRYPTOGRAPHIC SYSTEM
So C1 = ak mod q = a6 mod 19 = 11
Then,