Unit 2
Unit 2
Unit 2
RSA is a best known and widely used public-key scheme by Rivest, Shamir
and Adleman of MIT in 1977.
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. Encryption is
denoted by E and decryption is denoted by D, plain text is denoted by M and
ciphertext is denoted by D.
Public key:
PU={e,n} Private
key: PR={d,n}
Both the sender and receiver must know ‘n’. The sender knows ‘e’ amd the receiver
knows ‘d’.
The requirements to be satisfied by the algorithm are
(i) It is possible to find values of e,d and n such that Med = M mod n for all
M<n.
(ii) It is easy to calculate t Me and Cd for all values of M<n
(iii) It is infeasible to determine d given e and n.
Key Generation
Select two prime numbers p and q,
where p ≠ q Calculate n = p*q
Calculate φ(n) = (p – 1)(q – 1)
Select e such that e is relatively prime to φ(n) and less than φ(n).
Calculate d such that de ≡ 1 mod f(n) and d<f(n). d is calculated using
extended Euclid’s algorithm.
Encryption
Plaintext: M<n
Ciphertext: C = Me (mod
n) Decryption
Plaintext: M = Cd (mod n)
Example:
Choose p = 3 and q = 11
Compute n = p * q = 3 * 11 = 33
Compute φ(n) = (p - 1) * (q - 1) = 2 * 10 = 20
Choose e such that 1 < e < φ(n) and e and n are coprime. Let e = 7
Compute a value for d such that (d * e) % φ(n) =
1. One solution is d = 3 [(3 * 7) % 20 = 1]
Public key is (e, n) => (7, 33)
Private key is (d, n) =>
(3, 33) The encryption c=
𝑚𝑒mod n
M=2
C = 27 % 33 = 29
The decryption
M=𝐶𝑑mod n
C = 29
M = 293 % 33 = 2
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.
Alice and Bob share a prime Alice and Bob share a prime
number q and an integer α, such number q and an integer α, such
that α <q and α is a primitive root that α <q and α is a primitive root
of q of q
Alice calculates public key YA = αXA mod q Bob calculates public key YB = αXB mod q
Alice receives Bobs public key YB in plain text Bob receives Bobs public key YA in plain text
Alice calculates rhe shared secret Bob calculates rhe shared secret
key K = (YB)XA mod q key K = (YA)XB mod q
For this scheme, there are two publicly known numbers: a prime number q and an
integer that is a primitive root of q.
Suppose the users A and B wish to exchange a key, user A selects a random
integer XA < q and computes YA = αXA mod q.
Similarly, user B independently selects a random integer XB < q and computes
YB=αXB mod q. Each side
keeps the X value private and makes the Y value available publicly to the other
side. User A computes the key as K = (YB)XA mod q
User B computes the key as K = (YA)XB mod q.
Man-in-the-Middle Attack
The protocol is insecure against a man-in-the-middle attack. Suppose Alice and
Bob wish to exchange keys, and Darth is the adversary. The attack proceeds as
follows:
1.
Darth prepares for the attack by generating two random private keys XD1
and XD2 and then computing the corresponding public keys YD1 and YD2.
2.
Alice transmits YA to Bob.
3.
Darth intercepts YA and transmits YD1 to Bob. Darth also calculates
K2=(YA)XD2 modq.
4.
Bob receives YD1 and calculates K1 =
(YD1)XB mod q. 5.Bob transmits XA to Alice.
6.
Darth intercepts XA and transmits YD2 to Alice. Darth calculates K1 = (YB)XD1
mod q.
7.
Alice receives YD2 and calculates K2 = (YD2)XA mod q.
At this point, Bob and Alice think that they share a secret key, but instead
Bob and Darth share secret key K1 and Alice and Darth share secret key
K2.
All future communication between Bob and Alice is compromised in the following
way:
1.
Alice sends an encrypted message M: E(K2, M).
2.
Darth intercepts the encrypted message and decrypts it, to recover M.
3.
Darth sends Bob E(K1, M) or E(K1, M'), where M' is any message. In the
first case, Darth simply wants to eavesdrop on the communication without
altering it. In the second case, Darth wants to modify the message going to
Bob.
This vulnerability can be overcome with the use of digital signatures and public-key
Certificates.
ELLIPTIC CURVE CRYPTOGRAPHY [ECC]
Elliptic curve cryptography [ECC] is a public-key cryptosystem. Every user has a
public and a private key.
– Public key is used for encryption/signature verification.
– Private key is used for decryption/signature
generation. Elliptic curves are used as an extension to other
current cryptosystems. ECC- Algorithm
Both parties agree to some publicly-known data items
Therefore, the elliptic curve equation y2 = x3 + ax + b
mod p and values of a and b such that 4a3 + 27 b2 ≠ 0
The elliptic group is computed from the elliptic curve equation A base
point, G, taken from the elliptic group
Each user generates their public/private key pair
Private Key = an integer, x selected from the interval [1, p-1]
Public Key = product of private key
and base point (Product = x*G)
Example :
• Suppose Alice wants to send to Bob an encrypted message.
– Both agree on a base point, G.
– Alice and Bob create public/private keys.
Alice : Private Key = nA
Public Key = PA =
nA * G Bob : Private
Key = nB
Public Key = PB = nB * G
Alice takes plaintext message, M, and encodes it onto a point, PM, from the elliptic
group.
Encryption : Alice choose another random k value from { 1,2,
… p-1 } Cipher text : Cm = { KG, Pm + KPB }
Decryption : by Bob
Take the first point from Cm - KG
Multiply KG and private key of Bob : Product = nB KG
Take the second point from Cm and subtract the
product from it Pm + KPB - nB KG
Substitute PB = nB * G
Then Pm + K nB * G - nB KG = Pm
Certificates
Figure shows the general format of a certificate, which includes the following
elements: Version:
Differentiates among successive versions of the certificate format; the default is
version 1.
Serial number: An integer value, unique within the issuing CA, that is
unambiguously associated with this certificate.
Signature algorithm identifier: The algorithm used to sign the certificate,
together with any associated parameters
Issuer name: X.500 name of the CA that created and signed this certificate.
Period of validity: Consists of two dates: the first and last on which the certificate
is valid. Subject name: The name of the user to whom this certificate refers. That
is, this certificate certifies the public key of the subject who holds the
corresponding private key.
Subject's public-key information: The public key of the subject, plus an identifier
of the algorithm for which this key is to be used, together with any associated
parameters.
Issuer unique identifier: An optional bit string field used to identify uniquely the
issuing CA in the event the X.500 name has been reused for different entities.
Subject unique identifier: An optional bit string field used to identify
uniquely the subject in the event the X.500 name has been reused for different
entities.
Extensions: A set of one or more extension fields.
Signature: This field includes the signature algorithm identifier.
Any user with access to the public key of the CA can verify the user
public key that was certified.
No party other than the certification authority can modify the certificate
without this being detected. Because certificates are unforgeable, they can be
placed in a directory without the need for the directory to make special efforts
to protect them.
Certificate Revocation
Certificates have a period of validity.
May need to revoke before expiry, eg:
User's private key is compromised
User is no longer certified by this CA
CA's certificate is compromised