mirror of
https://github.com/fumiama/blake2b-simd.git
synced 2026-06-13 15:01:03 +08:00
Move message loop into assembly (#3)
This commit is contained in:
@@ -20,10 +20,9 @@
|
||||
package blake2b
|
||||
|
||||
//go:noescape
|
||||
func blockAVX(p []uint8, in, iv, t, f, shffle, out []uint64)
|
||||
func blockAVXLoop(p []uint8, in, iv, t, f, shffle, out []uint64)
|
||||
|
||||
func compressAVX(d *digest, p []uint8) {
|
||||
h0, h1, h2, h3, h4, h5, h6, h7 := d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7]
|
||||
|
||||
in := make([]uint64, 8, 8)
|
||||
out := make([]uint64, 8, 8)
|
||||
@@ -33,23 +32,11 @@ func compressAVX(d *digest, p []uint8) {
|
||||
shffle[0] = 0x0201000706050403
|
||||
shffle[1] = 0x0a09080f0e0d0c0b
|
||||
|
||||
for len(p) >= BlockSize {
|
||||
// Increment counter.
|
||||
d.t[0] += BlockSize
|
||||
if d.t[0] < BlockSize {
|
||||
d.t[1]++
|
||||
}
|
||||
in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] = d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7]
|
||||
|
||||
in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] = h0, h1, h2, h3, h4, h5, h6, h7
|
||||
blockAVXLoop(p, in, iv[:], d.t[:], d.f[:], shffle, out)
|
||||
|
||||
blockAVX(p, in, iv[:], d.t[:], d.f[:], shffle, out)
|
||||
|
||||
h0, h1, h2, h3, h4, h5, h6, h7 = out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]
|
||||
|
||||
p = p[BlockSize:]
|
||||
}
|
||||
|
||||
d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7] = h0, h1, h2, h3, h4, h5, h6, h7
|
||||
d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7] = out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]
|
||||
}
|
||||
|
||||
func compress(d *digest, p []uint8) {
|
||||
|
||||
Reference in New Issue
Block a user