Update blake2b_generic.go

This commit is contained in:
marukai67 2025-12-21 17:49:04 +01:00 committed by GitHub
parent 2e5cd21edf
commit 8072451f67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,10 +4,7 @@
package blake2b
import (
"encoding/binary"
"math/bits"
)
import "math/bits"
// the precomputed values for BLAKE2b
// there are 10 16-byte arrays - one for each round
@ -25,25 +22,6 @@ var precomputed = [10][16]byte{
{10, 8, 7, 1, 2, 4, 6, 5, 15, 9, 3, 13, 11, 14, 12, 0},
}
// nolint:unused
func hashBlocksGeneric(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) {
var m [16]uint64
c0, c1 := c[0], c[1]
for i := 0; i < len(blocks); {
c0 += BlockSize
if c0 < BlockSize {
c1++
}
for j := range m {
m[j] = binary.LittleEndian.Uint64(blocks[i:])
i += 8
}
fGeneric(h, &m, c0, c1, flag, 12)
}
c[0], c[1] = c0, c1
}
func fGeneric(h *[8]uint64, m *[16]uint64, c0, c1 uint64, flag uint64, rounds uint64) {
v0, v1, v2, v3, v4, v5, v6, v7 := h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7]
v8, v9, v10, v11, v12, v13, v14, v15 := iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7]