37
1 Cryptography 101 Frank Hecker [email protected] m

1 Cryptography 101 Frank Hecker [email protected]

Embed Size (px)

Citation preview

Page 1: 1 Cryptography 101 Frank Hecker hecker@netscape.com

1

Cryptography 101

Frank [email protected]

Page 2: 1 Cryptography 101 Frank Hecker hecker@netscape.com

2

Cryptography 101

• Goal: provide a basic understanding of cryptography and related security technologies key to Netscape

• Topics:

- encryption algorithms, both symmetric and asymmetric (i.e., public key)

-hash functions, digital signatures, and X.509 certificates

-SSL

-S/MIME

Page 3: 1 Cryptography 101 Frank Hecker hecker@netscape.com

3

You should be able to answer...

• What are the real differences between the "40-bit" and "128-bit" versions?

• How are certificates used (or not used) in SSL connections?

• What are certificate authorities for, and what do they actually do?

• How does S/MIME differ from SSL?

• Where can SSL, S/MIME be best used?

• Other questions?

Page 4: 1 Cryptography 101 Frank Hecker hecker@netscape.com

4

Why security technology?

• Keep information secret- confidentiality

• Protect information from tampering- integrity

• Tell if person is who they say they are- authentication

• Allow or deny access to data, etc.- authorization (access control)

• Prove that person really did something-nonrepudiation

Page 5: 1 Cryptography 101 Frank Hecker hecker@netscape.com

5

• Encryption provides confidentiality

• Data encrypted using encryption algorithm together with encryption key

• Use algorithm with decryption key to recover original data

Encryption

encrypt

0110111010010001 key Ke

The quick brown fox 4f60ce544b43c13f1d

decrypt

1001001100111010 key Kd

4f60ce544b43c13f1d The quick brown fox

Page 6: 1 Cryptography 101 Frank Hecker hecker@netscape.com

6

Secure Sockets Layer (SSL)

Communicator(Navigator)

Enterprise Server

HTTP

user requests URL http://www.foo.com/def/xyz.html

SSL

user requests URL https://www.foo.com/def/xyz.html

GET def/xyz.html GET def/xyz.html48c00db62f7d

userid/password userid/password8f27a038ee3c

<html><head>... <html><head>...77d9421a0645...

Page 7: 1 Cryptography 101 Frank Hecker hecker@netscape.com

7

SSL-transmitted web page

Security indicator

Page 8: 1 Cryptography 101 Frank Hecker hecker@netscape.com

8

Symmetric cryptography

• In symmetric (or single key, or secret key) encryption algorithm

-decryption key is same as encryption key (or can be easily derived from it)

• Examples: RC4, DES, triple-DES

encrypt

0110111010010001 key K

The quick brown fox 4f60ce544b43c13f1ddecrypt

Page 9: 1 Cryptography 101 Frank Hecker hecker@netscape.com

9

Encryption strength

• For well-designed symmetric encryption algorithm, strength of algorithm is dependent on number of possible keys

-brute force attack: try all possible keys

• Adding one bit to key length makes algorithm twice as strong

-doubles number of possible keys

• For a given algorithm (e.g., RC4)

-56-bit key is 216 stronger than 40-bit key

-128-bit key is 288 stronger than 40-bit key

Page 10: 1 Cryptography 101 Frank Hecker hecker@netscape.com

10

How SSL works (take 1)

make TCP connection

“I’d like to talk SSL”

“OK, let’s talk SSL”

have session key Kshave session key Ks

transmit data over TCPencrypted using symmetric encryption algorithm

with key Ks

Problem: How do both sides agree on session key?

Page 11: 1 Cryptography 101 Frank Hecker hecker@netscape.com

11

• In asymmetric (or dual key, or public key) encryption algorithm

-decryption key is not same as encryption key (and cannot be easily derived from it)

• Examples: RSA, KEA

Public key cryptography

The quick brown fox encrypt

0110111010010001 key Kpublic

4f60ce544b43c13f1d

4f60ce544b43c13f1d decrypt

1001001100111010 key Kprivate

The quick brown foxencrypt

decrypt

Page 12: 1 Cryptography 101 Frank Hecker hecker@netscape.com

12

Strength of RSApublic key cryptography• Public key cryptography is based on

existence of certain hard problems

- figuring out private key from public key requires solving the hard problem

• For RSA, public/private keys are created using product of two large prime numbers

-hard problem is factoring the product (modulus) to recover original primes

• RSA strength depends on modulus length

-512-bit modulus (export) or 1024-bit (US)

Page 13: 1 Cryptography 101 Frank Hecker hecker@netscape.com

13

How SSL works (take 2)make TCP connection

“I’d like to talk SSL”

“OK, here’s my public key”

generate randomsession key Ks

“Here’s session key, encrypted using your public key”

decrypt session keyusing private key

transmit data encrypted using session key Ks

Problem: Must do (slow) public key operationsfor every SSL connection

Page 14: 1 Cryptography 101 Frank Hecker hecker@netscape.com

14

How SSL works (take 3)make TCP connection

“I’d like to talk SSL”

“OK, here’s my public key”

generate randomsecret value

“Here’s secret value, encrypted using your public key”

decrypt secret valueusing private key

use shared secretto make session keys

K1 and K2

use shared secretto make session keys

K1 and K2

transmit data encrypted using session keys

Page 15: 1 Cryptography 101 Frank Hecker hecker@netscape.com

15

What’s left to do?

• We seem to have basic problem of confidentiality solved, but…

• “Man in the middle” can corrupt encrypted data and mess up transaction

• MITM can breach confidentiality by substituting his public key for server’s

• Server doesn’t have strong authentication for client

• Time to talk about hash functions, digital signatures, and certificates!

Page 16: 1 Cryptography 101 Frank Hecker hecker@netscape.com

16

Hash functions

• Takes original data (any length) and computes fixed-length hash code

-different data means different hash code

- can’t recover data from hash code

• Examples: MD5 (128-bit hash code), SHA-1 (160-bit hash code)

hash functionThe quick brown fox... 85d013f4

hash functionThe quick red fox... ad917c7f

Page 17: 1 Cryptography 101 Frank Hecker hecker@netscape.com

17

Message authentication codes

• Essentially a secure checksum

-hash code computed from original data and shared secret value

- transmitted with data (like checksum)

• Used in SSL to protect integrity of data

hash function

The quick brown fox jumps over... 2a487c81fe215c

f730d1f4

The quick brown fox jumps over... f730d1f4

Page 18: 1 Cryptography 101 Frank Hecker hecker@netscape.com

18

• Signer generates digital signature

- compute hash code from original data

- encrypt hash code using signer’s private key

• Others verify digital signature

-decrypt hash code using signer’s public key

- compute second copy of hash code from copy of original data

- two copies of hash code should match

• No match means data was altered or signer is imposter or using wrong public key

Digital signatures

Page 19: 1 Cryptography 101 Frank Hecker hecker@netscape.com

19

Signing and verifying

The quick brown fox... hash function 85d013f4

85d013f4 encrypt

0110111010010001 key Kprivate

a3ff369b

The quick brown fox... a3ff369b

a3ff369b decrypt

0110111010010001 key Kpublic

85d013f4

The quick brown fox... hash function 85d013f4

OK

The quick red fox...

The quick red fox... ad917c7f

Bad!

Page 20: 1 Cryptography 101 Frank Hecker hecker@netscape.com

20

Certificates

• A certificate consists of (at least)

-public key

- identity associated with public key

-digital signature on certificate contents

• Certificate can be signed

-by owner of public key (self-signed)

-by trusted third party (certificate authority)

• Examples: X.509v3 certs, PGP certs

0111011011011001 John Doe d90e891a

Page 21: 1 Cryptography 101 Frank Hecker hecker@netscape.com

21

How SSL works (take 4)make TCP connection

“I’d like to talk SSL”

“OK, here’s my public key (in certificate)”

generate randomsecret value

“Here’s secret value, encrypted using your public key”

decrypt secret valueusing private key

use shared secretto make session keys

K1 and K2

use shared secretto make session keys

K1 and K2

transmit data encrypted using session keys

Page 22: 1 Cryptography 101 Frank Hecker hecker@netscape.com

22

Certificates and authentication

• Goal: Prove entity is who they claim to be

• First prove that entity knows private key corresponding to a known public key

- entity can decrypt something encrypted with public key or

- entity can sign something with private key, signature verifiable using public key

• Then map from public key to an identity (i.e., identity included in certificate)

• Note: certificate by itself proves nothing

Page 23: 1 Cryptography 101 Frank Hecker hecker@netscape.com

23

Basic SSL (final take)make TCP connection

“I’d like to talk SSL”

“OK, here’s my public key (in certificate)”

cert checked for validity,but not yet authenticated

“Here’s secret value, encrypted using your public key”

decrypt secret valueusing private key

“Done with handshake, switching to encrypted mode”(sent encrypted using session keys generated from secret)

if works, server now authenticated

transmit encrypted application data

Page 24: 1 Cryptography 101 Frank Hecker hecker@netscape.com

24

SSL with client authentication

make TCP connection

“I’d like to talk SSL”

“Here’s my certificate. What’s yours?”

“Here’s my certificate too”

cert checked for validity,but not yet authenticated

“Here’s secret value, encrypted using your public key”

“Here’s something signed using my private key”

if verified, client now authenticated

“Done with handshake, switching to encrypted mode”(sent encrypted using session keys generated from secret)

transmit data encrypted using session keys

Page 25: 1 Cryptography 101 Frank Hecker hecker@netscape.com

25

Certificates and trust

• Binds a public key to an identity (person’s name, server hostname, etc.)

-but how much you trust that binding is a separate issue

• If self-signed, you must decide level of trust with each new certificate seen

• If signed by CA, can trust new certificates based on your trust in CA and its policies

-verifying certificates requires public key of CA (i.e., certificate for CA itself)

Page 26: 1 Cryptography 101 Frank Hecker hecker@netscape.com

26

What SSL does/doesn’t do

• SSL provides

- confidentiality of transmitted data from client to server and server to client

- authentication of server to client

- authentication of client to server (optional)

- integrity of transmitted data

• SSL does not provide

- confidentiality, etc., for data in a store and forward environment (e.g., email)

Page 27: 1 Cryptography 101 Frank Hecker hecker@netscape.com

27

S/MIME

• Emerging standard for secure document transfer (e.g., in email, etc.)

-works with standard Internet message types (RFC 822, MIME)

• Goals of S/MIME

- confidentiality of document contents

- integrity of document contents

-nonrepudiation: can prove sender wrote document

• S/MIME uses encryption and/or signing

Page 28: 1 Cryptography 101 Frank Hecker hecker@netscape.com

28

S/MIME (signing only)

The quick brown fox...

SMTP mailserverSMTP

The quick brown fox... a3ff369b

mailserver

S/MIME mail client

The quick brown fox... a3ff369b

(signature OK)

The quick brown fox...

Page 29: 1 Cryptography 101 Frank Hecker hecker@netscape.com

29

How S/MIME signing works

• Start with MIME-compliant message body (text and attachments)

• Sign content using sender’s private key

• Include copy of sender’s certificate

• On receipt, validate signature using public key from sender’s certificate

-Note: This assumes that sender’s certificate is valid and trusted for signing

• Get signer’s authenticated identity from certificate

Page 30: 1 Cryptography 101 Frank Hecker hecker@netscape.com

30

S/MIME (encryption only)

SMTPSMTP mail

server

4f60ce544b43c13f1d

The quick brown fox...

0110111010010001 key Kpublic of recipientencrypt

mailserver

S/MIME mail client

4f60ce544b43c13f1d

The quick brown fox...

decryptkey Kprivate of recipient 1001001100111010

Page 31: 1 Cryptography 101 Frank Hecker hecker@netscape.com

31

How S/MIME encryption works

• Start with MIME-compliant message body (text and attachments)

• Pick random key and encrypt message using some symmetric algorithm

• Encrypt symmetric key using recipient’s public key (requires their certificate)

• On receipt, decrypt symmetric key using recipient’s private key

• Use symmetric key to decrypt message

Page 32: 1 Cryptography 101 Frank Hecker hecker@netscape.com

32

S/MIME signing/encryption

• Can combine signing and encryption in single S/MIME message

• Start with MIME-compliant body

• Sign content using sender’s private key

• Encrypt signed message using random symmetric key then encrypt symmetric key using recipient’s public key

• On receipt, reverse operations: use recipient’s private key in decrypting, then sender’s public key to verify signature

Page 33: 1 Cryptography 101 Frank Hecker hecker@netscape.com

33

S/MIME-secured message

security indicator

Page 34: 1 Cryptography 101 Frank Hecker hecker@netscape.com

34

Certificate creation, retrieval

• Certificate creation

- create key pair at client

- send public key plus identity to CA

-CA verifies identity, signs key+indentity

- client gets certificate and installs

• Certificate retrieval

-not needed for SSL (exchanged in-band)

-not needed for S/MIME signed messages

-needed for S/MIME encryption if sender doesn’t have certificate for recipient

Page 35: 1 Cryptography 101 Frank Hecker hecker@netscape.com

35

Summary of Crypto 101

• Goal is to implement security services: confidentiality, integrity, etc.

• Services implemented using cryptography

- encryption provides confidentiality

-hash function plus shared secret provides integrity (MAC)

-public key encryption plus hash function provides integrity, nonrepudiation (digital signature)

- authentication is obtained as a by-product of key exchange or of signing

Page 36: 1 Cryptography 101 Frank Hecker hecker@netscape.com

36

For more information

• SSL and cryptography tutorials- http://home.netscape.com/assist/security/ssl/howitworks.html

- Chapter 1, Netscape Certificate Server Administrator’s Guidehttp://twain/html/certificate/certserv/ux/ag/overview.htm

• SSL FAQ (from ssl-talk mailing list)- http://www.consensus.com/security/ssl-talk-faq.html

• S/MIME- http://www.rsa.com/rsa/S-MIME/index.html

• For serious crypto enthusiasts- news:mcom.crypto.interest

- Applied Cryptography (2nd. Ed.), Bruce Schneier

Page 37: 1 Cryptography 101 Frank Hecker hecker@netscape.com

37

Cryptography 101

The End