mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-25 19:56:18 +08:00
MAGIC - optimize sm3
This commit is contained in:
parent
798dbe465e
commit
1ed21cbbfc
@ -38,7 +38,6 @@ func gg(j uint8, x, y, z uint32) uint32 {
|
||||
|
||||
func block(dig *digest, p []byte) {
|
||||
var w [68]uint32
|
||||
var w1 [64]uint32
|
||||
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]
|
||||
for len(p) >= chunk {
|
||||
for i := 0; i < 16; i++ {
|
||||
@ -48,14 +47,11 @@ func block(dig *digest, p []byte) {
|
||||
for i := 16; i < 68; i++ {
|
||||
w[i] = p1(w[i-16]^w[i-9]^bits.RotateLeft32(w[i-3], 15)) ^ bits.RotateLeft32(w[i-13], 7) ^ w[i-6]
|
||||
}
|
||||
for i := 0; i < 64; i++ {
|
||||
w1[i] = w[i] ^ w[i+4]
|
||||
}
|
||||
a, b, c, d, e, f, g, h := h0, h1, h2, h3, h4, h5, h6, h7
|
||||
for i := 0; i < 64; i++ {
|
||||
ss1 := bits.RotateLeft32(bits.RotateLeft32(a, 12)+e+bits.RotateLeft32(t(uint8(i)), i), 7)
|
||||
ss2 := ss1 ^ bits.RotateLeft32(a, 12)
|
||||
tt1 := ff(uint8(i), a, b, c) + d + ss2 + w1[i]
|
||||
tt1 := ff(uint8(i), a, b, c) + d + ss2 + (w[i] ^ w[i+4])
|
||||
tt2 := gg(uint8(i), e, f, g) + h + ss1 + w[i]
|
||||
d = c
|
||||
c = bits.RotateLeft32(b, 9)
|
||||
|
Loading…
x
Reference in New Issue
Block a user