Cryptography Prof. Seth D. Bergmann Rowan University Computer Science
Cryptography: Why? Secure communication is needed by: Government Military Financial organizations Individual citizens The Internet is not a secure channel.
Cryptography Alice wishes to send a confidential message to Bob.
Cryptography (Evil) Eve wants to intercept the message To learn what Alice is sending to Bob To change all or part of the message to Bob To pretend that she is Alice (and/or Bob). Eve Bob Alice
How Can Alice and Bob Thwart Eve? Encrypt the message (plain text) into an unreadable form (cipher text) which only Bob can decipher Authenticate Alice’s message, to prove that it is really sent directly by Alice Provide a message ‘digest’ which guarantees that Eve has not tampered with the message.
Secure Communication Terminology Cryptology Cryptography (Encryption and decryption) Cryptanalysis (“Breaking” a code) Authentication Integrity Verification (of authenticity and integrity) Key Distribution Certificates.
Metaphors Authentication Certificate Encryption and Integrity Ordinary Email To::
Private-key Cryptography Same key used for encryption and decryption Symmetric Key distribution is a major problem.
Private-key Cryptography OK, How about 11011001 ? We need to agree on a Key!
Key Distribution Could Be a Problem OK, I’ve got your key!!! OK, How about 11011001 ? We need to agree on a Key!
Private-key Cryptography We both need to know how to use this key for encryption and decryption !
Math for Encryption and Decryption All information is coded as 0’s and 1’s For example: ‘A’ is 00000 ‘B’ is 00001 ‘C’ is 00010 ‘Z’ is 11001
Math for Encryption and Decryption Exclusive OR is defined as: + x y 1 0 = false 1 = true Exclusive OR means ‘different’
Math for Encryption and Decryption x y 1
Using XOR to Encrypt a Message Example: plain 00111 01000 = “HI” key 01011 00110 = “LG” cipher 01100 01110 = “MO”
Using XOR to Decrypt the Cipher
Using XOR to Decrypt the Cipher Example: cipher 01100 01110 = “MO” key 01011 00110 = “LG” plain 00111 01000 = “HI”
Private-Key Cryptography Summary Encryption: Decryption:
Public-key Cryptography Each person has two keys: Public key, used by anyone encrypting messages to this person Private key, used by this person to decrypt received messages A person may announce the public key to the world, but the private key is secret. The public and private keys are related in such a way that the private key is used to decrypt any message encrypted with the public key.
Use it to encrypt messages to me! Bob Has Two Keys My private key is 0001011101 My public key is 1011100010! Use it to encrypt messages to me!
Alice Uses Bob’s Public Key to Encrypt the Message Encr(1011100010 ,“Hey!”) = “gX&*3i” “gX&*3i”
Bob Uses His Private Key to Decrypt the Message Decr(“gX&*3i”, 0001011101) = “Hey!”
Eve Has Been Thwarted “gX&*3i” “Hey!” ??? “Hey!” No problem with key distribution!
How Does it Work? Prime numbers have no divisors: 2, 3, 5, 7, 11, 13, 17, 19, 23, ... Every number is the product of prime factors Examples 36 = 2 x 2 x 3 x 3 21 = 3 x 7 100 = 2 x 2 x 5 x 5 Finding factors of large numbers is hard
Public and Private Keys The public and private keys are related To find Bob’s private key, using his public key, Eve will have to factor the public key. This could take years, even with a fast computer. Eve has been thwarted.
How Does Public Key Cryptography Work? Mathematics Modular Arithmetic Exponents, modular Multiplicative inverse, modular.
Modular Arithmetic 2 1
Modular Arithmetic Remainder after division Example:
Mod 5 4 1 3 2
Multiplicative Inverses if xy = 1, then x and y are inverses What is the inverse of 2 (mod 5)?
How Does Public Key Cryptography Work? My private key is 0001011101 My public key is 1011100010! Use it to encrypt messages to me!
How Does Public Key Cryptography Work? Bob chooses two random prime numbers: p and q Bob’s public modulus is m = pq n = (p-1) (q-1) Bob chooses a number, e, which is relatively prime to n (e and n share no factors) e is Bob’s (public) encryption exponent m and e, together, make up Bob’s public key.
How Does Public Key Cryptography Work? Bob announces his public key (m,e) to the world To encrypt a message to Bob, Alice codes the message as a number and uses his public key:
Decryption Bob will need a private key, d, to decrypt the message: The (private) decryption exponent is the inverse of the (public) encryption exponent
Decryption From Fermat’s Little Theorem (1636): To decrypt the message from Alice, Bob uses his private key, d:
Can Eve Find Bob’s Private Key? Hmm, m = 55 = 5*11 = p*q n = (p-1) * (q-1) = 4*10 = 40 d = e-1 (mod 40) = 23 Gotcha! My public key is: m = 55 e = 7
Public Key Cryptography My private key is d = 103,583,939 I don’t care who intercepts the message. My public key is: m = 117,852,727 e = 24,059 Use these to encrypt messages to me!
Can Eve Find Bob’s Private Key? Hmm, m = 117,852,727 = ??? Takes too long to factor!!! Foiled!! My public key is: m = 117,852,727 e = 24,059
Useful By-products of Public Key Cryptography Integrity: Has somebody tampered with this message? Authentication: Is this message really coming from the person in the from field, or is it from an impostor? (Digital signature).
Integrity To: Alice From: Bob You stink! To: Alice From: Bob I Love You Eve can intercept a message, change it, and forward it to Alice, without her knowing it! (Integrity is poor)
Authentication To: Alice From: Bob Meet me after school at McD’s! Eve can send a message to Alice, pretending to be Bob! (The message is not authentic)
Digital Signatures Bob wishes to sign a message to Alice in such a way that she can be sure it is from him She will also know that nobody has tampered with the message.
Digital Signatures Solution to both problems Ensure message integrity Provide authentication By-product of public-key cryptography.
Digital Signatures Bob encrypts the message with his private decryption key, d!!! This is his signature. Sig = Decr(msg) He sends his signature and the message to Alice. To: Alice From: Bob I Love You Signed: 011010
Verification Alice uses Bob’s public encryption key (m,e) to decrypt the signature. Encr(sig) = msg If the result doesn’t match the message, she knows that either Someone altered the message or the signature, or The message did not come from Bob It’s really from Bob! To: Alice From: Bob I Love You Signed: 011010 To: Alice From: Bob I Love You Encr(011010) = I Love You
Digital Signatures Why does it work? (msgd)e (mod m) = msg There is only one person who knows d: Bob He is the only one who could have created the signature, msgd.
Summary Communications Security is Improved by Cryptography (Encryption & Decryption) Integrity (Tamper-proof communications) Authenticity (Impostors are ignored) No security system is 100% effective Thank you for listening... And be careful!!
Are You Interested in Computer Science? http://cs.rowan.edu/compsci www.abet.org