- Select two prime numbers
- prime numbers are represented by "P" & "Q"
- Calculate product of prime numbers
- "P" x "Q" = "N"
- Calculate totient of "N"
- totient is product of 1 subtracted from each prime number represented by "T"
- "T" = ("P"-1) x ("Q"-1)
- Select Public Key
- Public key value is represented by "E" and must match following requirements:
- must be a prime number
- must be less than totient ("T")
- must not be a factor of totient ("T")
- a factor is a number you can multiple to get another number
- e.g factors of 12 are 1, 2, 3, 4, 6, and 12
- Calculate Private Key
- product of public key multipled by private key when divided by totient must result in remainder of 1
- represented by "D"
- (D x E) MOD T = 1
- MOD is modulus which calculates remainders i.e. 16 MOD 3 = 1 (3 into 16 goes 5 times with 1 remaining)
- RSA encryption formula
- cipher text = M ^ E MOD N
- RSA decryption formula
- plain text = M ^ D MOD N
- where "M" is the "message"
- Simple Encryption/Decryption Example
- Variables
- P=7
- Q=11
- N=77
- T=60 (7-1 x 11-1)
- E=23 (meets the 3 public key criteria)
- D=47 (meets the private key criteria)
- (47 x 23) MOD 60 = 1
- Encrypt Plaintext "65" (ASCII codepoint "A")
- (65 ^ 23) MOD 77 = 32
- 32 is the ciphertext of "65" plaintext (i.e."H")
- Decrypt CipherText of "32"
- (32 ^ 47) MOD 77 = 65
- 65 is the plaintext of the ciphertext of "32"