mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 04:36:19 +08:00
sm3: add copyResultsBy4 test case
This commit is contained in:
parent
664f5dcae3
commit
7a84c6fd29
@ -7,6 +7,7 @@
|
|||||||
package sm3
|
package sm3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -76,6 +77,28 @@ func TestBlockMultBy4(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCopyResultsBy4(t *testing.T) {
|
||||||
|
var m [4][8]uint32
|
||||||
|
var ret, expected [128]byte
|
||||||
|
var k uint32 = 0
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
for j := 0; j < 8; j++ {
|
||||||
|
m[i][j] = k
|
||||||
|
k++
|
||||||
|
fmt.Printf("%08x ", m[i][j])
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
copyResultsBy4(&m[0][0], &ret[0])
|
||||||
|
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
for j := 0; j < 8; j++ {
|
||||||
|
binary.BigEndian.PutUint32(expected[i*32+j*4:], m[i][j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Errorf("got %x, expected %x\n", ret[:], expected[:])
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkOneBlockBy4(b *testing.B) {
|
func BenchmarkOneBlockBy4(b *testing.B) {
|
||||||
digs := initState4()
|
digs := initState4()
|
||||||
p := createOneBlockBy4()
|
p := createOneBlockBy4()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user