summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-09-29 20:34:11 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-09-29 20:34:11 +0700
commitd5cf9239aca3f6f43fea68508b9b9d7585afb8c5 (patch)
tree86951586b83864443c15d8a74b8a35af53795065 /crypto/src
parentGrain128Aead fixes (diff)
downloadBouncyCastle.NET-ed25519-d5cf9239aca3f6f43fea68508b9b9d7585afb8c5.tar.xz
Preserve mac after DoFinal
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/crypto/engines/Grain128AEADEngine.cs32
1 files changed, 15 insertions, 17 deletions
diff --git a/crypto/src/crypto/engines/Grain128AEADEngine.cs b/crypto/src/crypto/engines/Grain128AEADEngine.cs

index 8dca6a6d8..a571cb124 100644 --- a/crypto/src/crypto/engines/Grain128AEADEngine.cs +++ b/crypto/src/crypto/engines/Grain128AEADEngine.cs
@@ -298,8 +298,16 @@ namespace Org.BouncyCastle.Crypto.Engines public void Reset() { + Reset(true); + } + + private void Reset(bool clearMac) + { this.isEven = true; - this.mac = null; + if (clearMac) + { + this.mac = null; + } this.aadData.SetLength(0); this.aadFinished = false; @@ -547,14 +555,9 @@ namespace Org.BouncyCastle.Crypto.Engines Array.Copy(mac, 0, output, outOff, mac.Length); - try - { - return mac.Length; - } - finally - { - Reset(); - } + Reset(false); + + return mac.Length; #endif } @@ -585,14 +588,9 @@ namespace Org.BouncyCastle.Crypto.Engines mac.CopyTo(output); - try - { - return mac.Length; - } - finally - { - Reset(); - } + Reset(false); + + return mac.Length; } #endif