0% found this document useful (0 votes)
12 views32 pages

Crytpographic Hash Functions

The document discusses cryptographic hash functions, focusing on their properties, such as determinism, uniformity, and collision resistance, which are essential for ensuring data integrity and security. It details specific algorithms like MD5 and SHA-1, explaining their workings and applications in data authentication. Additionally, it covers Message Authentication Codes (MAC), HMAC, and CMAC as methods for ensuring message integrity and authenticity.

Uploaded by

amishav2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views32 pages

Crytpographic Hash Functions

The document discusses cryptographic hash functions, focusing on their properties, such as determinism, uniformity, and collision resistance, which are essential for ensuring data integrity and security. It details specific algorithms like MD5 and SHA-1, explaining their workings and applications in data authentication. Additionally, it covers Message Authentication Codes (MAC), HMAC, and CMAC as methods for ensuring message integrity and authenticity.

Uploaded by

amishav2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Cryptography and System

Security

Cryptographic Hash
Functions

Sejal Chopra
Assistant Professor - Dept. of Computer Engineering
Don Bosco Institute of Technology, Mumbai
Contents to be discussed

• Introduction
• Properties of Secure Hash Function
• MD5
• SHA-1
• MAC
• HMAC
• CMAC
Cryptographic Hash Functions-
Introduction
It is a function that takes arbitrary-sized data and maps it to a fixed-size integer
value.
Cryptographic Hash Functions-
Introduction
• A hash function H accepts a variable-length block of data M as input
and produces a fixed-size hash value h = H(M).
• A “good” hash function has the property that the results of applying
the function to a large set of inputs will produce outputs that are
evenly distributed and apparently random.
• In general terms, the principal object of a hash function is data
integrity. A change to any bit or bits in M results, with high probability,
in a change to the hash value.
• The kind of hash function needed for security applications is referred
to as a cryptographic hash function.
• A cryptographic hash function is an algorithm for which it is
computationally infeasible (because no attack is significantly more
efficient than brute force) to find either
 a data object that maps to a pre-specified hash result (the one-way
property) or
 two data objects that map to the same hash result (the collision-free
property).
• Because of these characteristics, hash functions are often used to
determine whether or not data has changed.
Cryptographic Hash Functions-
Introduction
Typically, the input is padded out to an integer multiple of some fixed length
(e.g., 1024 bits), and the padding includes the value of the length of the
original message in bits.
The length field is a security measure to increase the difficulty for an
attacker to produce an alternative message with the same hash value.
Properties of Secure Hash Function
• Determinism: A hash function is deterministic, meaning a given input
will always produce the same output.

• Uniformity: A good hash function should produce uniformly


distributed outputs. This means that the probability of any given work
should be equal. This property is essential because it helps to avoid
collisions, where different inputs produce the same result.

• Non-reversibility: A hash function is non-reversible, meaning it is


impossible to determine the input that produced a given output. This
property is essential because it helps to ensure data security and
confidentiality.

• Fixed-size output: It produces a fixed-size output regardless of the


input size. This property is essential because it enables efficient
storage and retrieval of data.
Properties of Secure Hash Function
• Sensitivity to input changes: A slight change in the input to a hash
function should produce a significant difference in the output. This
property is essential because it helps to ensure data integrity, as even
minor changes in the input will result in a different production.

• Collision resistance: A good hash function should be resistant to


collisions, which occur when different inputs produce the same output.
Collision resistance is significant because it helps ensure data
accuracy and reliability.

• Speed: A hash function should be fast and efficient, as it is for real-


time applications where speed is critical.
Properties of Secure Hash Function
Pre-image resistance:
It is computationally infeasible to invert a hash function (find an input that
hashes to the given output). The following is not possible.
Properties of Secure Hash Function
Second pre-image resistance:
It is computationally infeasible to find a second input that hashes to the
same output as the given input. e.g., Given h(Cat) = AB38DA, it is
computationally very hard to find another input that maps to the same
output.
Properties of Secure Hash Function
Properties of Secure Hash Function
Collision resistant:
It is a property of a hash function h for which it is computationally very
hard to find two distinct inputs, A and B, for which h(A) = h(B).
MD-5 algorithm
• MD5 is a cryptographic hash function algorithm that takes the
message as input of any length and changes it into a fixed-length
message of 16 bytes.
• MD5 algorithm stands for the message-digest algorithm.
• The output of MD5 (Digest size) is always 128 bits. MD5 was developed
in 1991 by Ronald Rivest.
• It is used for file authentication.In a web application, it is used for
security purposes. e.g. Secure password of users etc
Working of MD-5 algorithm
1. Append Padding Bits: In the first step, we add padding bits in the original
message in such a way that the total length of the message is 64 bits less
than the exact multiple of 512. When it comes to padding the bits, you
must add one(1) first, followed by zeroes to round out the extra
characters.

Length(original message + padding bits) = 512 * i – 64 where i = 1,2,3 . . .


Working of MD-5 algorithm
2. Append Length Bits: In this step, we add the length bit in the output of the
first step in such a way that the total number of the bits is the perfect multiple
of 512. Simply, here we add the 64-bit as a length bit in the output of the first
step.
i.e. output of first step = 512 * n – 64
length bits = 64.
After adding both we will get 512 * n i.e. the exact multiple of 512.
Working of MD-5 algorithm
3.Initialize MD Buffer
The entire string is converted into multiple blocks of 512 bits each. You also
need to initialize four different buffers, namely A, B, C, and D. These buffers
are 32 bits each and are initialized as follows:
F(K,L,M) = (K AND L) OR (NOT K AND M) - G(K,L,M) = (K AND L) OR (L AND NOT M) - H(K,L,M) = K XOR L XOR M - I(K,L,M) = L XOR (K OR NOT M)

Working of MD-5 algorithm


4. Process Each 512-bit Block: This is the most important step of the MD5
algorithm. Here, a total of 64 operations are performed in 4 rounds-EACH
ROUND HAS 16 OPERATIONS.

F(A,B,C) = (B AND C) OR (NOT B AND D)


G(A,B,C) = (B AND D) OR (C AND NOT D)
H(A,B,C) = B XOR C XOR D
I(A,B,C) = C XOR (B OR NOT D)
F(K,L,M) = (K AND L) OR (NOT K AND M) - G(K,L,M) = (K AND L) OR (L AND NOT M) - H(K,L,M) = K XOR L XOR M - I(K,L,M) = L XOR (K OR NOT M)

Working of MD-5 algorithm


Steps followed are:
• It passes B, C, and D onto a function.1st round-F
function, 2nd- G function, 3rd -H function and 4th-I
function.
• The result is added with the value present at A.
• It adds M[i] – 32 bit message to the result above.
• Then, it adds the constant value K[i] – 32-bit
constant for that particular iteration.
• There is a left circular shift by n bits applied to
the string.
• As a final step, it adds the value of B to the
string.
• After each round the values stored in registers
got shuffled. The value in D is stored in A, value
of A is stored in B, value of B is stored in C and
value of C is stored in D. At last the values
obtained from the algorithm are added with the
values stored in temporary variables.
F(K,L,M) = (K AND L) OR (NOT K AND M) - G(K,L,M) = (K AND L) OR (L AND NOT M) - H(K,L,M) = K XOR L XOR M - I(K,L,M) = L XOR (K OR NOT M)

Working of MD-5 algorithm


After processing of all 512-bit blocks with the algorithm,
the message digest of n-bit message is in A, B, C and
D. The lower order byte of A represents the first byte of
MD5 output. The higher order byte of D represents the
last byte of MD5 output.

5.Output:
After processing of all 512-bit blocks with the algorithm, the message
digest of n-bit message is in A, B, C and D. The lower order byte of A
represents the first byte of MD5 output. The higher order byte of D
represents the last byte of MD5 output.
SHA-1 algorithm
SHA-1 or Secure Hash Algorithm 1 is a cryptographic algorithm
which takes an input and produces a 160-bit (20-byte) hash value.
This hash value is known as a message digest. This message
digest is usually then rendered as a hexadecimal number which is
40 digits long.
Working of SHA-1 algorithm
Working of SHA-1 algorithm
Working of SHA-1 algorithm
Working of SHA-1 algorithm
Comparison of various SHA
algorithms
Message Authentication Code (MAC)
Message Authentication Code (MAC)
HMAC (Hashed Based MAC)
HMAC
CMAC (Cipher Based MAC)
CMAC
References

• William Stallings, “Cryptography and Network Security,


Principles and Practice”, 6th Edition, Pearson Education,
March 2013
• Behrouz A. Ferouzan, “Cryptography & Network Security”,
Tata McGraw Hill
THANK YOU

You might also like