X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=mgm%2Fmode.go;h=c4bb92ae66353fdda8f90dcada019a25eecca8ee;hb=HEAD;hp=3fdeaba0fbc889ca6baa59c645751bcec9d7e7d4;hpb=b465c131a7dc5dd4563cfa85b5629baeaa403f7b;p=gogost.git diff --git a/mgm/mode.go b/mgm/mode.go index 3fdeaba..cbba435 100644 --- a/mgm/mode.go +++ b/mgm/mode.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2023 Sergey Matveev +// Copyright (C) 2015-2024 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ import ( "crypto/hmac" "encoding/binary" "errors" + "fmt" ) var InvalidTag = errors.New("gogost/mgm: invalid authentication tag") @@ -45,10 +46,10 @@ type MGM struct { func NewMGM(cipher cipher.Block, tagSize int) (cipher.AEAD, error) { blockSize := cipher.BlockSize() if !(blockSize == 8 || blockSize == 16) { - return nil, errors.New("gogost/mgm: only 64/128 blocksizes allowed") + return nil, errors.New("gogost/mgm: only {64|128} blocksizes allowed") } if tagSize < 4 || tagSize > blockSize { - return nil, errors.New("gogost/mgm: invalid tag size") + return nil, fmt.Errorf("gogost/mgm: invalid tag size (4<=%d<=%d)", tagSize, blockSize) } mgm := MGM{ MaxSize: uint64(1< mgm.MaxSize { panic("ciphertext is too big")