0 2

BIT303 ยท 0 ยท 10 marks

SHA-1 Hash Function Properties and Computation What are properties of hash function? In a hash function SHA-1, how padded message is computed before hash function computation? Using elongated message blocks from w0 to w79 how can you compute the final hash value? For the 160 bit hash value represent

SHA-1 Hash Function Properties and Computation

What are properties of hash function? In a hash function SHA-1, how padded message is computed before hash function computation? Using elongated message blocks from $w_0$ to $w_{79}$ how can you compute the final hash value? For the 160 bit hash value represented by 5 words A, B, C, D, E, write the expressions for $A_{79}$, $B_{79}$, $C_{79}$ after the last pass of the algorithm?[10]

Information SecurityChapter 5: Hash Functions and Message AuthenticationSHA-1 algorithm and paddingNumerical: SHA-1 hash computation

SHA-1: Properties, Padding, and Hash Computation

Given

  • Hash algorithm: SHA-1
  • Output size: 160-bit hash, represented as five 32-bit words $A, B, C, D, E$
  • Message schedule words: $w_0$ to $w_{79}$ (80 words)
  • Required: properties of hash functions, padding procedure, hash computation, and expressions for $A_{79}, B_{79}, C_{79}$ after the last pass.

No numeric message is provided; the answer is derived from the standard SHA-1 specification.


Solution

1. Properties of a Hash Function

PropertyDescription
CompressionMaps arbitrary-length input to a fixed-length output (160 bits for SHA-1)
Ease of computation$H(x)$ is fast and easy to compute for any $x$
Pre-image resistanceGiven $h$, infeasible to find $x$ with $H(x)=h$ (one-way)
Second pre-image resistanceGiven $x$, infeasible to find $x'\ne x$ with $H(x')=H(x)$ (weak collision)
Collision resistanceInfeasible to find any $x\ne x'$ with $H(x)=H(x')$ (strong collision)
Avalanche effectA tiny input change flips ~half the output bits
DeterministicSame input always gives the same digest

2. Padded Message Computation in SHA-1

SHA-1 works on 512-bit blocks. For a message $M$ of length $L$ bits:

  1. Append a single 1 bit.
  2. Append k zero bits, where $k$ is the smallest non-negative integer with $$L + 1 + k \equiv 448 \pmod{512}$$
  3. Append the original length $L$ as a 64-bit big-endian integer.

The result is a total length that is a multiple of 512: $$\text{Padded length} = N \times 512 \text{ bits}, \quad N \ge 1$$

Example (M = "abc", $L = 24$): append 1 โ†’ 25 bits, append 423 zeros โ†’ 448 bits, append 64-bit length 24 โ†’ 512 bits.


3. Computing the Final Hash Value ($w_0 \dots w_{79}$)

Initial hash values: $$H_0=\texttt{67452301},\ H_1=\texttt{EFCDAB89},\ H_2=\texttt{98BADCFE},\ H_3=\texttt{10325476},\ H_4=\texttt{C3D2E1F0}$$

Message schedule expansion: the block gives $w_0 \dots w_{15}$; the rest are: $$w_t = \text{ROTL}^{1}(w_{t-3}\oplus w_{t-8}\oplus w_{t-14}\oplus w_{t-16}), \quad 16 \le t \le 79$$

Round constants $K_t$ and functions $f_t(B,C,D)$:

$t$$K_t$$f_t(B,C,D)$
0-195A827999$(B\wedge C)\vee(\neg B\wedge D)$
20-396ED9EBA1$B\oplus C\oplus D$
40-598F1BBCDC$(B\wedge C)\vee(B\wedge D)\vee(C\wedge D)$
60-79CA62C1D6$B\oplus C\oplus D$

Compression loop. Initialize: $$A=H_0,\ B=H_1,\ C=H_2,\ D=H_3,\ E=H_4$$

For $t = 0$ to $79$: $$T = \text{ROTL}^{5}(A) + f_t(B,C,D) + E + w_t + K_t \pmod{2^{32}}$$ $$E=D,\quad D=C,\quad C=\text{ROTL}^{30}(B),\quad B=A,\quad A=T$$

After all 80 rounds, update: $$H_0{+}{=}A,\ H_1{+}{=}B,\ H_2{+}{=}C,\ H_3{+}{=}D,\ H_4{+}{=}E$$

Final digest: $$\text{Hash}=H_0,|,H_1,|,H_2,|,H_3,|,H_4 \quad (160 \text{ bits})$$


4. Expressions for $A_{79}, B_{79}, C_{79}$ (after the last pass, $t=79$)

Let subscript $t$ denote the value after round $t$ (so $A_{78},B_{78},\dots$ are the values entering round 79). The update rules give:

$A_{79}$ (the new $A = T$ using round-79 inputs): $$\boxed{A_{79} = \text{ROTL}^{5}(A_{78}) + f_{79}(B_{78},C_{78},D_{78}) + E_{78} + w_{79} + K_{79}}$$ with $f_{79}=B_{78}\oplus C_{78}\oplus D_{78}$ and $K_{79}=\texttt{CA62C1D6}$.

$B_{79}$ (new $B$ = old $A$): $$\boxed{B_{79} = A_{78}}$$

$C_{79}$ (new $C$ = ROTL$^{30}$ of old $B$): $$\boxed{C_{79} = \text{ROTL}^{30}(B_{78})}$$

(For completeness: $D_{79}=C_{78}$, $E_{79}=D_{78}$.)

These $A_{79},\dots,E_{79}$ are then added to the initial $H_0,\dots,H_4$ to form the block's contribution to the final hash.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.