init: v1.0.0

This commit is contained in:
yaole
2026-05-27 23:03:00 +08:00
commit 8d97f750eb
466 changed files with 80067 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
//go:build amd64
// +build amd64
package sm4
import (
"encoding/hex"
"fmt"
"testing"
)
func TestAesni(t *testing.T) {
key, _ := hex.DecodeString("AF07B5BDDF77A3727E9E5FEC48DA1D9E")
// test 4 blocks for aesni
src, _ := hex.DecodeString(
"B358A63B7587FCCB46CD41FFE778D5C1" +
"B358A63B7587FCCB46CD41FFE778D5C1" +
"B358A63B7587FCCB46CD41FFE778D5C1" +
"B358A63B7587FCCB46CD41FFE778D5C1",
)
dst := make([]byte, len(src))
encKey := make([]uint32, 32)
decKey := make([]uint32, 32)
expandKey(key, encKey, decKey)
encrypt4(dst, src, encKey)
// dst = 6845268B 91394C00 6648E71A 2D6D68C1 * 4
for i := 0; i < 64; i++ {
fmt.Printf("%02x ", dst[i])
if i > 0 && (i+1)%16 == 0 {
fmt.Println()
}
}
}