Skip to content

Commit 79ebcd6

Browse files
author
Alexandre Stein
authored
Fixes #21
1 parent 3d3ad9f commit 79ebcd6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

aes_gcm.go

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (alg *AesGcm) Decrypt(aad, cek, iv, cipherText, authTag []byte) (plainText
8585

8686
cipherWithTag:=append(cipherText,authTag...)
8787

88+
if nonceSize := len(iv); nonceSize != aesgcm.NonceSize() {
89+
return nil, errors.New(fmt.Sprintf("AesGcm.Decrypt(): expected nonce of size %v bits, but was given %v bits.", aesgcm.NonceSize()<<3, nonceSize<<3))
90+
}
91+
8892
if plainText,err = aesgcm.Open(nil, iv, cipherWithTag, aad);err!=nil {
8993
return nil,err
9094
}

0 commit comments

Comments
 (0)