add complete test case

This commit is contained in:
emmansun 2022-01-02 21:12:46 +08:00
parent ebc3bf5da6
commit 09414993cc

View File

@ -94,7 +94,7 @@ amd64 result = {
8F F3 05 10 EA 99 A8 D7 41 D9 E3 BA 67 D6 18 EE
}
arm64 result = {
8F F3 05 10 EA 99 A8 D7 41 D9 E3 BA 67 D6 18 EE
}
*/
func TestGcmSm4Finish(t *testing.T) {
@ -108,3 +108,27 @@ func TestGcmSm4Finish(t *testing.T) {
}
fmt.Println()
}
func TestBothDataPlaintext(t *testing.T) {
g := genPrecomputeTable()
var tagOut, tagMask [gcmBlockSize]byte
data := []byte("emmansun")
gcmSm4Data(&g.bytesProductTable, data, &tagOut)
for j := 0; j < 16; j++ {
tagMask[j] = byte(j)
}
for j := 0; j < 16; j++ {
fmt.Printf("%02X ", tagOut[j])
}
fmt.Println()
gcmSm4Data(&g.bytesProductTable, []byte("emmansunemmansunemmansunemmansun"), &tagOut)
for j := 0; j < 16; j++ {
fmt.Printf("%02X ", tagOut[j])
}
fmt.Println()
gcmSm4Finish(&g.bytesProductTable, &tagMask, &tagOut, uint64(32), uint64(8))
for j := 0; j < 16; j++ {
fmt.Printf("%02X ", tagOut[j])
}
fmt.Println()
}