mirror of
https://github.com/emmansun/gmsm.git
synced 2025-05-14 04:56:21 +08:00
kdf-sm3: optimize arm64
This commit is contained in:
parent
a81432fbf8
commit
7c832f65e7
@ -197,7 +197,9 @@ TEXT ·blockMultBy4(SB), NOSPLIT, $0
|
|||||||
MOVD (srcPtrPtr), srcPtr4
|
MOVD (srcPtrPtr), srcPtr4
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
// reset wordPtr
|
||||||
MOVD wordStart, wordPtr
|
MOVD wordStart, wordPtr
|
||||||
|
|
||||||
// load message block
|
// load message block
|
||||||
prepare4Words
|
prepare4Words
|
||||||
prepare4Words
|
prepare4Words
|
||||||
@ -271,9 +273,8 @@ loop:
|
|||||||
ROUND_16_63(62, T30, c, d, e, f, g, h, a, b)
|
ROUND_16_63(62, T30, c, d, e, f, g, h, a, b)
|
||||||
ROUND_16_63(63, T31, b, c, d, e, f, g, h, a)
|
ROUND_16_63(63, T31, b, c, d, e, f, g, h, a)
|
||||||
|
|
||||||
MOVD statePtr, R20
|
VLD1.P 64(statePtr), [V8.S4, V9.S4, V10.S4, V11.S4]
|
||||||
VLD1.P 64(R20), [V8.S4, V9.S4, V10.S4, V11.S4]
|
VLD1 (statePtr), [V12.S4, V13.S4, V14.S4, V15.S4]
|
||||||
VLD1 (R20), [V12.S4, V13.S4, V14.S4, V15.S4]
|
|
||||||
VEOR a.B16, V8.B16, a.B16
|
VEOR a.B16, V8.B16, a.B16
|
||||||
VEOR b.B16, V9.B16, b.B16
|
VEOR b.B16, V9.B16, b.B16
|
||||||
VEOR c.B16, V10.B16, c.B16
|
VEOR c.B16, V10.B16, c.B16
|
||||||
@ -282,9 +283,8 @@ loop:
|
|||||||
VEOR f.B16, V13.B16, f.B16
|
VEOR f.B16, V13.B16, f.B16
|
||||||
VEOR g.B16, V14.B16, g.B16
|
VEOR g.B16, V14.B16, g.B16
|
||||||
VEOR h.B16, V15.B16, h.B16
|
VEOR h.B16, V15.B16, h.B16
|
||||||
MOVD statePtr, R20
|
VST1.P [e.S4, f.S4, g.S4, h.S4], -64(statePtr)
|
||||||
VST1.P [a.S4, b.S4, c.S4, d.S4], 64(R20)
|
VST1 [a.S4, b.S4, c.S4, d.S4], (statePtr)
|
||||||
VST1 [e.S4, f.S4, g.S4, h.S4], (R20)
|
|
||||||
|
|
||||||
SUB $1, blockCount
|
SUB $1, blockCount
|
||||||
CBNZ blockCount, loop
|
CBNZ blockCount, loop
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
package sm3
|
package sm3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -54,13 +53,6 @@ func TestBlockMultBy4(t *testing.T) {
|
|||||||
buffer := make([]byte, preallocSize)
|
buffer := make([]byte, preallocSize)
|
||||||
blockMultBy4(&digs[0], &p[0], &buffer[0], 1)
|
blockMultBy4(&digs[0], &p[0], &buffer[0], 1)
|
||||||
expected := "[66c7f0f4 62eeedd9 d1f2d46b dc10e4e2 4167c487 5cf2f7a2 297da02b 8f4ba8e0]"
|
expected := "[66c7f0f4 62eeedd9 d1f2d46b dc10e4e2 4167c487 5cf2f7a2 297da02b 8f4ba8e0]"
|
||||||
for i := 0; i < 128+68*4*4; i += 64 {
|
|
||||||
fmt.Printf("%08x %08x %08x %08x ", binary.LittleEndian.Uint32(buffer[i:]), binary.LittleEndian.Uint32(buffer[i+4:]), binary.LittleEndian.Uint32(buffer[i+8:]), binary.LittleEndian.Uint32(buffer[i+12:]))
|
|
||||||
fmt.Printf("%08x %08x %08x %08x ", binary.LittleEndian.Uint32(buffer[i+16:]), binary.LittleEndian.Uint32(buffer[i+20:]), binary.LittleEndian.Uint32(buffer[i+24:]), binary.LittleEndian.Uint32(buffer[i+28:]))
|
|
||||||
fmt.Printf("%08x %08x %08x %08x ", binary.LittleEndian.Uint32(buffer[i+32:]), binary.LittleEndian.Uint32(buffer[i+36:]), binary.LittleEndian.Uint32(buffer[i+40:]), binary.LittleEndian.Uint32(buffer[i+44:]))
|
|
||||||
fmt.Printf("%08x %08x %08x %08x ", binary.LittleEndian.Uint32(buffer[i+48:]), binary.LittleEndian.Uint32(buffer[i+52:]), binary.LittleEndian.Uint32(buffer[i+56:]), binary.LittleEndian.Uint32(buffer[i+60:]))
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
s := fmt.Sprintf("%x", digs[0][:])
|
s := fmt.Sprintf("%x", digs[0][:])
|
||||||
if s != expected {
|
if s != expected {
|
||||||
t.Errorf("digs[0] got %s", s)
|
t.Errorf("digs[0] got %s", s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user