Asymmetric Cryptography

2,676 views 31 slides Jan 29, 2018
Slide 1
Slide 1 of 31
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31

About This Presentation

An introduction to asymmetric cryptography with an in-depth look at RSA, Diffie-Hellman, the FREAK and LOGJAM attacks on TLS/SSL, and the "Mining your P's and Q's attack".


Slide Content

Asymmetric Cryptography
February 8, 2017

Why Cryptography?
●Confidentiality - only intended parties can read contents
●Integrity - message tampering can be detected
●Authentication - the author is verified
●Nonrepudiation - the author cannot deny being the author

Why asymmetric cryptography?
●No need to secretly distribute key
●Difficult to brute-force
●Reuse of key does not significantly weaken security

Why not asymmetric cryptography?
●More computationally-intensive than symmetric
cryptography

RSA
●Developed by Rivest, Shamir, and Adleman in 1977
●Based on the difficulty of factoring product of 2 large
primes, being able to compute private key from public key
●Built-in confidentiality, authentication, integrity, and
nonrepudiation from owner
●Computationally expensive

RSA Keys
●Public and private key should be prime numbers ≥ 2048
bits
●Public key should be available to everyone
○Ex) Distribute using keyserver
●Private key should be known only to the owner of key pair

Key Generation and
Encryption/Decryption

RSA Key Generation
1.Pick primes of similar length (p = 61, q = 53)
2.Compute N as p x q (61 x 53 = 3233)
3.Compute the totient of N (60 x 52 = 3120)
4.Chose public exponent e that is coprime to N (17)
5.Compute the modular multiplicative inverse of e mod totient(N) (2753)

RSA Encryption
●e(m) = m
e
mod N = c
●d(c) = c
d
mod N = m
Because:
●d(m
e
) = m
ed
mod N = m -- ed = 1 + hφ(n) (Definition of multiplicative inverse)
●m
1 + hφ(n)
mod N = m
●m(m
φ(n)
)
h
mod N = m -- a
φ(n)
= 1 mod N (Euler’s Theorem)
●m(1)
h
mod N = m

Uses for RSA
●First connection in SSL/TLS
●Signing communication
○More efficient to encrypt hash of message rather than
whole message
●Subscription-based services like commercial TV, radio,
etc.

Diffie-Hellman Key Exchange
●Developed and published by Whitfield Diffie and Martin
Hellman in 1976
●Relies on difficulty of discrete logarithm problem
●Forward secrecy
●Can be performed with more than two parties
●More efficient than RSA

Diffie-Hellman Keys
●Communicating parties agree on a exponential base (g)
and prime modulus (p)
●Each communicating party generates a secret value to
use for exponentiation
●Shared symmetric key can be generated securely over
public network
○Negotiation steps, if captured, should not give away
key

Key Generation and
Encryption/Decryption

Diffie Hellman Key Exchange
1.Alice and Bob agree on p = 23 and g = 5 (which is primitive root mod 23)
2.Alice chooses a = 6, and sends Bob A = 5
6
mod 23 = 8
3.Bob chooses b = 15, and sends Alice B = 5
15
mod 23 = 19
4.S = A
b
mod p = 8
15
mod 23 = 2
5.S = B
a
mod p = 19
6
mod 23 = 2

Uses for Diffie-Hellman
●Key negotiation over public or unsecured channels
(especially Ephemeral Diffie-Hellman)
○Part of SSL/TLS
○IPSec/VPN
○SSH

Attacks on Public Key Cryptography

Timeline of “Modern” Cryptography
Post World War II - Cryptography is regulated as munitions (can’t be exported)
1975 - DES Published
1976 - Diffie-Hellman Key Exchange published
1977 - RSA published
1977 - DES Standardized (FIPS)
1985 - Amiga 1000 released
1989 - Public commercial use of the internet
1991 - PGP Released (First major instance of personal cryptography)
1993 - PGP finds it way out of the United States
1996 - Bernstein v. United States (Cryptography Export laws)
1996 - SSLv3 released (containing export grade cryptography)

Factoring RSA Export Keys
●FREAK
●March 3, 2015
●CVE-2015-0204
●Capitalizes on forcing the server to use RSA_EXPORT keys
●RSA_EXPORT Keys are 512 bits or less
●RSA_EXPORT keys were designed to be a backdoor, good enough for public
use, bad enough for the NSA to be able to break if needed
●9.6% of top million domains vulnerable

Factoring RSA Export Keys
●Man in the Middle attack that requests RSA_EXPORT keys
●Most servers just go with it
●Most clients just go with it
●Generally one RSA_EXPORT key per server
●As seen in the diagram, knowing the premaster secret breaks the session

CADO-NFS
●Implementation of Number Field Sieve
●Current fastest way to factor large numbers
●Current fastest way to compute discrete logarithm
●Can break 512 bit RSA keys in 7 hours for ~$100 on EC2

Logjam
●October 2015
●CVE-2015-4000
●Capitalizes on forcing the server to use DHE_EXPORT parameters
●Tricks the client into thinking they are standard DHE
●8.4% of the top million domains vulnerable

Number Field Sieve for Discrete Log

“Mining your P’s and Q’s”
●Low entropy RSA keys may share a common prime
●This prime can be found trivially with Euclid’s GCD Algorithm
●Finding one prime makes the other trivial to find, making generating a private
key trivial to find

Euclidean Algorithm for GCD
function gcd(a, b)
while b ≠ 0
t := b;
b := a mod b;
a := t;
return a;

More Resources:
●https://www.id0-rsa.pub/ - Cryptography Challenges
●https://www.youtube.com/watch?v=2aHkqB2-46k - Cryptography Lectures
●https://weakdh.org - Logjam Website
●https://mitls.org/pages/attacks/SMACK#freak - Freak Website
●https://factorable.net/ - Mining your P’s and Q’s
●https://github.com/kulinacs/smashcipher - Factor RSA library

Questions?

Future Events
●Introduction to Pentesting - Saturday, February 11th, 12 PM - 3 PM
●Coming up in March: Binary Exploitation
●CTFs for the semester (subject to change):
○Boston Key Party (February 25th & 26th)
○VolgaCTF (March 24th - 26th)
○ASIS CTF (April 7th - 9th)