Module4-Integrity and Authentication
Module4-Integrity and Authentication
1 INTRODUCTION
Before discuss some general ideas that may be applied to any cryptographic hash
function.
.
Iterated Hash Function
Instead of using a hash function with variable-size input, a function with fixed-
size input is created and is used a necessary number of times.
.
Merkle-Damgard Scheme
The Merkle-Damgard scheme is an iterated hash function that is collision resistant if the
compression function is collision resistant.
.
Merkle-Damgard Scheme (contd)
2. The message is then considered as t blocks, each of n bits. Call each block M 1, M2,…, Mt.
3. Before starting the iteration, the digest H0 is set to a fixed value, normally called IV (initial
value or initial vector).
4. The compression function at each iteration operates on H i−1 and Mi to create a new Hi.
Hi = ƒ(Hi−1, Mi), where ƒ is the compression function.
5. Ht is the cryptographic hash function of the original message, that is, h(M).
.
If the compression function in the Merkle-Damgard scheme is
collision resistant, the hash function is also collision resistant.
.
Two Groups of Compression Functions
Merkle-Damgard scheme is the basis for many cryptographic hash functions today.
.
Hash Functions Made from Scratch
A set of cryptographic hash functions uses compression functions that are made from
scratch.
These compression functions are specifically designed for the purposes they serve.
.
Secure Hash Algorithm (SHA)
The Secure Hash Algorithm (SHA) is a standard that was developed by the National
Institute of Standards and Technology (NIST).
It is sometimes referred to as Secure Hash Standard (SHS).
The standard is mostly based on MD5.
The standard was revised in 1995, which includes SHA-1.
It was revised later, which defines 4 new versions: SHA-224, SHA-256, SHA-384, and
SHA-512.
.
Other Algorithms
RACE Integrity Primitives Evaluation Message Digest (RIPMED) has several
versions.
RIPEMD-160 is a hash algorithm with a 160-bit message digest.
RIPEMD-160 uses the same structure as MD5 but uses two parallel lines of
execution.
HAVAL is a variable-length hashing algorithm with a message digest of size 128,
160, 192, 224, and 256.The block size is 1024 bits.
.
Hash Functions Based on Block Ciphers
An iterated cryptographic hash function can use a symmetric-key block cipher
as a compression function.
There are several secure symmetric-key block ciphers, such as triple DES or
AES, that can be used to make a one-way function.
.
Rabin Scheme
The iterated hash function proposed by Rabin is very simple.
The digest is the size of data block cipher in the underlying cryptosystem.
For example, if DES is used as the block cipher, the size of the digest is only 64
bits.
.
Rabin Scheme
.
Davies-Meyer Scheme
.
Matyas-Meyer-Oseas Scheme
The scheme can be used if the data block and the cipher key are the same
size.
.
Miyaguchi-Preneel Scheme
To make the algorithm stronger against attack, the plaintext, the cipher key,
and the ciphertext are all exclusive-ored together to create the new digest.
.
12.2 SHA-512
it is the latest version, it has a more complex structure than the others, and its
message digest is the longest.
.
12.2 SHA-512
.
12.2 SHA-512
SHA-512 creates a digest of 512 bits from a multiple-block message.
.
12.2 SHA-512
The algorithm mixes this initial value with the first block of the message to
create the first intermediate message digest of 512 bits.
This digest is then mixed with the second block to create the second
intermediate digest.
Finally, the (N − 1)th digest is mixed with the Nth block to create the Nth digest.
.
12.2 SHA-512
Message Preparation
SHA-512 insists that the length of the original message be less than 2128 bits.
This means that if the length of a message is equal to or greater than 2 128, it
will not be processed by SHA-512.
This is not usually a problem because 2128 bits is probably larger than the
total storage capacity of any system.
.
12.2 SHA-512
Message Preparation
128
SHA-512 creates a 512-bit message digest out of a message less than 2 .
.
12.2 SHA-512
Length Field and Padding
Before the message digest can be created, SHA-512 requires the addition of a
128-bit unsigned-integer length field to the message that defines the length of the
message in bits.
An unsigned integer field of 128 bits can define a number between 0 and 2128 − 1,
which is the maximum length of the message allowed in SHA-512.
The length field defines the length of the original message before adding the length field
or the padding (Figure 12.7).
.
12.2 SHA-512
Length Field and Padding
.
12.2 SHA-512
Length Field and Padding
Before the addition of the length field, we need to pad the original message
to make the length a multiple of 1024.
Let |M| be the length of the original message and |P| be the length of the
padding field.
The format of the padding is one 1 followed by the necessary number of 0s.
.
12.2 SHA-512
Length Field and Padding
What is the number of padding bits if the length of the original message is 2590
bits?
Solution
.
12.2 SHA-512
Length Field and Padding
Example 12.4
Do we need padding if the length of the original message is already a multiple
of 1024 bits?
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.2 SHA-512
Example 12.5
What is the minimum and maximum number of padding bits that can be added to a
message?
Solution
a. The minimum length of padding is 0 and it happens when (−M − 128) mod 1024 is 0.
This means that |M| = −128 mod 1024 = 896 mod 1024 bits. In other words, the last
block in the original message is 896 bits. We add a 128-bit length field to make the
block complete.
b. The maximum length of padding is 1023 and it happens when (−|M| −128) = 1023
mod 1024. This means that the length of the original message is |M| = (−128 −1023)
mod 1024 or the length is |M| = 897 mod 1024. In this case, we cannot just add the
length field because the length of the last block exceeds one bit more than 1024. So
we need to add 897 bits to complete this block and create a second block of 896 bits.
Now the length can be added to make this block complete.
.
12.2 SHA-512
Words
SHA-512 operates on words; A word is defined as 64 bits.
After the padding and the length field are added to the message, each block of
the message consists of sixteen 64-bit words.
Message digest is also made of 64-bit words, but the message digest is only
eight words and the words are named A, B, C, D, E, F, G, and H.
.
12.2 SHA-512
Words
16*64=1024
8*64=512
.
12.2 SHA-512
Word Expansion
.
12.2 SHA-512
Word Expansion
The 1024-bit block becomes the first 16 words;
The rest of the words come from already-made words according to the operation
shown in the figure.
.
12.2 SHA-512
Example 12.6
Show how W60 is made.
Solution
.
12.2 SHA-512
Call these constants A0 to H0 to match with the word naming used for the digest.
.
12.2 SHA-512
Values are calculated from the first 8 prime numbers (2, 3, 5, 7, 11, 13, 17, and 19).
Each value is the fraction part of the square root of the corresponding prime
number after converting to binary and keeping only the first 64 bits.
For example, the eighth prime is 19, with the square root (19)1/2 = 4.35889894354.
Converting the number to binary with only 64 bits in the fraction part, we get
.
12.2 SHA-512
Compression Function
SHA-512 creates a 512-bit (eight 64-bit words) message digest from a multiple-
block message where each block is 1024 bits.
Figure 12.10 shows the general outline for the compression function.
.
12.2 SHA-512 In each round, the contents of eight
previous buffers, one word from the
Compression Function expanded block (Wi), and one 64-
bit constant (Ki) are mixed together
and then operated on to create a
new set of eight buffers.
.
Structure of Each Round
In each round, eight new values for the 64-bit buffers are created from the
values of the buffers in the previous round.
As Figure 12.11 shows, six buffers are the exact copies of one of the buffers
in the previous round as shown below:
.
Structure of Each Round
Two of the new buffers, A and E, receive their inputs from some complex
functions that involve some of the previous buffers, the corresponding word for
this round (Wi), and the corresponding constant for this round (Ki).
.
Structure of Each Round
Figure 12.11 shows the structure of each round.
.
Structure of Each Round
Figure 12.11 shows the structure of each round.
.
Structure of Each Round
.
Structure of Each Round
.
Structure of Each Round
.
Structure of Each Round
Each value is the fraction part of the cubic root of the corresponding prime
number after converting it to binary and keeping only the first 64 bits.
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
(111.0110 1100 0100 0100 . . . 0111)2 → (7.6C44198C4A475817)16
.
Structure of Each Round
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. We can also prove it using the
definition of the Majority function:
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. Since E1 = 1, the result is F1, which is 1. We
can also use the definition of the Condition function to prove the result:
b. The second bits are 0, 0, and 1. Since E2 is 0, the result is G2, which is 1.
c. The third bits are 0, 1, and 1. Since E3 is 0, the result is G3, which is 1.
d. The fourth bits are 1, 0, and 1. Since E4 is 1, the result is F4, which is 0.
The result is 1110, or 0xE in hexadecimal.
.
12.3 WHIRLPOOL
Block cipher is a modified AES cipher that has been tailored for this purpose.
.
12.3 WHIRLPOOL
.
12.3 WHIRLPOOL
Preparation
Whirlpool requires that the length of the original message be less than 2256
bits.
After padding, a block of 256 bits is added to define the length of the original
message.
After padding and adding the length field, the augmented message size is an
even multiple of 256 bits or a multiple of 512 bits.
.
12.3 WHIRLPOOL
Whirlpool creates a digest of 512 bits from a multiple 512-bit block message.
This value becomes the cipher key for encrypting the first block.
The ciphertext resulting from encrypting each block becomes the cipher key for the
next block after being exclusive-ored with the previous cipher key and the plaintext
block.
Message digest is the final 512-bit ciphertext after the last exclusive-or operation.
.
Whirlpool Cipher
Here the Whirlpool cipher is compared with the AES cipher and their differences
are mentioned.
Rounds
Whirlpool is a round cipher that uses 10 rounds.
.
Figure 12.13 General idea of the Whirlpool cipher
.
States and Blocks
Like the AES cipher, the Whirlpool cipher uses states and blocks.
.
Figure 12.14 Block and state in the Whirlpool cipher
Unlike AES, the block-to-state or stateto- block transformation is done row by row.
.
Structure of Each Round
Figure 12.15 shows the structure of each round. Each round uses four
transformations.
.
SubBytes Like in AES, SubBytes provide a nonlinear transformation.
Left digit defines the row and right digit defines the column of the substitution
table.
Two hexadecimal digits at the junction of the row and the column are the new
byte.
.
In the SubBytes transformation, the state is treated as an 8 × 8 matrix of bytes.
The contents of each byte are changed, but the arrangement of the bytes in
the matrix remains the same.
Table 12.4 shows the substitution table (S-Box) for SubBytes transformation.
.
For example, two bytes, 5A16 and 5B16, which differ only in one bit (the rightmost bit), are
transformed to 5B16 and 8816, which differ in five bits.
.
ShiftColumns
Column 0 goes through 0-byte shifting (no shifting), while column 7 goes
through 7-byte shifting.
.
MixRows
Multiplication of bytes is done in GF(28), but the modulus is different from the
one used in AES.
.
Figure 12.19 MixRows transformation in the Whirlpool cipher
.
AddRoundKey
A byte from the data state is added, in GF(28) field, to the corresponding byte in
the round-key state.
.
Key Expansion
Key-expansion algorithm in Whirlpool is totally different from the algorithm in
AES.
Instead of using a new algorithm for creating round keys, Whirlpool uses a copy of the
encryption algorithm (without the pre-round) to create the round keys.
The output of each round in the encryption algorithm is the round key for that round.
Whirlpool uses ten round constants (RCs) as the virtual round keys for the keyexpansion
algorithm.
In other words, the key-expansion algorithm uses constants as the round keys and the
encryption algorithm uses the output of each round of the keyexpansion algorithm as the
round keys.
The key-generation algorithm treats the cipher key as the plaintext and encrypts it.
Note that the cipher key is also K0 for the encryption algorithm
.
.
Round Constants Each round constant, RCr is an 8 × 8 matrix where only the first row has
non-zero values.
The values for the first row in each constant matrix can be calculated using the SubBytes
transformation (Table 12.4).
.
In other words, RC1 uses the first eight entries in the SubBytes transformation table
[Table 12.4]; RC2 uses the second eight entries, and so on.
For example, Figure 12.22 shows RC3, where the first row is the third eight entries in
the SubBytes table.
.
Summary
Table 12.5 summarizes some characteristics of the Whirlpool cipher.
.
Analysis
Although Whirlpool has not been extensively studied or tested, it is based on
a robust scheme (Miyaguchi-Preneel), and for a compression function uses a
cipher that is based on AES, a cryptosystem that has been proved very
resistant to attacks.
In addition, the size of the message digest is the same as for SHA-512.
.
END