From 23fdca4d319fdba488f70cb4c19687f13be9c5be Mon Sep 17 00:00:00 2001 From: Pavel Gabriel Date: Mon, 4 Mar 2024 16:44:01 +0100 Subject: [PATCH] use slice with proper length (a multiple of a block size) --- pkg/des/des.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/des/des.go b/pkg/des/des.go index 142ea80..1d07bd6 100644 --- a/pkg/des/des.go +++ b/pkg/des/des.go @@ -226,7 +226,7 @@ func GenerateMac(currentKey []byte, plainText, action string) ([]byte, error) { initialVector := make([]byte, desBlockLen) leftCipher, _ := encryption.NewDesECB(leftKey) for partNum := 0; partNum < repeatCnt; partNum++ { - macPart := plainTextBytes[partNum*desBlockLen : (partNum+1)*desBlockLen] + macPart := serializePlaintext[partNum*desBlockLen : (partNum+1)*desBlockLen] for in := range initialVector { initialVector[in] = initialVector[in] ^ macPart[in] }