summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-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