Chapter 3. Public-Key Cryptography and Message Authentication
Total Page:16
File Type:pdf, Size:1020Kb
Network Security Essentials Applications and Standards Third Edition William Stallings Chapter 3 Public-Key Cryptography and Message Authentication Dr. BHARGAVI H. GOSWAMI Head & Associate Professor Department of Computer Science Garden City College +91 9426669020 [email protected] Topic Outline 1. Approaches to Message Authentication 2. Secure Hash Functions and HMAC 3. Public-Key Cryptography Principles 4. Public-Key Cryptography Algorithms 5. Digital Signatures 6. Key Management Authentication • Encryption protects against passive attack. • But for active attacks we needs Authentication. • Authentication Requirements - must be able to verify that: 1. Message came from apparent source or author, 2. Contents have not been altered, 3. Sometimes, it was sent at a certain time or sequence. • Thus provide protection against active attack (falsification of data and transactions) Approaches to Message Authentication Includes following Sub topics: A. Authentication Using Conventional Encryption. B. Message Authentication without Message Encryption. C. Message Authentication Code. D. One way Hash function. A. Authentication Using Conventional Encryption: a) Genuine sender and receiver: Only the sender and receiver should share a key. b) Include Error Detection Code to avoid alterations. c) Proper Sequencing. d) Include Timestamp to assure no delay. B. Message Authentication without Message Encryption: a) An authentication tag is generated and appended to each message. b) Message is neigther E nor D without authentication function. c) Message confidentiality is not provided as message is not Encrypted. d) Advantageous when encryption is overhead and security requirement is not very high. C. Message Authentication Code: a) Calculate the MAC as a function of the message and the key. MAC = F(KAB, M) b) Involves the use of secret key to generate data block. c) Message plus MAC code are transmitted to intended recipient. d) If the received code matches calculated code, a) Assured message is not been altered. b) Assured that message is from alleged sender. c) Attacker cannot successfully alter sequence number. e) Similar to encryption. f) Then what is the difference? Algorithm need not be reversible. g) Advantage: Less vulnerable to being broken than encryption due to its mathematical properties. D. One Way Hash Function • Alternate of MAC. • Similarity with MAC. – Input: variable size message M. – Output: Fixed size message digest H(M). • Difference with MAC. – Does not take Key as input. • Following three ways of authentication: – Using Conventional Encryption – Using Public Key Encryption – Using Secret Value One-Way Hash Function a) Conventional Encryption, only sender and receiver share the encryption key; then authenticity is assured. b) Public Key Encryption, It has 2 advantages: - Provides digital signature and authentication. - Does not require distribution of keys. For above stated methods, computation required is very less. c) Using Secret Value, (next figure) – no encryption is required; – authenticity using hash function. – Here, A and B share secret key SAB and calculate MDM=H(SAB|M). – Then it sends [M|MDM] to B. – B has SAB, it can compute H(SAB|M) and verify MDM. – Advantage: Secure, as secret key is not sent. One-Way Hash Function • Secret value is added before the hash and removed before transmission. In which situation we wish to avoid Encryption altogether? When Encryption s/w is slow and data to be encrypted is also too small. Encryption hardware costs are non-negligible and could not be attached to each system in n/w. Encryption Algorithm spent high proportion of the time in initialization/invocation overhead. Encryption algorithms may be patented and must be licensed, adding a cost. Eg: RSA public-key algorithm. Encryption algorithms may be subject to export control. This is true of DES. Secure Hash Functions • Purpose of the hash function: is to produce a “fingerprint” of a file, message or data block. • Required Properties of a hash function H: 1. H can be applied to a block of data at any size. 2. H produces a fixed length output. 3. H(x) is easy to compute for any given x in anything, h/w or s/w. 4. For any given value h, it is computationally infeasible to find x such that H(x) = h. Known as One Way Property. 5. For any given block x, it is computationally infeasible to find y x with H(y) = H(x). Known as Weak Collision Resistance. 6. It is computationally infeasible to find any pair (x, y) such that H(x) = H(y). Known as Strong Collision Resistance. • To provide ‘Message Authentication’, first 3 properties are required. • 4th property, “one-way” is important if authentication involves use of secret key. • 5th property, “weak collision resistance” guaranties that analyst cannot find alternative msg with same hash value. • If hash function satisfies first 5 properties, its called weak hash function. • If hash function satisfies all 6 properties, its called strong hash function. • This process of message digest also provides data integrity. Simple Hash Function: • All hash functions operate using the following general principles: • “The input is processed one block at a time in an iterative fashion to produce an n-bit hash function.” • One of the simplest hash functions is the bit-by-bit exclusive-OR (XOR) of every block. • This can be expressed as follows: Ci = bi1 XOR bi2 XOR . XOR bim where, Ci = ith bit of the hash code, 1 <= i <= n m = number of n-bit blocks in the input bij = ith bit in jth block XOR =xor operation This is explained in next figure. • It produces simple parity for each bit position. • So, also called longitudinal redundancy check. • Effective for random data. • Provides data integrity check. • Problems: – Each n-bit hash value is equally likely. – So, probability of data error is equal to 2-n. – When data is more formatted, function becomes less effective. – Eg: Data of 128 bit, Error probability 2-128 and effectiveness 2-112. • Now, how to improve the method? • Solution? • Solution? Rotation. • Perform one bit circular shift on hash value after each block is processed. • Procedure: 1. Initially set the n-bit hash value to zero. 2. Process each successive n-bit block of data: a. Rotate the current hash value to the left by one bit. b. XOR the block into the hash value. • This has the effect of “randomizing” • Overcome the regularities in input. • Advantage: Provides good measure of data integrity. • Dis-advantage: Virtually useless for data security when an encrypted hash code is used. (See fig 3.2 a and b.) • Conclusion: XOR or Rotated XOR (RXOR) is insufficient if hash code is encrypted. • Problem? Solution? • What if we encrypt hash code and message both? Good Idea? • Technique proposed by National Bureau of Standards. • Uses simple XOR. • Applied to 64 bit blocks. • And then encryption is done using CBC(Cipher Block Chaining) mode. • Blocks :X1, X2, . ., XN, • Hash code : C • Block-by-block xoring is done: xor • Then all blocks and append the hash code as the final block: • C = XN+1 = X1 X2 . XN • Then encrypt entire message plus hash code using CBC mode. • Output encrypted message Y1, Y2, ...Yn+1. X1 = IV xor D(K, Y1) Xi = Yi-1 xor D(K, Yi) Xn+1 = Yn xor D(K, Yn+1) • But, Xn+1 is the hash code, so Xn+1 = X1 xor X2 xor ......xor Xn sdf = [IV xor D(K,Y1)] xor [Y1 xor D(K,Y2)] xor ...................xor [Yn-1 xor D(K,Yn)] • Advantage: – Equation can be XORed in any order. – Hash code would not change if cipher-text blocks are permuted. SHA-1 Secure Hash Function: • History of SHA: Secure Hash Algorithm: • SHA was more or less the last remaining standardized hash algorithm by 2005. • Was developed by National Institute of Standards and Technology (NIST). • Published as Federal Information Processing Standard (FIPS 180) in 1993. • When weaknesses were discovered in SHA (now known as SHA-0), a revised version was issued as FIPS 180-1 in 1995 and is referred to as SHA-1. • SHA-1 is also specified in RFC 3174, which essentially duplicates the material in FIPS 180-1 but adds a C code implementation. • In 2002, NIST produced a revised version of the standard, FIPS 180-2, that defined three new versions of SHA with hash value lengths of 256, 384, and 512 bits known as SHA-256, SHA- 384, and SHA-512, respectively. • Collectively, these hash algorithms are known as SHA-2. • See next figure. • SHA is based on the hash function MD4. • SHA-1 produces a hash value of 160 bits. • Here, we provide a description of SHA-512 as other versions are quite similar. • Input: 2128 bits message. • Output: 512-bit message digest MD. • The input is processed in 1024-bit blocks. • Procedure: – Step 1: Append padding bits. – Step 2: Append length. – Step 3: Initialize hash buffer. – Step 4: Process message in 1024-bit (128 words) blocks. – Step 5: Output. • Step 1: Append padding bits: – The message is padded so that its length is congruent to 896 modulo 1024 [length 896 (mod 1024)]. – The padding consists of a single 1 bit followed by the necessary number of 0 bits. • Step 2: Append Length: – A block of 128 bits is appended to the message. – This block has original message and code which is treated as an unsigned 128-bit integer. • Step 3: Initialize hash buffer: – A 512-bit buffer is used to hold intermediate and final results of the hash function. – Represented as eight 64-bit registers (a, b, c, d, e, f, g, h). – Registers are are initialized to the following 64-bit integers (hexadecimal values). – These values are stored in big-endian format, which is the most significant byte of a word in the low-address (leftmost) byte position. Initialization of registers: • a = 6A09E667F3BCC908 • b = BB67AE8584CAA73B • c = 3C6EF372FE94F82B • d = A54FF53A5F1D36F1 • e = 510E527FADE682D1 • f = 9B05688C2B3E6C1F • g = 1F83D9ABFB41BD6B • h = 5BE0CD19137E2179 • Step 4 Process message in 1024-bit (128-word) blocks: – The heart of the algorithm.