Lecture 6 - Key Exchange and Public-Key Cryptography
eecs-388
Diffie-Hellman Key Exchange
- Alice and Bob can have a public conversation to derive a secret shared key
Procedure
- use public (often from standards) parameters:
- p: a large prime (e.g. 2048-bits)
- g: a primitive root modulo p (usually small)
- Alice generates a random secret value Bob generates random secret value Alice computes and shares it with Bob Bob computes and shares it with Alice
- Alice computes Bob computes Alice and Bob each obtain the same value: Mallory is not able to derive in polynomial time either or
Security of Diffie-Hellman
- passive eavesdropping fails
- Eve knows
- Eve wants to compute
- best known approach: find or , then compute
- finding given is an instance of the discrete logarithm problem, which is believed to be intractable for 2048-bit
- active MITM attack succeeds
- Alice does DH with Mallory, ends up with
- Bob does DH with Mallory, ends up with
- Alice and Bob think they’re talking to each other, but really they’ve computed a separate secret key shared with Mallory
- DH dives you a shared secret, but you don’t know who it’s shared with
Issues About Keys
Defending DH from MITMs Approaches:
- trust-on-first-use - hope there’s no attacker the first time, but detect if keys change later (SSH)
- have users communicate out-of-band - ask people to meet or call each other to verify they have the same (Signal)
- rely on proximity to limit MITMs - attacker must be nearby, or in contact (IoT devices)
- use digital signatures - what HTTPS websites do Important Goal: forward secrecy
- we usually want to communicate repeatedly
- pitfall - adversary could record all the ciphertexts, then later steal our key
- solution - for each session, use DH to generate a temp session key; use separate long-term key to authenticate it
- benefits - compromising long-term key would allow future impersonation but not retrospective decryption (assuming attacker can’t break DH)
RSA - Public-Key Cryptography
- since antiquity, encryption key = decryption key “symmetric key crypto”
- breakthrough - keys can be distinct
“Textbook” RSA
key generation (in secret):
- generate large random primes and (say, 2048 bits each)
- compute “modulus” (say, 4096 bits)
- pick small “encryption exponent” (say, 65537) must be relatively prime to
- compute “decryption exponent” such that
- yields RSA key pair: - public key - - private key -
- public key encryption:
- encrypt -
- decrypt -
- digital signatures:
- sign -
- verify:
Facts about RSA
- RSA can be used for confidentiality and/or integrity+authenticity
- confidentiality - public-key encryption
- Alice encrypts using Bob’s public key to get
- Bob decrypts using Bob’s private key to get
- integrity/sender authenticity - digital signatures
- Alice signs using Alice’s private key to get
- Bob verifies using Alice’s public key
- both properties - use both, with two key pairs
- Alice encrypts using Bob’s public key to get , then Alice signs using Alice’s private key to get
- Bob verifies using Alice’s public key, then Bob decrypts using Bob’s private key to get
Security
- best known way to compute from is factoring into and
- best known algorithm - number field sieve
- believed intractable for 4096-bit
Drawbacks
-
1000x slower than AES
- messages must be shorter than
- keys must be relatively large
Alternative - Elliptic-Curve Cryptography (ECC)
- elliptic curves are a mathematical alternative for constructing key exchange, signing, encryption
- pros: attacks (hoped) harder, so key can be shorter
- ex: ECDH, ECDSA, Ed25519
Subtle Attacks on Textbook RSA
