Ch12 Cryptographic Hash Functions
Ch12 Cryptographic Hash Functions
Cryptographic
Hash Functions
12.1
122SHA512
SHA-512 is the version of SHA with a 512-bit message
digest. This version, like the others in the SHA family of
algorithms, is based on the Merkle-Damgard scheme.
12.2.1 Introduction
Figure 12.6 Message digest creation SHA-512
12.3
12.2.1 Continued
Message Preparation
SHA-512 insists that the length of the original message be less
than 2128 bits.
Note
SHA-512 creates a 512-bit message digest out of a
message less than 2128.
12.4
12.2.1
Continued
Example 12.1
12.2.1
Continued
Example 12.2
This example also concerns the message length in SHA-512. How many
pages are occupied by a message of 2128 bits?
Solution
Suppose that a character is 32, or 26, bits. Each page is less than 2048, or
approximately 212, characters. So 2128 bits need at least 2128 / 218, or 2110,
pages. This again shows that we need not worry about the message
length restriction.
12.6
SHA Version
12.8
General Logic
Basic Steps
Step1: Padding
Step2: Appending length as 64 bit unsigned
Step3: Initialize MD buffer 5 32-bit words
Store in big endian format, most significant bit in low address
A|B|C|D|E
A = 67452301
B = efcdab89
C = 98badcfe
D = 10325476
E = c3d2e1f0
Basic Steps...
Step 4: the 80-step processing of 512-bit blocks 4
rounds, 20 steps each.
Each step t (0 <= t <= 79):
Input:
Kt a constant
ABCDE: current MD
Output:
ABCDE: new MD
12.12
12.13
Basic Steps...
12.2.1 Continued
12.15
12.2.1
Continued
Example 12.3
What is the number of padding bits if the length of the original message
is 2590 bits?
Solution
We can calculate the number of padding bits as follows:
12.16
12.2.1
Continued
Example 12.4
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.
12.17
12.2.1
Continued
Example 12.5
12.18
12.2.1
Example 12.5
Continued
Continued
12.2.1 Continued
Words
Figure 12.8 A message block and the digest as words
12.20
12.2.1 Continued
Word Expansion
Figure 12.9 Word expansion in SHA-512
12.21
12.2.1
Continued
Example 12.6
Show how W60 is made.
Solution
Each word in the range W16 to W79 is made from four previously-made
words. W60 is made as
12.22
12.2.1 Continued
Message Digest Initialization
12.23
12.24
12.2.2 Continued
Figure 12.11 Structure of each round in SHA-512
12.25
12.2.2 Continued
Majority Function
Conditional Function
Rotate Functions
12.26
12.2.2 Continued
12.27
12.2.2 Continued
There are 80 constants, K0 to K79, each of 64 bits. Similar
These values are calculated from the first 80 prime numbers
(2, 3,, 409). For example, the 80th prime is 409, with the
cubic root (409)1/3 = 7.42291412044. Converting this number
to binary with only 64 bits in the fraction part, we get
12.28
12.2.2
Continued
Example 12.7
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.
12.29
12.2.2
Continued
Example 12.8
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.
12.30