Download presentation
Presentation is loading. Please wait.
Published byAgnes Potter Modified over 8 years ago
1
Network Security Essentials Chapter 3 Fourth Edition by William Stallings (Based on Lecture slides by Lawrie Brown)
2
Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively as the true name and the good name, or the great name and the little name; and while the good or little name was made public, the true or great name appears to have been carefully concealed. —The Golden Bough, Sir James George Frazer
3
Outline Message authentication (Ref. Chap.12) Secure hash functions (Ref. Chap.11) Message authentication codes (Ref. Chap.12) Public-key cryptography (Ref. Chap.9) Digital signatures (Ref. Chap.13)
4
Message Authentication To protect against passive attacks Encryption Encryption To protect against active attacks Message authentication Message authentication
5
Message Authentication Message authentication is concerned with: Protecting the integrity of a message Protecting the integrity of a message Validating identity of originator Validating identity of originator Non-repudiation of origin (dispute resolution) Non-repudiation of origin (dispute resolution) The three alternative functions used: Message encryption Message encryption Hash function Hash function Message authentication code (MAC) Message authentication code (MAC)
6
Authentication using conventional encryption Not suitable, e.g. block reordering in ECB mode Not suitable, e.g. block reordering in ECB mode Authentication without encryption Broadcast Broadcast Heavy loads Heavy loads Authentication of a program in plaintext Authentication of a program in plaintext
7
Message Authentication Code
8
MAC M =F(K AB, M) Message not altered The alleged sender confirmed The proper sequence of messages assured Similar to encryption NIST recommends the use of DES One difference: authentication algorithm need not be reversible, less vulnerable
9
Hash Functions Condenses arbitrary message to fixed size h = H(M) No secret key needed No secret key needed Usually assume hash function is public Usually assume hash function is public Hash used to detect changes to message Hash used to detect changes to message We want a cryptographic hash function Computationally infeasible to find data mapping to specific hash (one-way property) Computationally infeasible to find data mapping to specific hash (one-way property) Computationally infeasible to find two data to the same hash (collision-free property) Computationally infeasible to find two data to the same hash (collision-free property)
11
Message authentication using a one-way hash function Using conventional encryption (Fig.3.2a) Using public-key encryption (Fig.3.2b) Using secret value (Fig.3.2c) MD M =H(S AB ||M), then send [M||MD M ] MD M =H(S AB ||M), then send [M||MD M ] E.g. HMAC adopted for IP security E.g. HMAC adopted for IP security Reasons for avoiding encryption Encryption software quite slow Encryption software quite slow Encryption hardware costs nonnegligible Encryption hardware costs nonnegligible Encryption hardware optimized for large data sizes Encryption hardware optimized for large data sizes Encryption algorithm protected by a patent Encryption algorithm protected by a patent
12
Two Simple Insecure Hash Functions Consider two simple insecure hash functions Bit-by-bit exclusive-OR (XOR) of every block C i = b i1 xor b i2 xor... xor b im C i = b i1 xor b i2 xor... xor b im A longitudinal redundancy check A longitudinal redundancy check Reasonably effective as data integrity check Reasonably effective as data integrity check One-bit circular shift on hash value For each successive n-bit block For each successive n-bit block Rotate current hash value to left by 1bit and XOR blockRotate current hash value to left by 1bit and XOR block Good for data integrity but useless for security Good for data integrity but useless for security
13
Simple Hash Function Using Bitwise XOR
14
Hash Function Requirements
15
Attacks on Hash Functions Have brute-force attacks and cryptanalysis A preimage or second preimage attack Find y s.t. H(y) equals a given hash value Find y s.t. H(y) equals a given hash value Collision resistance Find two messages x & y with the same hash H(x) = H(y) Find two messages x & y with the same hash H(x) = H(y) Protection against birthday attack Protection against birthday attack Hence value 2 m/2 determines strength of hash code against brute-force attacks 128-bits inadequate, 160-bits suspect 128-bits inadequate, 160-bits suspect
16
Secure Hash Algorithm SHA originally designed by NIST & NSA in 1993 Was revised in 1995 as SHA-1 US standard for use with DSA signature scheme Standard is FIPS 180-1 1995, also Internet RFC3174 Standard is FIPS 180-1 1995, also Internet RFC3174 nb. the algorithm is SHA, the standard is SHS nb. the algorithm is SHA, the standard is SHS Based on design of MD4 with key differences Produces 160-bit hash values Recent 2005 results on security of SHA-1 have raised concerns on its use in future applications
17
Revised Secure Hash Standard NIST issued revision FIPS 180-2 in 2002 Adds 3 additional versions of SHA: SHA-256, SHA-384, SHA-512 Adds 3 additional versions of SHA: SHA-256, SHA-384, SHA-512 Designed for compatibility with increased security provided by the AES cipher Designed for compatibility with increased security provided by the AES cipher Structure & detail is similar to SHA-1 Structure & detail is similar to SHA-1 Hence analysis should be similar, but security levels are rather higher Hence analysis should be similar, but security levels are rather higher NIST FIPS 180-3 (in 2008) adds SHA-224 RFC 4634 details SHA-224, -256, -384, -512
18
SHA Versions
19
SHA-512 Overview
20
SHA-512 Compression Function Heart of the algorithm Processing message in 1024-bit blocks Consists of 80 rounds Updating a 512-bit buffer Updating a 512-bit buffer Using a 64-bit value W t derived from the current message block Using a 64-bit value W t derived from the current message block And a round constant K t based on cube roots of the first 80 prime numbers And a round constant K t based on cube roots of the first 80 prime numbers
21
Keyed Hash Functions as MACs Want a MAC based on a hash function Because hash functions are generally faster Because hash functions are generally faster Crypto hash function code is widely available Crypto hash function code is widely available Hash includes a key along with message Original proposal: KeyedHash = Hash(Key|Message) Some weaknesses were found with this Some weaknesses were found with this Eventually led to development of HMAC
22
HMAC Design Objectives Use, without modifications, hash functions Allow for easy replaceability of embedded hash function Preserve original performance of hash function without significant degradation Use and handle keys in a simple way Have well understood cryptographic analysis of authentication mechanism strength
23
HMAC Specified as Internet standard RFC2104 Uses hash function on the message: HMAC K (M)= Hash[(K + XOR opad) || Hash[(K + XOR ipad) || M)] ] where K + is the key padded out to size where K + is the key padded out to size opad, ipad are specified padding constants opad, ipad are specified padding constants Overhead is just 3 more hash calculations than the message needs alone Any hash function can be used E.g. MD5, SHA-1, RIPEMD-160, Whirlpool E.g. MD5, SHA-1, RIPEMD-160, Whirlpool
24
HMAC Overview
25
HMAC Security Proved security of HMAC relates to that of the underlying hash algorithm Attacking HMAC requires either: Brute force attack on key used Brute force attack on key used Birthday attack (but since keyed would need to observe a very large number of messages) Birthday attack (but since keyed would need to observe a very large number of messages) Choose hash function used based on speed verses security constraints MD5 vs. SHA-1 MD5 vs. SHA-1
26
MACs based on Block Ciphers CMAC CCM
27
CMAC Previously saw the DAA (CBC-MAC) Widely used in govt & industry But has message size limitation Can overcome using 2 keys & padding Thus forming the Cipher-based Message Authentication Code (CMAC) Adopted by NIST SP800-38B
28
CMAC Overview
29
Authenticated Encryption Simultaneously protect confidentiality and authenticity of communications Often required but usually separate Often required but usually separate Approaches Hash-then-encrypt: E(K, (M || H(M)) Hash-then-encrypt: E(K, (M || H(M)) MAC-then-encrypt: E(K2, (M || MAC(K1, M)) MAC-then-encrypt: E(K2, (M || MAC(K1, M)) Encrypt-then-MAC: C=E(K2, M), T=MAC(K1, C) Encrypt-then-MAC: C=E(K2, M), T=MAC(K1, C) Encrypt-and-MAC: C=E(K2, M), T=MAC(K1, M) Encrypt-and-MAC: C=E(K2, M), T=MAC(K1, M) Decryption /verification straightforward But security vulnerabilities with all these E.g. HtE used in WEP (Wired Equivalent Privacy)
30
Counter with Cipher Block Chaining-Message Authentication Code (CCM) NIST standard SP 800-38C for WiFi Variation of encrypt-and-MAC approach Algorithmic ingredients AES encryption algorithm AES encryption algorithm CTR mode of operation CTR mode of operation CMAC authentication algorithm CMAC authentication algorithm Single key used for both encryption & MAC
31
CCM Operation
32
Private-Key Cryptography Traditional private/secret/single key cryptography uses one key Shared by both sender and receiver If this key is disclosed communications are compromised Also is symmetric, parties are equal Hence does not protect sender from receiver forging a message & claiming is sent by sender
33
Public-Key Cryptography Probably the most significant advance in the 3000 year history of cryptography Uses two keys – a public & a private key Asymmetric since parties are not equal Uses clever application of number theoretic concepts to function Complements rather than replaces private key cryptography
34
Why Public-Key Cryptography? Developed to address two key issues: Key distribution – how to have secure communications in general without having to trust a KDC with your key Key distribution – how to have secure communications in general without having to trust a KDC with your key Digital signatures – how to verify a message comes intact from the claimed sender Digital signatures – how to verify a message comes intact from the claimed sender Public invention due to Whitfield Diffie & Martin Hellman at Stanford Univ. in 1976 Known earlier in classified community Known earlier in classified community
35
Public-Key Cryptography Public-key/two-key/asymmetric cryptography involves the use of two keys: A public-key, which may be known by anybody, and can be used to encrypt messages, and verify signatures A public-key, which may be known by anybody, and can be used to encrypt messages, and verify signatures A related private-key, known only to the recipient, used to decrypt messages, and sign (create) signatures A related private-key, known only to the recipient, used to decrypt messages, and sign (create) signatures Infeasible to determine private key from public Is asymmetric because Those who encrypt messages or verify signatures cannot decrypt messages or create signatures Those who encrypt messages or verify signatures cannot decrypt messages or create signatures
36
Public-Key Cryptography
37
Symmetric vs Public-Key
38
RSA By Rivest, Shamir & Adleman of MIT in 1977 Best known & widely used public-key scheme Based on exponentiation in a finite (Galois) field over integers modulo a prime nb. exponentiation takes O((log n) 3 ) operations (easy) nb. exponentiation takes O((log n) 3 ) operations (easy) Uses large integers (eg. 1024 bits) Security due to cost of factoring large numbers nb. factorization takes O(e log n log log n ) operations (hard) nb. factorization takes O(e log n log log n ) operations (hard)
39
RSA En/decryption To encrypt a message M the sender: Obtains public key of recipient PU={e,n} Obtains public key of recipient PU={e,n} Computes: C = M e mod n, where 0≤M<n Computes: C = M e mod n, where 0≤M<n To decrypt the ciphertext C the owner: Uses their private key PR={d,n} Uses their private key PR={d,n} Computes: M = C d mod n Computes: M = C d mod n Note that the message M must be smaller than the modulus n (block if needed)
40
RSA Key Setup Each user generates a public/private key pair by: Selecting two large primes at random: p, q Computing their system modulus n=p.q note ø(n)=(p-1)(q-1) note ø(n)=(p-1)(q-1) Selecting at random the encryption key e where 1<e<ø(n), gcd(e,ø(n))=1 where 1<e<ø(n), gcd(e,ø(n))=1 Solve following equation to find decryption key d e.d=1 mod ø(n) and 0≤d≤n e.d=1 mod ø(n) and 0≤d≤n Publish their public encryption key: PU={e,n} Keep secret private decryption key: PR={d,n}
41
Why RSA Works Because of Euler's Theorem: a ø(n) mod n = 1 where gcd(a,n)=1 a ø(n) mod n = 1 where gcd(a,n)=1 In RSA have: n=p.q n=p.q ø(n)=(p-1)(q-1) ø(n)=(p-1)(q-1) Carefully chose e & d to be inverses mod ø(n) Carefully chose e & d to be inverses mod ø(n) Hence e.d=1+k.ø(n) for some k Hence e.d=1+k.ø(n) for some k Hence : C d = M e.d = M 1+k.ø(n) = M 1.(M ø(n) ) k = M 1.(1) k = M 1 = M mod n = M 1.(1) k = M 1 = M mod n
42
RSA Example - Key Setup 1. Select primes: p=17 & q=11 2. Calculate n = pq =17 x 11=187 3. Calculate ø(n)=(p–1)(q-1)=16x10=160 4. Select e : gcd(e,160)=1; choose e=7 5. Determine d : de=1 mod 160 and d < 160 Value is d=23 since 23x7=161= 10x160+1 6. Publish public key PU={7,187} 7. Keep secret private key PR={23,187}
43
RSA Example - En/Decryption Sample RSA encryption/decryption is: Given message M = 88 (nb. 88<187 ) Encryption: C = 88 7 mod 187 = 11 Decryption: M = 11 23 mod 187 = 88
44
Diffie-Hellman Key Exchange First public-key type scheme proposed By Diffie & Hellman in 1976 along with the exposition of public key concepts Note: now know that Williamson (UK CESG) secretly proposed the concept in 1970 Note: now know that Williamson (UK CESG) secretly proposed the concept in 1970 Is a practical method for public exchange of a secret key Used in a number of commercial products
45
Diffie-Hellman Key Exchange A public-key distribution scheme Cannot be used to exchange an arbitrary message Cannot be used to exchange an arbitrary message Rather it can establish a common key Rather it can establish a common key Known only to the two participants Known only to the two participants Value of key depends on the participants (and their private and public key information) Based on exponentiation in a finite (Galois) field (modulo a prime or a polynomial) - easy Security relies on the difficulty of computing discrete logarithms (similar to factoring) – hard
46
Discrete Logarithm Ordinary logarithm: a x =b a x =b x=log a (b) x=log a (b) Discrete logarithm: b=a i mod p(0 i p-1) b=a i mod p(0 i p-1) a: primitive root of prime number pa: primitive root of prime number p Can generate all integers from 1 to p-1Can generate all integers from 1 to p-1 i.e. a 1 mod p, a 2 mod p, a p-1 mod p are distincti.e. a 1 mod p, a 2 mod p, a p-1 mod p are distinct i=dlog a,p (b) i=dlog a,p (b)
47
Diffie-Hellman Setup All users agree on global parameters: Large prime integer or polynomial q Large prime integer or polynomial q a being a primitive root mod q a being a primitive root mod q Each user (eg. A) generates their key Chooses a secret key (number): x A < q Chooses a secret key (number): x A < q Compute their public key: y A = a x A mod q Compute their public key: y A = a x A mod q Each user makes public that key y A
48
Diffie-Hellman Key Exchange Shared session key for users A & B is K AB : K AB = a x A. x B mod q = y A x B mod q (which B can compute) = y B x A mod q (which A can compute) K AB is used as session key in private-key encryption scheme between Alice and Bob If Alice and Bob subsequently communicate, they will have the same key as before, unless they choose new public-keys Attacker needs an x, must solve discrete log from the corresponding y
49
Diffie-Hellman Example Users Alice & Bob who wish to swap keys: Agree on prime q=353 and a=3 Select random secret keys: A chooses x A =97, B chooses x B =233 A chooses x A =97, B chooses x B =233 Compute respective public keys: y A = 3 97 mod 353 = 40 (Alice) y A = 3 97 mod 353 = 40 (Alice) y B = 3 233 mod 353 = 248 (Bob) y B = 3 233 mod 353 = 248 (Bob) Compute shared session key as: K AB = y B x A mod 353 = 248 97 = 160 (Alice) K AB = y B x A mod 353 = 248 97 = 160 (Alice) K AB = y A x B mod 353 = 40 233 = 160 (Bob) K AB = y A x B mod 353 = 40 233 = 160 (Bob)
50
Key Exchange Protocols Users could create random private/public D-H keys each time they communicate (Fig. 3.13) (Fig. 3.13) Users could create a known private/public D-H key and publish in a directory, then consulted and used to securely communicate with them Both of these are vulnerable to a meet-in- the-Middle Attack Authentication of the keys is needed
51
Man-in-the-Middle Attack 1. Darth prepares by creating two private / public keys 2. Alice transmits her public key to Bob 3. Darth intercepts this and transmits his first public key to Bob. Darth also calculates a shared key with Alice 4. Bob receives the public key and calculates the shared key (with Darth instead of Alice) 5. Bob transmits his public key to Alice 6. Darth intercepts this and transmits his second public key to Alice. Darth calculates a shared key with Bob 7. Alice receives the key and calculates the shared key (with Darth instead of Bob) Darth can then intercept, decrypt, re-encrypt, forward all messages between Alice & Bob
52
Digital Signatures Have looked at message authentication But does not address issues of lack of trust But does not address issues of lack of trust Digital signatures provide the ability to: Verify author, date & time of signature Verify author, date & time of signature Authenticate message contents Authenticate message contents Be verified by third parties to resolve disputes Be verified by third parties to resolve disputes Hence include authentication function with additional capabilities
53
Digital Signature Model
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.