CS 340 Lecture 16 Authentication
CS 340 Lecture 16 Authentication
CS-340 Introduction to
Computer Networking
Lecture 16: Authentication
Steve Tarzia
2
Last Lecture: Encryption and Anonymity
• Network security goals are:
• Confidentiality, Reliability, Integrity, Authentication & Anonymity
• Routers and other participants on the network cannot be trusted.
• AES is a the standard symmetric-key encryption algorithm. Must
somehow establish a shared session key, used by both parties.
• Public Key cryptography (RSA, ECC) uses a pair of related keys.
• Public key is openly advertised and is used for encryption
• Private key is secret and is used for decryption.
• Onion-routing/mix networks create routing overlays on the Internet.
• Sender encrypts data many times. Relays decrypt one layer each.
• This enables anonymous web browsing and even anonymous services.
3
Authentication definition
• Verifying the identity of the person/host I’m communicating with.
5
(🔑A,🔓A) (🔑
G,🔓G)
(🔑M,🔓M)
Here’s my public
key🔓M
Let’s talk securely!
OK. Here’s my
public key 🔓G
4903c2…
“I feel pretty”
5933c0…
11290a…
“Do you?
Rewrite to
“So do I!”
0943e2…
• Like a hash function, it always produces the same result (for given data).
• It produces different results for different documents and keys.
• The document cannot be signed without a private key.
• The signature can be verified using only the corresponding public key.
• Closely related to public key encryption: can use the same RSA keys.
• Changing a signed document will make the former signature invalid.
9
Meg
Signing: The signer
likes
beets
Meg
likes uses the RSA private
beets
to encrypt the message
hash, creating a
signature.
🔑 Meg
likes Verification: Anyone
beets
Name of signer, looking at the
Public key 🔓
certificate can use the
public key to try to
Certificate 🔓 decrypt the signature.
If this leads to the true
message hash, then the
Meg signature must have
likes
been generated using
beets
If hashes are equal, the the true private key.
signature is valid
For confidentiality, we
10
encrypt with public
Meg keys, but here we use Signing:
The signer
likes
beets
private key. Why?
STOP
Meg
likes uses the
RSA private
and
THINK
beets
to encrypt
the message
hash,
creating a
signature.
🔑 Meg
likes
Verification: Anyone
beets
Name of signer, looking at
the
Public key 🔓
Server certificate
Intermediate certificate
Customer www.shopping.com Webbycorp
Root certificate Public key: e231… Certificate
authority
Public key:
904e… www.shopping.com
Crosby corporation
Root certificate
Public key:
BakerRoot 0c92…
corporation Signed by: Webbycorp Signed by:
AAA corp.
certificate
Public key: 0c92… Public key: 904e… Public
key: 0c92…
Actalis Inc.
Root certificate
Signature: 3902… Signature:
0032…
Public
AAAkey: 493a…
corporation
Public key: 0c92…
16
Getting a certificate
• Pay a fee to a certificate authority and send them a How to verify
requester's
certificate signing request (CSR): identity?
STOP
“Common name: northwestern.edu; Public key: 3a203c…” and
THINK
THINK
• Many HTTPS websites (and other SSL connections) would stop working.
STOP
• What would happened if you added a “bad” root certificate? and
THINK
• Your web browser would trust public keys that may be invalid, making you
vulnerable to a man-in-the-middle or other impersonation attack.
MITM Attack Revisited
G
24
A
(🔑G,🔓G)
(🔑A,🔓A)
(🔑M,🔓M)
gadgets.com
Here’s my public key 🔓A
Let’s talk securely!
OK. Here’s my
public key 🔓G
and my
signed certificate 📄G
OK. Here’s my public key 🔓M
and (an invalid) certificate 📄M
STOP
and Server
does not notice the attack
THINK
Client notices that certificate is fake
because it doesn’t expect a
📄M must have one of Why?
or missing. A real certificate these problems: signed
certificate from client.
authority would not have signed a • Domain name is not
Instead, passwords are usually
“gadgets.com” used
to authenticate clients.
certificate listing 🔓M as the public • Signature is invalid.
key for gadgets.com. • Issuer is not trusted.
Client drops the connection.
25
Sketchy root certificates allow MITM attacks
• Some corporate and campus networks require machines to install a
new root certificate to connect to networked services.
• By installing a single malicious root certificate, all of client’s encrypted
network traffic can be read and modified.
• This technique is also used by some legitimate debugging tools (eg.
Charles Proxy) to sniff HTTPS traffic.
• Normally, Wireshark cannot view HTTPS traffic because it’s encrypted at the
application layer.
• Charles Proxy is a MITM running on your machine that shows decrypted
HTTPS streams.
A
Successful MITM Attack
G
26
(🔑A,🔓A)
(🔑G,🔓G)
(🔑M,🔓M)
(🔑B,🔓B)
gadgets.com
Here’s my public key 🔓A
Root certificate
Let’s talk securely!
Big Brother
Here’s my
public key🔓M
Let’s talk
securely!
Pub key: 🔓B
OK.
Here’s my public key 🔓G
and my certificate 📄G
(signed
by a legitimate authority)
Name: 3kjD|Sj3;…
Hash collisions
940294a9bc9233eb5829848ecb9e2482
Public key: a329…
Name: \(we(CC1…
940294a9bc9233eb5829848ecb9e2482
Public key: 44a0…
…
Name: shop.com
45b798e10349ae8750cd45209809ec94
Public key: 201e…
31
Cryptographic Hash functions
If H(x) is a cryptographic hash function, it should be computationally infeasible
to:
• Map backwards from hash output to input: find x given H(x)
• Find two inputs x and y that map to the same hashed value: H(x) = H(y)
• We know that there is an infinite set of such (x,y) pairs, but the hash
function
is designed to make them nearly impossible to find.
• In particular, if we know x, we should not be able to find y in polynomial
time
such that H(x) = H(y)
• Like a good symmetric encryption algorithm, a cryptographic hash must have
good confusion and diffusion. It must behave very randomly.
• If input is called the message, the output is sometimes called the message
digest.
• SHA-1 and MD5 are examples of cryptographic hash functions.
32
Back to digital signatures
• If I sign a SHA-1 hash of a document and publish that signature, it
will be difficult for an attacker to construct a second document with
the same SHA-1 hash as the original document that I signed.
• Thus, it’s difficult for that signature to be used to falsely verify other
documents that I have not seen and signed.
• If I used a dumb hash function, like “the sum of all bytes,” forgery
would be easy:
• SUM(“fun and cats”) == SUM(“gun and bats”)
• The change f+1→g is cancelled by the change c-1→b
• Using this really bad hash function, the signature of “fun and cats”
would also be valid for “gun and bats”
33
Hash-based Message Authentication Code (HMAC)
• Public-key cryptography & digital signatures are computationally expensive.
• HMAC provides a more efficient way to authenticate public messages:
• HMAC steps:
• Assume sender and receiver have a shared secret: ⟵⟵ a new requirement :(
• MAC = hash(message +🗝)
• Send ⟨message, MAC⟩
• Anyone can read the message.
• Receiver with 🗝 can also compute the MAC to verify the received MAC.
• Again, we must use a strong cryptographic hash, like SHA-1
• We could have used 🗝 to encrypt with AES, but this is slower than a SHA-
1 hash (and maybe we want 3rd parties to see the message).
• HMAC is often used to authenticate API calls (eg., AWS REST API).
34
SSL/TLS Ethernet Packet
MAC addresses, CRC, etc.
• Transport Layer Security (TLS) is IP Packet
the Internet standard for encrypted IPEthernet
addresses,payload
TTL, etc.
communication, formerly called TCP Packet
Secure Sockets Layer (SSL). IP payload
Port #, sequence #, ack #, etc.
• A real-world implementation of TLS Record
public-key encryption and auth. TCP payload
Sequence #, length, MAC
• It’s built on top of TCP, sitting
🔒
below the application layer. HTTP Response
TLS payload
status code, content-type, etc.
• TLS payload is encrypted. Eg., this
could be an encrypted segment of <html><body><h1>My
an HTML document. great page</h1><p>…
• Defined in RFC 5246.
35
TLS handshake (after TCP handshake)
Sender and receiver must
agree on:
• encryption algorithms
eg., RSA+AES
• Shared keys. TLS
actually uses four
different keys
(sender, receiver)×(encryption, MAC)
🔑=private key37
🔓=public key
replay attack
Generate key pair
Generate key pair
(🔑A,🔓A) (🔑
G,🔓G)
Let’s talk securely!
Here’s my public key 🔓A
🔓G
“I would like to
buy 10 widgets.” RSAe 92b102…
🔑G
92b102…
“I would like to
92b102… RSAd
buy 10 widgets.”
🔓A
“OK, it’s
RSAe 5773ae…
5773ae…
shipped.”
🔑A
🔓=public key
“I would like to
92b102… RSAd
buy 10 widgets.”
🔓A
“OK, it’s
RSAe 5773ae…
5773ae…
shipped.”
Hmm, I don’t know what
happened, but hopefully it
was something bad!
The attacker made the
another order!
Let’s do it again! Let’s talk securely!
Here’s my public key 🔓A
How to prevent 39
Connection replay attack STOP
and
this?
THINK
🔑=private key40
🔓=public key
7344. I would
92b102… RSAd
like to buy 10
widgets.”
The server
rejects this connection because
the returned
Nonce is wrong (because it
came from
replaying a prior connection).
41
Fundamental network security lessons
• Secure communication involves many considerations.
• Encryption primitives are not enough, they must be used carefully.
• TLS must be carefully designed to avoid all kinds of clever attacks, like
replay attacks (and many others!)
• Authentication is still not a fully-solved problem,
(Public Key Infrastructure has many drawbacks).
• Learn more in CS-396 Cryptography
Lessons for the software/network engineer:
• Don’t try to build your own encryption scheme from scratch.
• Just use the latest version of TLS.
• Know the meaning of PKI/certificates, and keep private keys safe!
42
Recap
• Digital signatures are special bit sequences attached to documents
that can only be computed by the holder of a private key.
• Signatures are used to establish transitive trust and verify new public keys,
thus preventing Man In The Middle and other attacks.
• Certificate authorities verify public keys with digitally signed certificates.
• MITM with root authority’s private key can forge arbitrary certificates.
• Cryptographic hash functions are irreversible and unpredictable.
• Used to create a small summary of a document than can be signed with RSA.
• Also used in Message Authenticate Codes (HMAC) to verify that sender
has a shared secret: MAC = hash(message +🗝)
• Transport Layer Security (TLS) encrypts a TCP stream.
• Details are complex, to allow many different systems to interoperate and to
mitigate a variety of attacks: Eg., packet replay, connection replay.