Implementing SSL
Implementing SSL
SSL/TLS
Joshua Davies
Director of Architecture 2Xoffice
Author of Implementing SSL/TLS
Using Cryptography and PKI
Outline
Cryptographic concepts
Symmetric Cryptography
Public-key cryptography
Digital Signatures
Certificates
SSL/TLS
Handshake
Advanced/optional components
Digital Security
Privacy
Integrity
Authentication
Authorization
Non-repudiation (I can prove you did
it)
Privacy - Encryption
C = Ek(P), P = Dk(C); K is a secret parameter
Ciphers: standard algorithms such as DES,
3DES, AES, RC4, Blowfish, IDEA hundreds
more
SSL/TLS provisionally supports any cipher
Most implementations support DES, 3DES,
AES and RC4
Called symmetric because the same key is
used for encryption and decryption
DES
Oldest digital cipher still in use
Developed by IBM for the NSA in
1974
Fixed 56-bit key size
3DES
Triples DES key size by running the
DES algorithm three times
Encrypt
K1
Decrypt
K2
Encrypt
K3
Rijndael/AES
NIST started looking for a
replacement for DES in 2001
Rijndael supports 128, 192 and 256bit keys
AES Encryption
RC4
Stream, rather than a block, cipher
Generates a single keystream as long
as the plaintext
No need for CBC or padding
RC4 Encryption
Diffie-Hellman Key
Exchange
Virtually unused, but TLS 1.0
mandates it be supported
Can only be used for secret
exchange, not for general encryption
Diffie-Hellman
Client
generate random a
Yc = (ga%p)
Z = Ysa%p
Server
generate random b
Ys=(gb%p)
Z = Ycb%p
Elliptic-Curve Cryptography
Relatively new, not much commercial
support
Based on operations on the curve
y2=x3+ax+b
Similar to Diffie-Hellman, but
replaces exponentiation with elliptic
curve operations
Provides similar security to DiffieHellman and RSA with far smaller
numbers
123
x456
738
+ 6150
+49200
56088
[(4x103)+(5x102)+6(101)]123
(4x103)123+(5x102)123+6(101)123
x10
xxxxxxxxxx
(xxxxx)(xxxxx)
(xxxxx)2
((xx)(xx)x)2
((xx)2x)2
(((x2)2x)2
Server
y pub
e
k
c
li
b
u
p
d
sen
Epub(K)
C = Ek(M)
Attacker
key
send public
pub
Epub(K)
C = Ek(M)
Server
key
send public
pub
Epub(Dpriv(K))
C = Ek(M)
w = s-1%q
z = hash(message)
u1 = (zw) % q
u2 = (rw) % q
v = (( gu1yu2)%p)%q
if v r, signature is rejected
Can replace exponentiation with Elliptic
Curve operations to create ECDSA
Root CA
2nd Level
CA
Certifica
te
Certifica
te
2nd Level
CA
Certifica
te
Trusted Certificate
Authorities
Keep a mapping of
public keys of
trusted CAs
Look up public key
and validate
signature on each
certificate
Sender
Generate
Key Pair
Receiver
Must be
done
Store CA key
out of
band
Wrap in CSR
Distribute
Signed Cert
Validate CA
Signature
Sign with
private key
Verify
Signature
Client
Client Hello (sup
ported suites)
r suite)
e
h
ip
c
a
t
c
(sele
Server Hello
ificate
t
r
e
C
r
e
v
r
e
S
Done
Epub(Key Exchan
ge)
Change Cipher S
pe c
her Spec
Change Cip
Client
Client Hello (sup
ported suites)
hash
r suite)
e
h
ip
c
a
t
c
(sele
Server Hello
ificate
t
r
e
C
r
e
v
r
e
S
Done
Change Cipher S
pe c
Ek(Finished)
her Spec
Change Cip
Ek(Finished)
hash
Epub(Key Exchan
ge)
Client Hello
Server Hello
Bleichenbacher Attack
Try to deduce the private key by
returning an invalid key exchange
message
If the server responds with a
handshake completion error rather
than an invalid message error, one
bit of private key information is
leaked
Solution: ignore malformed key
exchange and complete the
Session Resumption
Key exchange is time-consuming
HTTP is based around a lot of short
transactions
Session resumption allows both sides
to remember keying material to be
reused
Mutual Authentication
The server can insist that the client
verify itself as well
Client and server may have a
different list of trusted certificate
authorities
Client doesnt have an identity to
validate
Session Renegotiation
Discard keying material, negotiate
new keys
Either side can initiate client
initiates by sending new client hello,
server initiates by sending explicit
renegotiation request (called a hello
request)
Renegotiation handshake is
encrypted using previously
negotiated key material
Prefix attacks
Client
Attacker
connect
handshake
complete
connect
prepend some
data
renegotiate
send data
Server
Extension 0xFF01
Simple solution reject renegotiation
attempts
RFC 5746 describes a client and
server extension that allows one
session to be securely tied back to
another
History of SSL/TLS
1995: Netscape releases a browser
with SSLv2
1996: SSLv2 is found to be flawed,
SSLv3 is specified
1999: IETF takes over SSL, renames
it TLS, blesses version 1.0
2006: TLS 1.1 is released, minor
revisions
2008: TLS 1.2 is released, major
revisions
More Information