Cryptography Reference
In-Depth Information
for ( t = 0; t < 80; t++ )
{
T = ( ( a << 5 ) | ( a >> 27 ) ) + e + k[ ( t / 20 ) ] + W[ t ];
if ( t <= 19 )
{
T += ch( b, c, d );
}
else if ( t <= 39 )
{
T += parity( b, c, d );
}
else if ( t <= 59 )
{
T += maj( b, c, d );
}
else
{
T += parity( b, c, d );
}
e = d;
d = c;
c = ( ( b << 30 ) | ( b >> 2 ) );
b = a;
a = T;
}
hash[ 0 ] += a;
hash[ 1 ] += b;
hash[ 2 ] += c;
hash[ 3 ] += d;
hash[ 4 ] += e;
}
Regarding Listing 4-8:
1. The constants k are defi ned — one for each set of 20 rounds.
2. The functions ch , maj , and parity are defi ned: ch for rounds 0-19, maj
for rounds 40-59, and parity for the remaining rounds. Like MD5's
F, G, H, and I, these four functions just shuffl e the bits of their input
randomly.
3. The block operation function computes the W array. Notice that you're
using unsigned int s here, rather than four-byte blocks, so you have to
be careful to account for endian-ness as usual. The benefi t is that you
only have to keep track of this transformation once, at the beginning of
the computation, and from that point you can use native operations on
a 32-bit architecture.
Search WWH ::




Custom Search