diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 12:22:25 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 12:22:25 +0700 |
commit | 72bc65bf9af227d835cfc04e43b4a51b5ac343d6 (patch) | |
tree | 1c6f1e685c89fa3d1746695c016b49f285ab5070 | |
parent | Switch to Strings.ToByteArray as is used in the Java API (diff) | |
download | BouncyCastle.NET-ed25519-72bc65bf9af227d835cfc04e43b4a51b5ac343d6.tar.xz |
Add CalculateMac utility method
-rw-r--r-- | crypto/src/security/MacUtilities.cs | 8 |
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()]; |