summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-10-18 12:22:25 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-10-18 12:22:25 +0700
commit72bc65bf9af227d835cfc04e43b4a51b5ac343d6 (patch)
tree1c6f1e685c89fa3d1746695c016b49f285ab5070
parentSwitch to Strings.ToByteArray as is used in the Java API (diff)
downloadBouncyCastle.NET-ed25519-72bc65bf9af227d835cfc04e43b4a51b5ac343d6.tar.xz
Add CalculateMac utility method
Diffstat (limited to '')
-rw-r--r--crypto/src/security/MacUtilities.cs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crypto/src/security/MacUtilities.cs b/crypto/src/security/MacUtilities.cs
index d1f8c89b4..d7fe91142 100644
--- a/crypto/src/security/MacUtilities.cs
+++ b/crypto/src/security/MacUtilities.cs
@@ -230,6 +230,14 @@ namespace Org.BouncyCastle.Security
             return (string) algorithms[oid.Id];
         }
 
+        public static byte[] CalculateMac(string algorithm, ICipherParameters cp, byte[] input)
+        {
+            IMac mac = GetMac(algorithm);
+            mac.Init(cp);
+            mac.BlockUpdate(input, 0, input.Length);
+            return DoFinal(mac);
+        }
+
         public static byte[] DoFinal(IMac mac)
         {
             byte[] b = new byte[mac.GetMacSize()];