2 * SHA core transform algorithm, used here solely as a `stirring'
3 * function for the PuTTY random number pool. Implemented directly
4 * from the specification by Simon Tatham.
9 #define rol(x,y) ( ((x) << (y)) | (((word32)x) >> (32-y)) )
11 void SHATransform(word32
*digest
, word32
*block
) {
16 for (t
= 0; t
< 16; t
++)
19 for (t
= 16; t
< 80; t
++) {
20 word32 tmp
= w
[t
-3] ^ w
[t
-8] ^ w
[t
-14] ^ w
[t
-16];
30 for (t
= 0; t
< 20; t
++) {
31 word32 tmp
= rol(a
, 5) + ( (b
&c
) | (d
&~b
) ) + e
+ w
[t
] + 0x5a827999;
32 e
= d
; d
= c
; c
= rol(b
, 30); b
= a
; a
= tmp
;
34 for (t
= 20; t
< 40; t
++) {
35 word32 tmp
= rol(a
, 5) + (b
^c
^d
) + e
+ w
[t
] + 0x6ed9eba1;
36 e
= d
; d
= c
; c
= rol(b
, 30); b
= a
; a
= tmp
;
38 for (t
= 40; t
< 60; t
++) {
39 word32 tmp
= rol(a
, 5) + ( (b
&c
) | (b
&d
) | (c
&d
) ) + e
+ w
[t
] + 0x8f1bbcdc;
40 e
= d
; d
= c
; c
= rol(b
, 30); b
= a
; a
= tmp
;
42 for (t
= 60; t
< 80; t
++) {
43 word32 tmp
= rol(a
, 5) + (b
^c
^d
) + e
+ w
[t
] + 0xca62c1d6;
44 e
= d
; d
= c
; c
= rol(b
, 30); b
= a
; a
= tmp
;