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.
6 // In its own file so that a faster assembly or C version
7 // can be substituted easily.
11 var shift1 = []uint{3, 7, 11, 19}
12 var shift2 = []uint{3, 5, 9, 13}
13 var shift3 = []uint{3, 9, 11, 15}
15 var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}
16 var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
18 func _Block(dig *digest, p []byte) int {
25 for len(p) >= _Chunk {
26 aa, bb, cc, dd := a, b, c, d
29 for i := 0; i < 16; i++ {
30 X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24
34 // If this needs to be made faster in the future,
35 // the usual trick is to unroll each of these
36 // loops by a factor of 4; that lets you replace
37 // the shift[] lookups with constants and,
38 // with suitable variable renaming in each
39 // unrolled body, delete the a, b, c, d = d, a, b, c
40 // (or you can let the optimizer do the renaming).
42 // The index variables are uint so that % by a power
43 // of two can be optimized easily by a compiler.
46 for i := uint(0); i < 16; i++ {
49 f := ((c ^ d) & b) ^ d
52 a, b, c, d = d, a, b, c
56 for i := uint(0); i < 16; i++ {
59 g := (b & c) | (b & d) | (c & d)
60 a += g + X[x] + 0x5a827999
62 a, b, c, d = d, a, b, c
66 for i := uint(0); i < 16; i++ {
70 a += h + X[x] + 0x6ed9eba1
72 a, b, c, d = d, a, b, c