Lecture 4++
Lecture 4++
Symmetric-key encryption
Invertible function Security depends on the shared secret a particular key. Fast, highly secure Fine for repeated communication Poor fit for one-shot communication, signatures
One-way functions
Most common functions are invertible; for any F(x) = y, there is an F-1(y) = x.
Multiplication and division DES
A function which is easy to compute in one direction, but hard to compute in the other, is known as a one-way function.
Hashing, modular arithmetic.
A one-way function that can be easily inverted with an additional piece of knowledge is called a trapdoor one-way function.
One-way functions
Public key encryption is based on the existence of trapdoor one-way functions.
Encryption with the public key is easy. Decryption is computationally hard. Knowledge of the private key opens the trapdoor, making inversion easy.
Overview of RSA
RSA is the most common and well-known public key cryptosystem Basic notation: a key pair (e,d) contains two keys:
e is the public key (used to encrypt documents) d is the private key (used to decrypt documents)
M is the plaintext message. Let R be the encryption function. R(e,M) = C. R(d,C) = M. - encryption R(d,M) = C R(e,C) = M - signing R(e,R(d,M)) = M = R(d,R(e,M))
Same function is used for both operations.
Modular Arithmetic
RSAs security is based on modular arithmetic.
a = b (mod n) <-> there is a q such that a-b=qn b is the remainder after dividing a by n 23 = 3 (mod 5)
Modular Arithmetic
Two numbers p and q are said to be relatively prime if their greatest common divisor is 1.
5 and 17, 8 and 9, 10 and 21
To compute gcd:
gcd(a,b) = gcd(b, a mod b) (Euclid, 300BC)
An inverse is a number (within the input set) and maps a given number to the identity
X * 1/X, X + -X in integer math
Multiplicative Inverses
3 and 2 are multiplicative inverses mod 5. 7 and 6 are multiplicative inverses mod 41. 5 and 2 are multiplicative inverses mod 9. For n > 1, if a and n are relatively prime, there is a unique x such that
ax = 1 (mod n)
More preliminaries
Fermats Little Theorem:
If p is prime, then for all a:
ap-1 = 1 (mod p)
RSA example
Let p = 11, q = 13 n = pq = 143 (p-1)(q-1) = 120 = 3 x 23 x 5 Possible d: 7, 11, 13, 17, (lets use 7) Find e: e*7 = 1(mod 120) = 103 Public key: (7, 143) Private key: (103, 143) En(42) = 427 (mod 143) = 81 De(81) = 81103(mod 143) = 42
Correctness of RSA
To show RSA is correct, we must show that encryption and decryption are inverse functions:
En(De(M)) = De(En(M)) = M = Med (mod n) Since d and e are multiplicative inverses, there is a k such that:
ed=1+ kn = 1 + k(p-1)(q-1) Med = M1+k(p-1)(q-1) = M*(Mp-1)k(q-1) By Fermat: Mp-1=1(mod p) Med = M(1)k(q-1)(mod p) = M(mod p)
Correctness of RSA
Med = M(1)k(q-1)(mod p) = M(mod p) Med = M(1)k(q-1)(mod q) = M(mod q) By Chinese Remainder Thm, we get: M^{ed} = M (mod p) M (mod q) = M (mod pq) = M (mod n)
Strengths of RSA
No prior communication needed Highly secure (for large enough keys) Well-understood Allows both encryption and signing
Weaknesses of RSA
Large keys needed (1024 bits is current standard) Relatively slow
Not suitable for very large messages
Security of RSA
The security of RSA is dependent on the assumption that its difficult to generate the private key d from the public key e and the modulus n. Equivalent to integer factorization problem.
This is how we got e and d in the first place.
Difficulty of Factoring
The fastest known factoring algorithm is the generalized number field sieve.
Sub-exponential time Greater than polynomial space.
Some statistics:
Number Length 430 760 1020 1620 Machines 1 215,000 342 million 1.6x10^15 Memory/Machine Trivial 4Gb 170 Gb 120 Tb
Digital Signatures
Desirable properties of a digital signature:
A receiver must be able to validate the signature The signature must not be forgeable The signer must not be able to repudiate the signature.
Hash Functions
A hash function is a one-way function that maps a message M into a (typically smaller) hashed message H. Sometimes this is called a fingerprint Also sometimes a message digest.
Goals:
Non-invertible fast low collision rate
Hash Functions
To sign a document, I compute its hash, encrypt that with my private key, and send the encrypted hash along with the original document as plaintext. The receiver hashes the plaintext and then uses my public key to verify that I was the one who sent the document. Can also detect tampering.
Authentication
A sends Please authenticate me to B B creates a random message and signs it with As public key. A decrypts the message with its private key, encrypts it with Bs public key, and returns it.
Only someone with As private key can do this.
Zero-knowledge Protocols
One application of public-key cryptography is zero-knowledge protocols. Often, one party might want to prove something to another without revealing any information
Nuclear treaties Bank balances Sensitive information
Zero-knowledge protocols
Alice wants to prove to Bob that she is Alice.
If she sends identification, Bob (or an eavesdropper) can use it.
Example: Authority chooses a number N=77, known by all. Alices public ID: (58, 67) Alices private ID: (9,10)
These are multiplicative inverses mod 77
Zero-knowledge protocols
Alice chooses some random numbers and computes their square mod N.
{19, 24, 51} -> 192(mod 77) = 53, 242(mod 77) = 37, 512(mod 77) = 60 Alice sends {53,37,60} to Bob. Bob sends back a random 2x3 matrix of 1s and 0s. 01 10 11
Zero-knowledge protocols
Alice uses this grid, plus her original random numbers and her secret numbers, to compute: 19 * 90 * 101 (mod 77) = 36 24 * 91 * 100 (mod 77) = 62 51 * 91 * 101 (mod 77) = 47 She sends {36,62,47} to Bob.
Zero-knowledge protocols
Bob verifies Alices identity by computing:
{58,67} are Alices public numbers
36^2 *58^0 *67^1 (mod 77)= 53 62^2 *58^1 * 67^0 (mod 77) = 37 47^2 * 58^1 * 67^1 (mod 77) = 60 Alices original numbers reappear!
(Actually, an attacker would have a 1 in 64 chance of guessing correctly )
Zero-knowledge protocols
In a real system, N would be very large
160 digits.
Many more numbers would be generated. This works because Alices secret numbers are multiplicative inverses of her public numbers mod N. Also, Bob learns nothing that he didnt know before.
Summary
Public key encryption provides a flexible system for secure communication in open environments. Based on one-way functions Allows for both authentication and signing Secure public key distribution remains a problem.