1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 // In its own file so that a faster assembly or C version
9 // can be substituted easily.
80 func block(dig
*digest
, p
[]byte) {
82 h0
, h1
, h2
, h3
, h4
, h5
, h6
, h7
:= dig
.h
[0], dig
.h
[1], dig
.h
[2], dig
.h
[3], dig
.h
[4], dig
.h
[5], dig
.h
[6], dig
.h
[7]
84 // Can interlace the computation of w with the
85 // rounds below if needed for speed.
86 for i
:= 0; i
< 16; i
++ {
88 w
[i
] = uint32(p
[j
])<<24 |
uint32(p
[j
+1])<<16 |
uint32(p
[j
+2])<<8 |
uint32(p
[j
+3])
90 for i
:= 16; i
< 64; i
++ {
92 t1
:= (v1
>>17 | v1
<<(32-17)) ^ (v1
>>19 | v1
<<(32-19)) ^ (v1
>> 10)
94 t2
:= (v2
>>7 | v2
<<(32-7)) ^ (v2
>>18 | v2
<<(32-18)) ^ (v2
>> 3)
95 w
[i
] = t1
+ w
[i
-7] + t2
+ w
[i
-16]
98 a
, b
, c
, d
, e
, f
, g
, h
:= h0
, h1
, h2
, h3
, h4
, h5
, h6
, h7
100 for i
:= 0; i
< 64; i
++ {
101 t1
:= h
+ ((e
>>6 | e
<<(32-6)) ^ (e
>>11 | e
<<(32-11)) ^ (e
>>25 | e
<<(32-25))) + ((e
& f
) ^ (^e
& g
)) + _K
[i
] + w
[i
]
103 t2
:= ((a
>>2 | a
<<(32-2)) ^ (a
>>13 | a
<<(32-13)) ^ (a
>>22 | a
<<(32-22))) + ((a
& b
) ^ (a
& c
) ^ (b
& c
))
127 dig
.h
[0], dig
.h
[1], dig
.h
[2], dig
.h
[3], dig
.h
[4], dig
.h
[5], dig
.h
[6], dig
.h
[7] = h0
, h1
, h2
, h3
, h4
, h5
, h6
, h7