PUBLIC-KEY
CRYPTOGRAPHY
Public key cryptography involves a pair of keys known
as a public key and a private key (a public key pair),
which are associated with an entity that needs to
authenticate its identity electronically or to sign or
encrypt data. Each public key is published and the
corresponding private key is kept secret.
Example
Bob wants to send Alice an encrypted email. To
do this, Bob takes Alice's public key and encrypts
his message to her. Then, when Alice receives the
message, she takes the private key that is known
only to her in order to decrypt the message from
Bob.
RSA algorithm (Rivest-Shamir-Adleman)
RSA algorithm is an asymmetric cryptography algorithm.
Asymmetric actually means that it works on two different
keys i.e. Public Key and Private Key.
As the name describes that the Public Key is given to
everyone and the Private key is kept private.
◦RSA algorithm uses the following procedure to generate public
and private keys:
◦Select two large prime numbers, p and q.
◦Multiply these numbers to find n = p x q, where n is called the
modulus for encryption and decryption.
◦Choose a number e less than n, such that n is relatively prime
to φ (n) = (p - 1) x (q -1).
It means that e and φ (n) have no common factor except 1. Choose "e"
such that 1<e < φ (n), e is prime to φ (n),
gcd (e,d(n)) =1
◦If n = p x q, then the public key is <e, n>.
A plaintext messageP is encrypted using public key <e, n>. To find
ciphertext from the plain text following formula is used to get
ciphertext C.
C = Pe mod n
Here, P must be less than n. A larger message (>n) is treated as a
concatenation of messages, each of which is encrypted
separately.
◦To determine the private key,
we use the following formula to calculate the d such that:
De mod {(p - 1) x (q - 1)} = 1
Or
De mod φ (n) = 1
◦The private key is <d, n>.
A ciphertext message c is decrypted using private key <d, n>. To
calculate plain text p from the ciphertext c following formula is
used to get plain text p.
P = cd mod n
Example 2