mirror of https://github.com/status-im/nim-eth.git
Clear after aes encrypt/decrypt
This commit is contained in:
parent
1e1fd70649
commit
67decc3a85
|
@ -199,6 +199,7 @@ proc encryptAesGcm(plain: openarray[byte], key: SymKey,
|
|||
gcm.encrypt(plain, result)
|
||||
var tag: array[gcmTagLen, byte]
|
||||
gcm.getTag(tag)
|
||||
gcm.clear()
|
||||
result.add tag
|
||||
result.add iv
|
||||
|
||||
|
@ -217,6 +218,7 @@ proc decryptAesGcm(cipher: openarray[byte], key: SymKey): Option[seq[byte]] =
|
|||
gcm.decrypt(cipher[0 ..< ^(gcmIVLen + gcmTagLen)], res)
|
||||
var tag2: array[gcmTagLen, byte]
|
||||
gcm.getTag(tag2)
|
||||
gcm.clear()
|
||||
|
||||
if tag != tag2:
|
||||
debug "cipher tag mismatch", len = cipher.len, tag, tag2
|
||||
|
|
Loading…
Reference in New Issue