3 Hash Functions
3 Hash Functions
Hash Functions
Message and Message Digest
Merkle-Damgard scheme
Two Groups of Compression Functions
Message Preparation
SHA-512 insists that the length of the original message be
less than 2128 bits.
Note
Example 1
Example 2
Solution
Yes we do, because we need to add the length field. So padding is
needed to make the new block a multiple of 1024 bits.
Continued
Words
SHA-512 operates on words; it is word oriented. A word is defined
as
64A bits.
message block and the digest as words
Continued
Word Expansion
• Before processing, each message block must be expanded.
• A block is made of 1024 bits, or sixteen 64-bit words.
• SHA-512 requires 80 words in the processing phase. So the
16-word block needs to be expanded to 80 words, from W0
to W79.
• Each word in the range W16 to W79 is made from four
previously-made words as shown in the figure on next slide.
Continued
Word Expansion
Word expansion in SHA-512
Continued
Example 3
• In each round, eight new values for the 64-bit buffers are
created from the values of the buffers in the previous round.
• As shown in the figure on the next slide, the six buffers (B, C,
D, F, G, and H) are the exact copies of one of the buffers in
the previous round, and two of the new buffers (A and E)
receive their inputs from some complex functions.
• Complex functions involve some of the previous buffers, the
corresponding word for this round (Wi), and the corresponding
constant for this round (Ki).
Continued
Structure of each round in SHA-512
Continued
Majority Function
It is a bitwise function. It takes three corresponding bits from
three buffers (A, B, and C) and calculates the resulting bit.
Conditional Function
It is also a bitwise function. It takes three corresponding bits from
three buffers (E, F, and G) and calculates the resulting bit.
Continued
Rotate Functions
It right-rotates the three instances of the same buffer (A or E). The
function, RotRi(x), right-rotates its argument by i bits; it is actually a
circular shift-right operation.
Addition operator ( )
The addition operator used in the process is addition modulo 2 64. This
means that the result of adding two or more buffers is always a 64-bit
word.
Continued
Continued
Example 4
We apply the Majority function on buffers A, B, and C. If the leftmost
hexadecimal digits of these buffers are 0x7, 0xA, and 0xE,
respectively, what is the leftmost digit of the result?
Solution
The digits in binary are 0111, 1010, and 1110.
a. The first bits are 0, 1, and 1. The majority is 1.
b. The second bits are 1, 0, and 1. The majority is 1.
c. The third bits are 1, 1, and 1. The majority is 1.
d. The fourth bits are 1, 0, and 0. The majority is 0.
The result is 1110, or 0xE in hexadecimal.
Continued
Example 5
We apply the Conditional function on E, F, and G buffers. If the
leftmost hexadecimal digits of these buffers are 0x9, 0xA, and 0xF
respectively, what is the leftmost digit of the result?
Solution
The digits in binary are 1001, 1010, and 1111.
a. The first bits are 1, 1, and 1. The result is F1, which is 1.
b. The second bits are 0, 0, and 1. The result is G2, which is 1.
c. The third bits are 0, 1, and 1. The result is G3, which is 1.
d. The fourth bits are 1, 0, and 1. The result is F4, which is 0.
The result is 1110, or 0xE in hexadecimal.
End