110 likes | 177 Views
CSC 386 – Computer Security. Scott Heggen. Agenda. Exploring that locked box thing from Friday?. Rivest , Shamar, and Adleman (RSA). A public key encryption method Based on the fact that computers have trouble factoring large prime numbers
E N D
CSC 386 – Computer Security Scott Heggen
Agenda • Exploring that locked box thing from Friday?
Rivest, Shamar, and Adleman (RSA) • A public key encryption method • Based on the fact that computers have trouble factoring large prime numbers • Used extensively in many systems and protocols, such as SSH
RSA • Step 1: • Convert your text to numerical values. • Usually this step is inherent, as everything is already represented as a number • For this example, we will simplify things by assuming • A = 1 • B = 2 • C = 3 • …
RSA • Step 2: • Generate a pair of keys: • Pick 2 very large random numbers • p = 3 • q = 11 • Compute the product: • n = 3 x 11 = 33 • φ(n) = (p-1) × (q-1) = 2 × 10 = 20 • Select a number less than φ(n), and relatively prime (few factors) • e = 7 With very large values of p and q, n is extremely difficult for a computer to reverse! Public key!
p = 3 q = 11 φ(n) = 20 n = 33 e = 7 RSA • Compute the matching private key d, as the inverse of e mod φ(n): • d = inv of e mod φ(n) = inv(7) mod 20 = 3 • 7 x 1 mod 20 = 7 • 7 x 2 mod 20 = 14 • 7 x 3 mod 20 = 1 • Public key (e): (7, 33) • Private key (d): (3, 33) In other words: 7 x ? mod 20 = 1
RSA Alice Bob Public key (e): (7, 33) Private key (d): (3, 33) C Eve
p = 3 q = 11 φ(n) = 20 n = 33 e = 7 d = 3 RSA m = “abc” = 123 • Step 3 (Alice) • Encrypt your message using the public key (e) • C = mkey mod n • For A: • CA = 17 mod 33 = 1 • For B: • CB = 27 mod 33 = 29 • For C: • Cc = 37 mod 33 = 9 C = 1, 29, 9
RSA Alice Bob Public key (e): (7, 33) Private key (d): (3, 33) C Eve knows: C = 1, 29, 9 e = (7, 33) Eve
p = 3 q = 11 n = 33 φ(n) = 20 e = 7 d = 3 RSA C = 1, 29, 9 • Step 4 (Bob) • Decrypt the cipher using the private key (d) • m = Ckey mod n • For A: • mA = 13 mod 33 = 1 • For B: • mB = 293 mod 33 = 2 • For A: • mC = 93 mod 33 = 3 Eve knows: C = 1, 29, 9 e = (7, 33)
Next Class • Quiz on RSA • Be able to encrypt a message given a public key • Be able to decrypt a message given a private key