From db9067c0417531b339b5acf7dc923c0f26f2811f Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 18 Dec 2013 18:56:32 +0700 Subject: Factor out variation of MacUtilities.DoFinal --- crypto/src/pkcs/Pkcs12Store.cs | 3 +-- crypto/src/security/MacUtilities.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'crypto/src') diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs index 6718aea10..55f20206a 100644 --- a/crypto/src/pkcs/Pkcs12Store.cs +++ b/crypto/src/pkcs/Pkcs12Store.cs @@ -1132,8 +1132,7 @@ namespace Org.BouncyCastle.Pkcs IMac mac = (IMac) PbeUtilities.CreateEngine(oid); mac.Init(cipherParams); - mac.BlockUpdate(data, 0, data.Length); - return MacUtilities.DoFinal(mac); + return MacUtilities.DoFinal(mac, data); } private static byte[] CryptPbeData( diff --git a/crypto/src/security/MacUtilities.cs b/crypto/src/security/MacUtilities.cs index 77d141411..d1f8c89b4 100644 --- a/crypto/src/security/MacUtilities.cs +++ b/crypto/src/security/MacUtilities.cs @@ -230,12 +230,17 @@ namespace Org.BouncyCastle.Security return (string) algorithms[oid.Id]; } - public static byte[] DoFinal( - IMac mac) + public static byte[] DoFinal(IMac mac) { byte[] b = new byte[mac.GetMacSize()]; mac.DoFinal(b, 0); return b; } + + public static byte[] DoFinal(IMac mac, byte[] input) + { + mac.BlockUpdate(input, 0, input.Length); + return DoFinal(mac); + } } } -- cgit 1.5.1