]> Cypherpunks.ru repositories - gogost.git/commitdiff
mgm.InvalidTag
authorSergey Matveev <stargrave@stargrave.org>
Wed, 5 Apr 2023 11:56:26 +0000 (14:56 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 5 Apr 2023 11:58:25 +0000 (14:58 +0300)
gogost.go
mgm/mode.go
news.texi

index 76095fe1ddfa99c144b828ab1d208dca6ae83717..2aad3a2be8067e59e5731b8a2ac73ee3bbce3384 100644 (file)
--- a/gogost.go
+++ b/gogost.go
@@ -1,4 +1,4 @@
 // Pure Go GOST cryptographic functions library.
 package gogost
 
-const Version = "5.9.1"
+const Version = "5.10.0"
index c62e7561ecaa608b2af6b920715f3d37f7c97fc7..3fdeaba0fbc889ca6baa59c645751bcec9d7e7d4 100644 (file)
@@ -23,6 +23,8 @@ import (
        "errors"
 )
 
+var InvalidTag = errors.New("gogost/mgm: invalid authentication tag")
+
 type Mul interface {
        Mul(x, y []byte) []byte
 }
@@ -207,6 +209,8 @@ func (mgm *MGM) Seal(dst, nonce, plaintext, additionalData []byte) []byte {
        return ret
 }
 
+// Open the authenticated ciphertext. If authentication tag is invalid,
+// then InvalidTag error is returned.
 func (mgm *MGM) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) {
        mgm.validateNonce(nonce)
        mgm.validateSizes(ciphertext, additionalData)
@@ -221,7 +225,7 @@ func (mgm *MGM) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, err
        copy(mgm.icn, nonce)
        mgm.auth(mgm.sum, ct, additionalData)
        if !hmac.Equal(mgm.sum[:mgm.TagSize], ciphertext[len(ciphertext)-mgm.TagSize:]) {
-               return nil, errors.New("gogost/mgm: invalid authentication tag")
+               return nil, InvalidTag
        }
        mgm.crypt(out, ct)
        return ret, nil
index 66e19421777ab5bc0228b6fee62b9975caed6823..341c8eaf17b0ee252d195a27fec3ca7c0636e549 100644 (file)
--- a/news.texi
+++ b/news.texi
@@ -3,6 +3,10 @@
 
 @table @strong
 
+@anchor{Release 5.10.0}
+@item 5.10.0
+@code{mgm.MGM.Open} returns @code{mgm.InvalidTag} for failed authentication.
+
 @anchor{Release 5.9.1}
 @item 5.9.1
 Updated and cleaned up @file{go.sum}.