Cryptography Reference
In-Depth Information
Fig. 11.9
High-level diagram of SHA-1
chunks. The compression function consists of 80 rounds which are divided into four
stages of 20 rounds each.
11.4.1 Preprocessing
Before the actual hash computation, the message
x
has to be padded to fit a size of
a multiple of 512 bit. For the internal processing, the padded message must then be
divided into blocks. Also, the initial value
H
0
is set to a predefined constant.
Padding
Assume that we have a message
x
with a length of
l
bit. To obtain an
overall message size of a multiple of 512 bits, we append a single “1” followed
by
k
zero bits and the binary 64-bit representation of
l
. Consequently, the number
of required zeros
k
is given by
≡
−
−
−
k
512
64
1
l
−
(
l
+ 1) mod 512
.
= 448
Figure 11.10 illustrates the padding of a message
x
.
N
512 bits
l
bits
k
+1 bits
64 bits
Message
x
100....0
l
Padding
Fig. 11.10
Padding of a message in SHA-1
Example 11.1.
Given is the message “
abc
” consisting of three 8-bit ASCII char-
acters with a total length of
l
= 24 bits: