Скачать презентацию Lecture 4 Hash Functions Message Authentication and Key Скачать презентацию Lecture 4 Hash Functions Message Authentication and Key

8644614fdad4c7146e98503e08a04c7a.ppt

  • Количество слайдов: 62

Lecture 4: Hash Functions, Message Authentication and Key Distribution CS 392/6813: Computer Security Fall Lecture 4: Hash Functions, Message Authentication and Key Distribution CS 392/6813: Computer Security Fall 2008 Nitesh Saxena 1/23/2006 *Adopted from Previous Lectures by Nasir Memon Lecture 4: Hash Functions and Key Distribution

Course Admin n HW#3 to be posted very soon n Sorry for the delay Course Admin n HW#3 to be posted very soon n Sorry for the delay Solutions will be posted soon Regarding programming portions of the homework n n Submit the whole modified code that you used to measure timings Comment the portions in the code where you modified the code n n If you did not submit the code for HW#2, do so now n n Include a small “readme” for us to understand this Upload it on My. Poly Break during the lecture? 1/23/2006 Lecture 4: Hash Functions and Key Distribution 2

Outline of Today’s lecture n Hash Functions n n Properties Known Hash Function n Outline of Today’s lecture n Hash Functions n n Properties Known Hash Function n n SHA-1 Message Authentication using hash fns: HMAC “Private Key” Distribution “Public Key” Distribution: PKI n n 1/23/2006 Certification Revocation Lecture 4: Hash Functions and Key Distribution 3

Cryptographic Hash Functions n Requirements of cryptographic hash functions: n n Can be applied Cryptographic Hash Functions n Requirements of cryptographic hash functions: n n Can be applied to data of any length. Output is fixed length. Relatively easy to compute h(x), given x. Infeasible to get x, given h(x). -wayness property n n 1/23/2006 One Given x, infeasible to find y such that h(x) = h(y). Weak collision property. Infeasible to find any pair x and y such that h(x) = h(y). Strong collision property. Lecture 4: Hash Functions and Key Distribution 4

Hash Output Length n n n How long should be the output (n bits) Hash Output Length n n n How long should be the output (n bits) of a cryptographic hash function? To find collision - randomly select messages and check if hash matches any that we know. Throwing k balls in N = 2 n bins. How large should k be, before probability of landing two balls in the same becomes greater than ½? Birthday paradox - a collision can be found in roughly sqrt(N) = 2(n/2) trials for an n bit hash n In a group of 23 )(~ sqrt(365)) people, at least two of them will have the same birthday (with a probability > ½) Hence n should be at least 160 1/23/2006 Lecture 4: Hash Functions and Key Distribution 5

Birthday Paradox n Probability that hash values of k random messages are distinct is Birthday Paradox n Probability that hash values of k random messages are distinct is (that is, no collisions) is: 1/23/2006 Lecture 4: Hash Functions and Key Distribution 6

Generic Hash Function 1/23/2006 Lecture 4: Hash Functions and Key Distribution 7 Generic Hash Function 1/23/2006 Lecture 4: Hash Functions and Key Distribution 7

1/23/2006 Lecture 4: Hash Functions and Key Distribution 8 1/23/2006 Lecture 4: Hash Functions and Key Distribution 8

1/23/2006 Lecture 4: Hash Functions and Key Distribution 9 1/23/2006 Lecture 4: Hash Functions and Key Distribution 9

1/23/2006 Lecture 4: Hash Functions and Key Distribution 10 1/23/2006 Lecture 4: Hash Functions and Key Distribution 10

1/23/2006 Lecture 4: Hash Functions and Key Distribution 11 1/23/2006 Lecture 4: Hash Functions and Key Distribution 11

1/23/2006 Lecture 4: Hash Functions and Key Distribution 12 1/23/2006 Lecture 4: Hash Functions and Key Distribution 12

1/23/2006 Lecture 4: Hash Functions and Key Distribution 13 1/23/2006 Lecture 4: Hash Functions and Key Distribution 13

1/23/2006 Lecture 4: Hash Functions and Key Distribution 14 1/23/2006 Lecture 4: Hash Functions and Key Distribution 14

1/23/2006 Lecture 4: Hash Functions and Key Distribution 15 1/23/2006 Lecture 4: Hash Functions and Key Distribution 15

1/23/2006 Lecture 4: Hash Functions and Key Distribution 16 1/23/2006 Lecture 4: Hash Functions and Key Distribution 16

Other Hash Functions n Many other hash functions n MD 5 – Message Digest Other Hash Functions n Many other hash functions n MD 5 – Message Digest algorithm 5 n n n 1/23/2006 Very similar to SHA – study on your own RIPEM MD 4 MD 6 Etc. Lecture 4: Hash Functions and Key Distribution 17

Current Security of MD 5 and SHA-1 n n n MD 5 n n Current Security of MD 5 and SHA-1 n n n MD 5 n n B’day attack requires 280 calls Faster attacks 269 calls http: //www. infosec. sdu. edu. cn/paper/sha 1 -crypto-auth-new 2 -yao. pdf Output is 128 -bits, so B’day attack requires 264 calls only Faster attacks to find a collision: http: //eprint. iacr. org/2004/199. pdf Better use stronger versions, such as SHA-256 Although, these attacks are still not practical – they only find two random messages that collide 1/23/2006 Lecture 4: Hash Functions and Key Distribution 18

Message Authentication Codes n n n Integrity as well as authentication (m, MAC) We Message Authentication Codes n n n Integrity as well as authentication (m, MAC) We want MAC to be as small and as secure as possible Security based on the length of the key and also how the MAC is computed A MAC can be constructed based on any “good” symmetric cipher – though this can be computationally expensive. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 19

Recall MAC Using DES in CBC mode 1/23/2006 Lecture 4: Hash Functions and Key Recall MAC Using DES in CBC mode 1/23/2006 Lecture 4: Hash Functions and Key Distribution 20

Security notion for MAC n n Very similar to the security notion for a Security notion for MAC n n Very similar to the security notion for a digital signature scheme Existential forgery under (adaptively) chosen message attack 1/23/2006 Lecture 4: Hash Functions and Key Distribution 21

HMAC: MAC using Hash Functions n n n Developed as part of IPSEC - HMAC: MAC using Hash Functions n n n Developed as part of IPSEC - RFC 2104. Also used in SSL etc. Key based hash but almost as fast as non-key based hash functions. Avoids export restrictions unlike DES based MAC. Provable security Can be used with different hash functions like SHA-1, MD 5, etc. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 22

HMAC Block size b bits. n K+ - K padded with bits on the HMAC Block size b bits. n K+ - K padded with bits on the left to make b bits. n ipad – 0110110 (ox 36) repeated b/8 times. n opad – 1011100 (0 x 5 c) repeated b/8 times. n Essentially HMACK = H[(K+ xor opad) || H[(K+ xor ipad) || M]] n 1/23/2006 Lecture 4: Hash Functions and Key Distribution 23

Security of HMAC n Proven secure under assumptions stronger than that of being able Security of HMAC n Proven secure under assumptions stronger than that of being able to find collisions of the underlying hash function Finding collisions even when the IV is secret and random n Computing the hash value even when the IV is secret and random n See HMAC paper, if interested in details http: //www-cse. ucsd. edu/~mihir/papers/hmac. html n 1/23/2006 Lecture 4: Hash Functions and Key Distribution 24

HMAC – An Efficient Implementation 1/23/2006 Lecture 4: Hash Functions and Key Distribution 25 HMAC – An Efficient Implementation 1/23/2006 Lecture 4: Hash Functions and Key Distribution 25

Key Distribution n Cryptographic primitives seen so far assume n n n In private Key Distribution n Cryptographic primitives seen so far assume n n n In private key setting: Alice and Bob share a secret key which is unknown to Oscar. In public key setting: Alice has a “trusted” (or authenticated) copy of Bob’s public key. But how does this happen in the first place? Alice and Bob meet and exchange key(s) Not always practical or possible. We need key distribution, first and foremost! 1/23/2006 Lecture 4: Hash Functions and Key Distribution 26

“Private Key” Distribution: attempt 1 n Protocol assumes that Alice and Bob share a “Private Key” Distribution: attempt 1 n Protocol assumes that Alice and Bob share a session key KA and KB with a Key Distribution Center (KDC). n n n Alice calls Trent (Trusted KDC) and requests a session key to communicate with Bob. Trent generates random session key K and sends E KA(K) to Alice and E KB(K) to Bob. Alice and Bob decrypt with KA and KB respectively to get K. This is a key distribution protocol. Susceptible to replay attack! 1/23/2006 Lecture 4: Hash Functions and Key Distribution 27

Session Key Exchange with KDC – Needham-Schroeder Protocol n A -> KDC IDA || Session Key Exchange with KDC – Needham-Schroeder Protocol n A -> KDC IDA || IDB || N 1 (Hello, I am Alice, I want to talk to Bob, I need a session Key and here is a random nonce identifying this request) n KDC -> A E K A( K || IDB || N 1 || E KB(K || IDA)) Encrypted(Here is a key, for you to talk to Bob as per your request N 1 and also an envelope to Bob containing the same key) n A -> B E KB(K || IDA) (I would like to talk using key in envelope sent by KDC) n B -> A E K(N 2) (OK Alice, But can you prove to me that you are indeed Alice and know the key? ) n n A -> B E K(f(N 2)) (Sure I can!) Dennig-Sacco (replay) attack on the protocol 1/23/2006 Lecture 4: Hash Functions and Key Distribution 28

Session Key Exchange with KDC – Needham-Schroeder Protocol (corrected version with mutual authentication) n Session Key Exchange with KDC – Needham-Schroeder Protocol (corrected version with mutual authentication) n A -> KDC: IDA || IDB || N 1 (Hello, I am Alice, I want to talk to Bob, I need a session Key and here is a random nonce identifying this request) n KDC -> A: E K A( K || IDB || N 1 || E KB(TS 1, K || IDA)) Encrypted(Here is a key, for you to talk to Bob as per your request N 1 and also an envelope to Bob containing the same key) n A -> B: E K(TS 2), E KB(TS 1, K || IDA) (I would like to talk using key in envelope sent by KDC; here is an authenticator) n B -> A: E K(TS 2+1) (OK Alice, here is a proof that I am really Bob) 1/23/2006 Lecture 4: Hash Functions and Key Distribution 29

Kerberos - Goals n Security n n n Reliability Transparency n n Next slide. Kerberos - Goals n Security n n n Reliability Transparency n n Next slide. Minimum modification to existing network applications. Scalability n 1/23/2006 Modular distributed architecture. Lecture 4: Hash Functions and Key Distribution 30

Kerberos – Security Goals n n n No cleartext passwords over network. No cleartext Kerberos – Security Goals n n n No cleartext passwords over network. No cleartext passwords stored on servers. Minimum exposure of client and server keys. Compromises should only affect current session. Require password only at login. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 31

Kerberos - Assumptions n n Global clock. There is a way to distribute authorization Kerberos - Assumptions n n Global clock. There is a way to distribute authorization data. n 1/23/2006 Kerberos provides authentication and not authorization. Lecture 4: Hash Functions and Key Distribution 32

Kerberos Key Distribution (1) Step 1 Joe to KDC Step 2 KDC Joe I Kerberos Key Distribution (1) Step 1 Joe to KDC Step 2 KDC Joe I would like to Talk to the File Server KDC Session key for service Session key for User KDC 1/23/2006 Lecture 4: Hash Functions and Key Distribution 33

Kerberos Key Distribution (2) Box 1 Step 3 KDC Session Key for Joe Dear Kerberos Key Distribution (2) Box 1 Step 3 KDC Session Key for Joe Dear Joe, This key for File server Step 4 KDC to Joe 1/23/2006 Box 2 Joe Session Key for File server Locked With Joe’s key Box 1 Dear File server, This key for Use with Joe Box 2 Lecture 4: Hash Functions and Key Distribution Locked With File Server’s key KDC 34

Kerberos Distribution (3) Step 5 Joe Box 2 Session Key for File server Opened Kerberos Distribution (3) Step 5 Joe Box 2 Session Key for File server Opened Box 1 Dear Joe, This key for File server Dear File server, This key for Use with Joe Box 3 Box 2 Session Key for File server Step 6 Joe Dear File server, The time is 3: 40 pm 1/23/2006 Locked With File Server’s key Locked With Session key Dear File server, This key for Use with Joe Lecture 4: Hash Functions and Key Distribution Locked With File Server’s key 35

Kerberos Distribution (4) Step 7 Joe to File server Box 2 Joe Unlocked Box Kerberos Distribution (4) Step 7 Joe to File server Box 2 Joe Unlocked Box 3 Step 8 File server 1/23/2006 Dear File server, The time is 3: 40 pm Box 3 File Server Unlocked Box 2 Dear File server, This key for Use with Joe Lecture 4: Hash Functions and Key Distribution 36

Kerberos Key Distribution (5) n n For mutual authentication, file server can create box Kerberos Key Distribution (5) n n For mutual authentication, file server can create box 4 with time stamp and encrypt with session key and send to Joe. Box 2 is called ticket. KDC issues ticket only after authenticating password To avoid entering passwords every time access needed, KDC split into two – authenticating server and ticket granting server. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 37

Kerberos– One Slide Overview 1/23/2006 Lecture 4: Hash Functions and Key Distribution 38 Kerberos– One Slide Overview 1/23/2006 Lecture 4: Hash Functions and Key Distribution 38

Version 4 summary 1/23/2006 Lecture 4: Hash Functions and Key Distribution 39 Version 4 summary 1/23/2006 Lecture 4: Hash Functions and Key Distribution 39

Kerberos - Limitations n n Every network service must be individually modified for use Kerberos - Limitations n n Every network service must be individually modified for use with Kerberos. Requires a global clock Requires secure Kerberos server. Requires continuously available or online server. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 40

Public Key Distribution n Public announcements (such as email) n n Public directory n Public Key Distribution n Public announcements (such as email) n n Public directory n n Can be forged Can be tampered with Public-key certification authority (CA) (such as verisign) n n 1/23/2006 This is what we use in practice CA issues certificates to the users Lecture 4: Hash Functions and Key Distribution 41

Naming and Certificates n Certification authority’s vouch for the identity of an entity - Naming and Certificates n Certification authority’s vouch for the identity of an entity - Distinguished Names (DN). /O=Polytechnic University/OU=CS/CN=John Doe n n Although CN may be same, DN is different. Policies of certification n Authentication policy n Issuance policy 1/23/2006 What level of authentication is required to identify the principal. Given the identity of principal will the CA issue a certificate? Lecture 4: Hash Functions and Key Distribution 42

Types of Certificates n n CA’s vouch at some level the identity of the Types of Certificates n n CA’s vouch at some level the identity of the principal. Example – Verisign: n n n 1/23/2006 Class 1 – Email address Class 2 – Name and address verified through database. Class 3 - Background check. Lecture 4: Hash Functions and Key Distribution 43

Public Key Certificate n n Public Key Certificate – Signed messages specifying a name Public Key Certificate n n Public Key Certificate – Signed messages specifying a name (identity) and the corresponding public key. Signed by whom – Certification Authority (CA), an organization that issues public key certificates. We assume that everyone is in possession of a trusted copy of the CA’s public key. CA could be n Internal CA. n Outsourced CA. n Trusted Third-Party CA. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 44

Public Key Certificate Note: Mechanism of certification and content of certificate, will vary but Public Key Certificate Note: Mechanism of certification and content of certificate, will vary but at the minimum we have email verification and contains ID and Public Key. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 45

Certificate Verification/Validation 1/23/2006 Lecture 4: Hash Functions and Key Distribution 46 Certificate Verification/Validation 1/23/2006 Lecture 4: Hash Functions and Key Distribution 46

Certificate Revocation n CA also needs some mechanism to revoke certificates n n n Certificate Revocation n CA also needs some mechanism to revoke certificates n n n Private key compromised. CA mistake in issuing certificate. Particular service the certificate grants access to may no longer exist. CA compromised. Expiration time solves the problems only partially. Certification Revocation Lists (CRL) – a list of every certificate that has been revoked but not expired. n CRL’s quickly grow large! CRL’s distributed periodically. n What about time period between revocation and distribution of CRL? n Other mechanisms n n 1/23/2006 OCSP (online certificate status protocol) Lecture 4: Hash Functions and Key Distribution 47

X. 509 n n n Clearly, there is a need for standardization – X. X. 509 n n n Clearly, there is a need for standardization – X. 509. Originally 1988, revised 93 and 95. X. 509 is part of X. 500 series that defines a directory service. Defines a framework for authentication services by X. 500 directory to its users. Used in S/MIME, IPSEC, SSL etc. Does not dictate use of specific algorithm (recommends RSA). 1/23/2006 Lecture 4: Hash Functions and Key Distribution 48

X. 509 Certificate 1/23/2006 Lecture 4: Hash Functions and Key Distribution 49 X. 509 Certificate 1/23/2006 Lecture 4: Hash Functions and Key Distribution 49

Advantages of CA Over KDC n n n CA does not need to be Advantages of CA Over KDC n n n CA does not need to be on-line! CA can be very simple computing device. If CA crashes, life goes on (except CRL). Certificates can be stored in an insecure manner!! Compromised CA cannot decrypt messages. Scales well. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 50

Internet Certificate Hierarchy Internet Policy Registration Authority Policy Certification Authorities Certification Authority Individuals/roles/orgs. 1/23/2006 Internet Certificate Hierarchy Internet Policy Registration Authority Policy Certification Authorities Certification Authority Individuals/roles/orgs. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 51

Types of certificates n Organizational Certificates Principal’s affiliation with an organization n Residential certificates Types of certificates n Organizational Certificates Principal’s affiliation with an organization n Residential certificates Principal’s affiliation with an address n Persona Certificates Principal’s Identity n Principal need not be a person. It could be a role. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 52

Public-key Infrastructure (PKI) n n Combination of digital certificates, public-key cryptography, and certificate authorities. Public-key Infrastructure (PKI) n n Combination of digital certificates, public-key cryptography, and certificate authorities. A typical enterprise's PKI encompasses n n n issuance of digital certificates to users and servers end-user enrollment software integration with corporate certificate directories tools for managing, renewing, and revoking certificates; and related services and support Verisign, Thawte and Entrust – PKI providers. Your own PKI using Netscape/Microsoft certificate servers 1/23/2006 Lecture 4: Hash Functions and Key Distribution 53

Problems with PKI – Private Key n Where and how is private key stored? Problems with PKI – Private Key n Where and how is private key stored? n n Host – encrypted with pass phrase Host – encrypted by OS or application Smart Card Assumes secure host or tamper proof smartcard. 1/23/2006 Lecture 4: Hash Functions and Key Distribution 54

Problems with PKI - Conflicts n n n X. 509, PGP and IPRA remain Problems with PKI - Conflicts n n n X. 509, PGP and IPRA remain silent on conflicts. They assume CA’s and PCA’s will ensure that no conflicts arise. But in practice conflicts may exist – n 1/23/2006 John A. Smith and John B. Smith may live at the same address. Lecture 4: Hash Functions and Key Distribution 55

Trustworthiness of Issuer n n A certificate is the binding of an external identity Trustworthiness of Issuer n n A certificate is the binding of an external identity to a cryptographic key and a distinguished name. If the issuer can be fooled, all who rely upon the certificate can be fooled How do you trust CA from country XYZ (your favorite prejudice). 1/23/2006 Lecture 4: Hash Functions and Key Distribution 56

Further Reading n n MIT Kerberos site: http: //web. mit. edu/kerberos/www/ Kerberos RFC: RFC-1510 Further Reading n n MIT Kerberos site: http: //web. mit. edu/kerberos/www/ Kerberos RFC: RFC-1510 X. 509 page http: //www. ietf. org/html. charters/pkixcharter. html Ten Risks of PKI http: //www. schneier. com/paper-pki. html 1/23/2006 Lecture 4: Hash Functions and Key Distribution 57

Some questions n Schnorr signatures (SK=x in Zq, PK=y=gx mod p) n Signing n Some questions n Schnorr signatures (SK=x in Zq, PK=y=gx mod p) n Signing n n n Choose random k in Zq Compute r = gk mod p, Set c = H(m, r) S = k + cx mod q Output (m, r, s) Verification? c = H(m, r) g^s = r. (y^c) mod p What is the length of n n n 1/23/2006 an RSA certificate? a DSS certificate? a Schnorr certificate? Lecture 4: Hash Functions and Key Distribution 58

Some questions n n Can a KDC learn communication between Alice and Bob, to Some questions n n Can a KDC learn communication between Alice and Bob, to whom it issued keys? Can a CA learn communication between Alice and Bob, to whom it issued certificates? What happens if the CA is online all the time? Alice uses her private key, public key pairs and a CA issued certificate. She learnt that Eve might have leaned her key. What should she do? 1/23/2006 Lecture 4: Hash Functions and Key Distribution 59

Some questions n n SHA-1 collisions can be found in 269 operations. Does this Some questions n n SHA-1 collisions can be found in 269 operations. Does this mean that HMAC (using SHA-1) can be forged in 269 operations too? DES CBC MAC is ------- than HMAC, computationally (for same key sizes)? 1/23/2006 Lecture 4: Hash Functions and Key Distribution 60

n n Sometimes when you access an https website, you get a security warning. n n Sometimes when you access an https website, you get a security warning. What is that warning for? Sometimes when you connect to an SSH server, you get a security warning. What is that warning for? What is a self-signed certificate? Computation time to MD-5 a 100 bytes long file is the same as for a 100 MB file. Right? 1/23/2006 Lecture 4: Hash Functions and Key Distribution 61

n n n Does DES use any modular arithmetic? Can I use a DL-based n n n Does DES use any modular arithmetic? Can I use a DL-based key pairs, when the CA issuing me a certificate uses RSA keys? Alice has only a DL-based key pairs, while Bob has only RSA keys. Can they ever be able to communicate securely? 1/23/2006 Lecture 4: Hash Functions and Key Distribution 62