Rivest-Shamir-Adleman
Algorithm used for Asymmetric cryptography.
- Public key = (n,e) where n= large modulus and e= encrypting exponent
- Private key= (n,d) where n=large modulus and d= decrypting exponent
Key generation
-
Calculate
- Where and are large prime numbers.
- and are kept secret.
- is public.
-
Choose
- is a randomly chosen number (preferably prime).
- Most common values: and .
- Reason: They can be efficiently used for modular exponentiation.
- Note: 3 is not considered safe.
- is public.
-
Calculate
-
Calculate
- is private.
Security Note: It is computationally infeasible to calculate from because and are secret and it is very difficult to derive them from .
Encryption
Formula:
- : Cipher text
- : Unencrypted message
Process:
- Modular Exponentiation: This is performed to encrypt . This method is used because when and are large, calculating directly becomes exponentially (impossibly) large.
- Padding: Padding is done to add randomness to the data.
Note
The encrypted message for the same plaintext will nearly always be different. To avoid same output on every encryption, secure implementations of RSA always use a process called padding before the message is encrypted
Decryption
Formula:
Representation of keys
Public or private keys can be stored and transferred in different ways. Two of them include -