An Overview of Cryptographic Hash Functions

Similar documents
Lecture 1 Applied Cryptography (Part 1)

CSE 127: Computer Security Cryptography. Kirill Levchenko

S. Erfani, ECE Dept., University of Windsor Network Security

Computer Security: Principles and Practice

CIS 4360 Secure Computer Systems Symmetric Cryptography

9/30/2016. Cryptography Basics. Outline. Encryption/Decryption. Cryptanalysis. Caesar Cipher. Mono-Alphabetic Ciphers

APNIC elearning: Cryptography Basics

Cryptography Basics. IT443 Network Security Administration Slides courtesy of Bo Sheng

Information Security CS526

Winter 2011 Josh Benaloh Brian LaMacchia

Data Integrity & Authentication. Message Authentication Codes (MACs)

Ref:

Computer Security. 08r. Pre-exam 2 Last-minute Review Cryptography. Paul Krzyzanowski. Rutgers University. Spring 2018

Cryptographic Hash Functions. Rocky K. C. Chang, February 5, 2015

Introduction to Cryptography. Lecture 6

1.264 Lecture 28. Cryptography: Asymmetric keys

Data Integrity & Authentication. Message Authentication Codes (MACs)

Computer Security CS 526

A hash function is strongly collision-free if it is computationally infeasible to find different messages M and M such that H(M) = H(M ).

The question paper contains 40 multiple choice questions with four choices and students will have to pick the correct one (each carrying ½ marks.).

Lecture 1: Course Introduction

Message Authentication with MD5 *

Cryptography. Summer Term 2010

Encryption I. An Introduction

Kurose & Ross, Chapters (5 th ed.)

A hash function is strongly collision-free if it is computationally infeasible to find different messages M and M such that H(M) = H(M ).

Data Integrity. Modified by: Dr. Ramzi Saifan

Introduction to Network Security Missouri S&T University CPE 5420 Data Integrity Algorithms

CS408 Cryptography & Internet Security

Cryptography Functions

Message Authentication Codes and Cryptographic Hash Functions

CSCE 715: Network Systems Security

Multiple forgery attacks against Message Authentication Codes

Spring 2010: CS419 Computer Security

Cryptographic Hash Functions

Data Encryption Standard (DES)

CSC 774 Network Security

EEC-682/782 Computer Networks I

Summary on Crypto Primitives and Protocols

Digests Requirements MAC Hash function Security of Hash and MAC Birthday Attack MD5 SHA RIPEMD Digital Signature Standard Proof of DSS

Cryptography and Network Security Chapter 12. Message Authentication. Message Security Requirements. Public Key Message Encryption

ח'/סיון/תשע "א. RSA: getting ready. Public Key Cryptography. Public key cryptography. Public key encryption algorithms

Practical Aspects of Modern Cryptography

Journal of Discrete Mathematical Sciences & Cryptography Vol. ( ), No., pp. 1 10

Hash Function. Guido Bertoni Luca Breveglieri. Fundations of Cryptography - hash function pp. 1 / 18

Public-key Cryptography: Theory and Practice

CS408 Cryptography & Internet Security

Encryption. INST 346, Section 0201 April 3, 2018

Analysis of Cryptography and Pseudorandom Numbers

ISSN: Page 320

Cryptanalysis. Ed Crowley

Lecture 2: Secret Key Cryptography

Network Security Essentials Chapter 2

Lecture 5. Cryptographic Hash Functions. Read: Chapter 5 in KPS

Cryptography ThreeB. Ed Crowley. Fall 08

Unit III. Chapter 1: Message Authentication and Hash Functions. Overview:

Chapter 6. New HASH Function. 6.1 Message Authentication. Message authentication is a mechanism or service used for verifying

Security. Communication security. System Security

CSC 474/574 Information Systems Security

Distributed Systems. 26. Cryptographic Systems: An Introduction. Paul Krzyzanowski. Rutgers University. Fall 2015

Cryptographic Checksums

KALASALINGAM UNIVERSITY

CIS 4360 Introduction to Computer Security Fall WITH ANSWERS in bold. First Midterm

CSE 3461/5461: Introduction to Computer Networking and Internet Technologies. Network Security. Presentation L

CSC/ECE 774 Advanced Network Security

Cryptography. Dr. Michael Schneider Chapter 10: Pseudorandom Bit Generators and Stream Ciphers

Delineation of Trivial PGP Security

Lecture 6: Overview of Public-Key Cryptography and RSA

L13. Reviews. Rocky K. C. Chang, April 10, 2015

LECTURE 4: Cryptography

Lecture 5. Cryptographic Hash Functions. Read: Chapter 5 in KPS

Cryptographic Hash Functions

S. Erfani, ECE Dept., University of Windsor Network Security. All hash functions operate using the following general principles:

EEC-484/584 Computer Networks

Cryptography & Key Exchange Protocols. Faculty of Computer Science & Engineering HCMC University of Technology

Encryption Algorithms Authentication Protocols Message Integrity Protocols Key Distribution Firewalls

Security: Cryptography

Lecture 4: Authentication and Hashing

Protecting Information Assets - Week 11 - Cryptography, Public Key Encryption and Digital Signatures. MIS 5206 Protecting Information Assets

Vortex: A New Family of One-way Hash Functions Based on AES Rounds and Carry-less Multiplication

Solutions to exam in Cryptography December 17, 2013

Block Ciphers. Secure Software Systems

ENEE 459-C Computer Security. Message authentication

Lecture 4: Hashes and Message Digests,

Computer Networks. Wenzhong Li. Nanjing University

PROTECTING CONVERSATIONS

Chapter 8 Security. Computer Networking: A Top Down Approach. 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012

Introduction to Cryptography. Vasil Slavov William Jewell College

Security Applications

Computer Security. 10r. Recitation assignment & concept review. Paul Krzyzanowski. Rutgers University. Spring 2018

An Efficient Stream Cipher Using Variable Sizes of Key-Streams

Comp527 status items. Crypto Protocols, part 2 Crypto primitives. Bart Preneel July Install the smart card software. Today

UNIT - IV Cryptographic Hash Function 31.1

Cryptographic hash functions and MACs

Introduction. CSE 5351: Introduction to cryptography Reading assignment: Chapter 1 of Katz & Lindell

ASYMMETRIC (PUBLIC-KEY) ENCRYPTION. Mihir Bellare UCSD 1

Homework 2. Out: 09/23/16 Due: 09/30/16 11:59pm UNIVERSITY OF MARYLAND DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

Course Business. Midterm is on March 1. Final Exam is Monday, May 1 (7 PM) Allowed to bring one index card (double sided) Location: Right here

Journal of Global Research in Computer Science A UNIFIED BLOCK AND STREAM CIPHER BASED FILE ENCRYPTION

Network Security Essentials

Transcription:

An Overview of Cryptographic Hash Functions Alok Ojha Indian Institute of Technology, Dept. of Mathematics Kharagpur 721302, India Email : ojha_iitkgp@yahoo.co.in, Sugata Sanyal Tata Institute of Fundamental Research, School of Technology and Computer Sc. Homi Bhabha road, Bombay 400 005, India Email : sanyal@tifr.res.in, June 25, 2002 Abstract This report gives a survey on cryptographic hash functions. It gives an overview of different types of hash functions and reviews design principles. It also focuses on keyed hash functions and suggests some applications and constructions of keyed hash functions. We have used hash (keyed) function for authenticating messages encrypted using Rijndael [1] block cipher. Moreover, a parallel message digest has been implemented using VHDL. The computational complexity is O(log k) compared to O(k) in case of serial method. Mersenne Twister is a uniform prng suggested by Matsumoto and Nishimura [2] which provides a astronomical period of 2 19937-1, but is not suitable for cryptographic applications. This report suggests a method for creating cryptographically secure random number using Mersenne Twister. 1. Introduction With the advent of public key cryptography and digital signature schemes, cryptographic hash functions have gained much more prominence. Therefore, we try to make a study of hash functions and their design principles. Information Theory and Complexity Theory are two major approaches in the study of hash functions. In the complexity theory approach, some assumptions are made based on the computing power of the enemy or the weakness of the existing systems and algorithms, and therefore the security cannot be proven but estimated by the analysis of best known attacking algorithms and considering improvements of the hardware and softwares. In this report we concentrate on the complexity theory approach. In this section we shall provide some basic definitions. In section 2, we discuss the design principles of hash functions. In section 3, applications and constructions of keyed hash functions are detailed, and in section 4, 5 and 6 we describe certain applications of hash function developed by us. 1.1 Definitions

Some useful definitions are given in this section. Definition 1 A function H() that maps an arbitrary length message M to a fixed length message digest MD is a One-Way Hash Function (OWHF), if it satisfies the following properties: 1. The description of H() is publicly known and should not require any secret information for its operation. 2. Given M, it is easy to compute H(M). 3. Given MD in the range of H(), it is hard to find a message M such that H(M) = MD, and given M and H(M), it is hard to find a message M ( M) such that H(M ) = H(M). Definition 2 A function H() that maps an arbitrary length message M to a fixed length message digest MD is a Collision Free Hash Function (CFHF), if it satisfies the following properties: 1. The description of H() is publicly known and should not require any secret information for its operation. 2. Given M, it is easy to compute H(M). 3. Given MD in the range of H(), it is hard to find a message M such that H(M) = MD, and given M and H(M), it is hard to find a message M ( M) such that H(M ) = H(M). 4. It is hard to find two distinct messages M and M that hash to the same result ( H(M) = H(M )). Definition 3 A function H() that maps a fixed length key K and an arbitrary length message M to n bit message digest MD is a Secure Keyed Hash Function (SKHF) or simply a Keyed Hash Function if it satisfies the following properties: 1. The description of H() is publicly known. 2. Given K and M, it is easy to compute H(K,M). 3. Without knowledge of K, it is hard to both find M when H(K,M) is given, and to find two distinct messages M and M such that H(K,M) = H(K,M ). 4. Given (possibly many) pairs of [ M i, MD i ] with MD i = H(K,M i ), it is hard to find the secret key K. 5. Without the knowledge of K, it is hard to determine H(K,M) for any message M, even when a large set of pairs [M i, H(K,M i )], where M i s are selected by the opponent (M M, M i ), is given. 2. Design Principles For Hash Functions Study of hash functions clears that most hash functions have similar structures. The following structure for hash functions has been suggested : 1. Choose a good round function f(), depending on the required level of the security. (Suppose the function maps a t-bit block into a r-bit block, where 128 r t.) 2. Use a padding procedure and pad a suffix to the arbitrary length message M such that the padded message length (in bits) becomes a multiple of t. The following padding procedure is suggested here: (a) Store the length of M modulo 2 s in a s-bit variable L and prepend it to the message. (b) Append a single 1 bit followed by enough 0 bits to the message such that the length of the result (in bits) is (t s) modulo t. (At least one bit is appended.)

(c) Append the s-bit variable L to the previous result. This makes the padded message length equal to a multiple of t. 3. Divide the padded message into n t-bit blocks M 1,M 2,,M n. This allows to process the message in t-bit blocks, using the round function f(). 4. Choose a good initial vector IV (probably by a random choice), and store it in an r-bit buffer X 1. 5. Perform the round function f() to the all n blocks, using a chaining method (X i+1, = f(x i,m i ), i = 1,2,,n). 6. The output of the above process is the message digest. That is, MD = X n+1. The above structure thwarts general attacks, such as Birthday attacks, but the cryptanalyst has still a chance to attack the hash function based on the weakness of the underlying round function f(). The round function should have the following properties: a) To have a weak/strong one-way hash function, the underlying round function should be so. This is a necessary condition but not sufficient, i.e, a hash function might not be one-way even if the underlying round function is so. b) To have collision free hash function the round function must be collision free. This is because, if the opponent can find two distinct messages M i and M i such that f(x i,m i ) = f(x i,m i ), for some chaining variable (intermediate value) X i, he/she can find a collision for the entire hash function by just replacing the M i with M i. c) It should be free from pseudo-collision. If the opponent can find two messages M i and M i and two chaining variables X i and X i such that f(x i,m i ) = f(x i,m i ), a pseudo collision is found. Sometimes pseudo collisions may lead to real collisions. For example, for the above pseudo collision, if the enemy can find a block M i such that f(x i, M i ) = X i, he/she can replace M i with ( M i M i ), because f(x i,m i ) = f( f(x i,m i ), M i ). d) It should not have fixed points. If the function has fixed points then the cryptanalyst may find a chaining variable X i such that f(x i,m i ) = X i. In this case M i can be inserted without affecting the result. However, adding a message length to the process provides some protection against this insertion. (another fixed point should be found and removed from the message to keep the message length constant) e) A hash function must use every bit of the message block many times. This prevents the cryptanalyst to create undetectable changes in the message, as changing a bit will cause many changes to the result of the round function. After choosing an appropriate round function, the process of the whole hash function must be analyzed. Any irregularities in the distribution of the output can lead to an attack (like Differential Cryptanalysis). 3. Keyed Hash Functions Keyed hash functions can be used for message authentication. In this section, applications and constructions of keyed hash functions are studied. 3.1 Application of Keyed Hash Function 3.1.1 Message Authentication between Two Parties

Although electronic signature [3] can be used for message authentication, they are usually slow and inefficient. They also need key distribution schemes for public key. When two parties need to communicate, it is easier to use a symmetric key rather than public and secret keys. Having a secure hash function, a message authentication between two communicants can be provided by sending the pair [M, MD] from one communicant to the other. 3.1.2 Message Authentication among Multiple Parties In some applications, such as electronic mails (Email), a message can be broadcasted to people to reduce the communication bandwidth. When a user A(Alice) wants to send a message M to other users B 1, B 2,,B n, she can, for example, send [M, H(K AB1,M),..., H(K Abn,M)] or [M, E(K AB1, (K H(K,M))),..., E(K Abn, (K H(K,M))) ], where H() is a keyed hash function, E() is an encryption algorithm, K Abi is the secret key shared between A and B i (i = 1, 2,, n) and K is a fixed length session key chosen by A. 3.1.3 Software Protection Keyed hash functions can be used to protect a software against modifications (and viruses). The protection can be provided by computing the digest of the file (software) using a keyed function and saving in a safe place. 3.1.4 Encryption Algorithms Hash functions can be used to construct encryption algorithms. In keyed hash functions, since a secret key contributes to the process of hashing, design of encryption algorithms becomes even simpler. An example clarifies the idea. Suppose H() is a secure keyed hash function which produces r-bit message digests. To encrypt a plaintext P = (P 1 P 2 ), where P 1 and P 2 are r-bit blocks, the following steps are followed: 1. T = H(K 1,P 1 ) P 2 2. C 1 = H(K 2,T) P 1 3. C 2 = H(K 1,C 1 ) P 2 Where K = (K 1 K 2 K 3 ) is the secret key and C 1 and C 2 are each r bits. The ciphertext is C = (C 1 C 2 ) and can be decrypted by a similar method. 1. T = H(K 1,C 1 ) C 2 2. P 1 = H(K 2,T) C 1 3. P 2 = H(K 1,C 1 ) T A similar scheme was originally proposed in [4] and was briefly examined in [5]. 3.2 Construction of Keyed Hash Functions from Existing Hash Functions In this section, we show how pre-existing hash functions can be used to construct a keyed hash function. This implies that, some security of the designed keyed hash function relies on the security of the underlying hash function. Bellare et al [6 ] have established a tight and general relationship between the security of the their schemes NMAC and HMAC, and the underlying hash function. We will consider Hash-then-Encrypt

Construction, Nested Hash Function Construction and Construction Using a Key as a Part of Message or Initial Vector. Hash-then-Encrypt Construction : The collision freeness depends on a collision free hash function H () and the protection against enemy depends on an encryption algorithm E(). The keyed hash function is defined as, H(K,M) = E(K, H (M)) Where K is the secret key and M is the message. Fig 1(a) illustrates this construction. Nested Hash Function Construction : There are many ways to construct a keyed hash function from nested hash functions. Here, we describe the most commonly used structure.suppose H () is a one-way hash function with r-bit message digest. The round function is defined as, f(x i,m i ) = H (H (X i ) M i ) Fig 1(b) illustrates this method. Thus, the keyed hash function can be summarized as : H(K,M) = f( f( f( f(k,m 1 ),M 2 ),,M n-1 ), M n ) figure 1(a) figure 1(b) Construction Using a Key as Part of Message or Initial Vector : The above constructions make the overall hash function slower. In this section, the construction of keyed hash function from a pre-existing hash function, by having a key as part of the message or the initial vector, is studied, and therefore, the speed of the constructed keyed hash function remains almost the same as that of the hash function. In the following, several schemes are given, where H () is a collision free (and pseudo-collision free) hash function, K = (K 1 K 2 ) is the secret key. denotes concatenation and R is special bitwise xor operation, where the operands may have different lengths and the xor will be performed bitwise starting from the right most bits. Similarly, L denotes special bitwise xor starting from the left most bits. And, IV stands for initial vector unless otherwise stated. 1. H(K,M) = H (IV,(K M)). 2. H(K,M) = H (IV, (M K)). 3. H(K,M) = H (IV, (K 1 M K 2 )). 4. H(K,M) = H (IV, (K M K)).

5. H(K,M) = H (IV, (K L M)). 6. H(K,M) = H (IV, (M R K)). 7. H(K,M) = H (IV, (K 1 L M R K 2 )). 8. H(K,M) = H (IV, (K L M R K)). 9. H(K,M) = H (IV, M), where IV = K. 10. H(K,M) = H (IV, (M R K)), where IV = K. 11. H(K,M) = H (IV, (M R K 2 )), where IV = K 1. 4. Secure Mersenne Twister Mersenne Twister (MT) is a pseudorandom number generator developed by Makoto Matsumoto and Takuji Nishimira [2]. It has the following merits : 1. Far longer period and far higher order of equidistribution than any other implemented generators. ( it is proved that the period is 2 19937-1, and 623-dimensional equidistribution property is assured) 2. Fast generation. (Although it depends on the system, it is reported to be sometimes faster than standard ANSI-C library in a system with pipepline and cache memory) 3. Efficient use of memory. (The implemented C-code consumes only 624 words of working area) With the above merits its suitable for most of the applications except cryptography. According to the authors, this generator does not create cryptographically secure random numbers as it is. By a simple linear transformation, the output of MT becomes a linear recurring sequence. Then, one can easily guess the present state from sufficiently large size of the output. Thus, its not suitable for cryptographic applications. In order to make this prng cryptographically more secure we suggest two modifications in the algorithm. First, we must hide the sequence generated by MT from the adversary. This can done by the use of an appropriate hash function mapping k- random numbers (each of length 32-bits) generated by MT to a message digest of length l. Second, MT makes use of a seed of size 32-bits which is an easy prey to attack by exhaustive search. So, an adversary can simply generate random seeds and see if the hash values obtained from the random numbers generated by MT match the data collected and thus succeed in guessing even the key. To avoid this, we modify the algorithm used for generating the initial vector of 624 32-bit words from a seed to size 32-bits, to accept a seed of size 128 bits. Here, the use of appropriate hash function is important. In order to preserve the period characteristic of MT the hash function should be such that it is very hard to find two such inputs which hash to the same value. Therefore, we suggest the use of collision-free hash functions (it need not be a keyed hash algorithm) like SHA-1 [7], MD5 [8]. Moreover, a hash function with round functions satisfying Strict Avalanche Criterion are more appropriate for this use, like, HAVAL [9]. 5. Message Authentication and Rijndael In communication, apart from secrecy, reliability of communication is an important issue. Message authentication is any procedure to verify that messages come from the alleged source and have not been altered. It should be possible, further, to verify the sequence/order and timing of messages. We provide a method to authenticate the messages encrypted by Rijndael. But, then a question arises that when an encrypted message is itself an authenticator, then why do this? The reason will be clear in the following discussion.

When the encrypted message is used as the authenticator, the reasoning is that the authorized sender is the only person who could create a ciphertext decrypting (with the key possessed by the authorized recipient ) to a coherent plaintext. If the plaintext is expected to be some language like English, then it should be hard to make a bogus ciphertext without having the true encryption key. But, the input to the decryption can be anything, so, if the legitimate messages are fairly arbitrary strings of 0 s and 1 s (like some assembly language code), then the decryption will give a supposed plaintext whose legitimacy will be hard to check. Moreover, such a method of authentication does not prevent Replay Attacks. Encryption does not prevent replay of old messages which had been heard and copied by an eavesdropper. In order to come over these problems, we suggest a scheme for authenticating the messages encrypted using the Rijndael [1]. figure 2(a) figure 2(b) Encryption : In this method, 256 bits of message block is encrypted using 128 bit key K. The ciphertext obtained while encryption after 2 nd last round is input to the hash function H() along with sequence number and time (time of generation) to generate a message digest of 128 bits. Intermediate ciphertext has been used to avoid the use of key in hash function thereby increasing the efficiency. Appropriate choice of hash function can be made accordingly. See figure 2(a). Decryption : The received packet has three parts : sequence number & time, ciphertext and message digest. Last round of Inverse Rijndael is applied to the ciphertext. Then the intermediate ciphertext along with the sequence number and time is fed to the hash function. The corresponding message digest is compared to the message digest in the packet. If they match, then the remaining rounds of decryption algorithm are applied else the packet is rejected. See figure 2(b). By doing so, we are able to earn 3 advantages. First, The process becomes more efficient as garbage packets are rejected before the application of complete decryption algorithm. Second, it checks the order of the received messages. Thus, an adversary cannot delete some of the sequence or reorder a sequence of messages. Third, every message has a Timestamp. So, an adversary cannot replay one or more old messages as if they were new, or delay messages to make them appear that they were sent later than they actually were.

6. Parallel Method of Hashing This method allows parallel computation of hash value on several processors. Let f be a fixed size, collision free, hash function mapping m bits to t bits. Then a collision free hash function H() which is implemented in a parallel way and maps strings of arbitrary length to t bit strings can be constructed as follows. Let a message M of length n be given. The message is padded with a number of 0 s so that the resulting bit string has a length equal to 2 k m for some k. 1 X i = f(m 2i-1,M 2i ) i = 1,...,2 k-1 j X i = f( j-1 X 2i-1, j-1 X 2i ) i = 1,...,2 k-1 ; j = 2,...,k-1 H(M) = f( k-1 X 1, k-1 X 2 ), H(M) : the final hash of M. This method is called parallel method in [10], while in some references such as [11] it is referred as the tree approach to hashing. For a given k, the complexity of this algorithm is clearly O(log k) as compared to O(k) in case of serial or chaining method. We are trying to implement this model on chip using VHDL for a given k. The work is still in progress. 7. Conclusion We have made a study on hash functions and their design principles and used them to make a pseudo random number generator called Mersenne Twister cryptographically secure. We have also succeeded in using hash functions for providing authentication to messages encrypted using Rijndael block cipher with three big advantages. We are also trying to implement the parallel method of hashing using VHDL and the work is currently in progress. 8. Acknowledgements I would like to thank my guide Dr. S. Sanyal for all his support and encouragement. 9. References [1] Vincent Rijmen and Joan Daemen, AES proposal : Rijndael, FIPS-197, 1999. [2] M. Matsumoto and T. Nishimura, Mersenne Twister : A 623-dimensionally equidistributed uniform pseudorandom number generator, unpublished. [3] J. Seberry and J. Pieprzyk, Cryptography : An introduction to computer security, Prentice Hall, 1989. [4] M. Luby and C. Rackoff, How to construct Pseudorandom Permutation and Functions, SIAm J. Computing, 17(2):373-386, April 1988. [5] R. Anderson, The classification of hash functions, In Proceedings of the IMA Conference in Cryptograpghy and Coding, 1993. [6] M. Bellare, R. Canett, and H. Krawczyk, Keying hash functions for message authentication, abridged version of this paper appears in Adv. In Cryptology Crypto 96 proceedings, Lecture notes in computer science vol. 1109, N. Kobiltz ed., Springer-Verlag. [7] Secure Hash Standard, FIPS pub 180-1, 1995. [8] R.L. Rivest, The MD5 message digest algorithm, RFC1321, April 1992, Network Working Group, MIT Laboratory for Computer Science and RSA Data Security, Inc.

[9] Y. Zheng, J. Pieprzyk, and J. Seberry, HAVAL A One-way Hashing Algorithm with Variable Length of Output, Adv. in Cryptology, Proceedings of AUSCRYPT 92, pages 83-104, December 1992. [10] J. Piepryzk and B. Sadeghiyan, Design of Hashing Algorithms, Lecture notes in Computer Science, 1993, Springer-Verlag. [11] B. Preneel, R. Govaerts, and J. Vandewalle, Collision resistant hash functions based on block ciphers, submitted to CRYPTO 91.