INNER CODE UNIT · Go

TestCBCMACWithPadding

emmansun/gmsm · cbcmac/cbcmac_test.go:53

func TestCBCMACWithPadding(t *testing.T) {
	// Test vectors from GB/T 15821.1-2020 Appendix B.
	cases := []struct {
		key            []byte
		src            []byte
		tag            []byte
		newPaddingFunc padding.NewPaddingFunc
	}{
		{
			[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
			nil,
			[]byte{0x8c, 0x33, 0x8e, 0x5a, 0x27, 0xe3, 0x49, 0xbe, 0xae, 0x39, 0x21, 0x4f, 0xed, 0xa9, 0x70, 0x99},
			padding.NewISO9797M2Padding,
		},
		{
			[]byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
			[]byte("This is the test message for mac"),
			[]byte{0x4b, 0x65, 0x53, 0xaf, 0x3c, 0x4e, 0x27, 0x44, 0x84, 0x12, 0x31, 0x5a, 0xc7, 0x84, 0x95, 0x35},

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…