summary refs log tree commit diff
path: root/crypto/src/x509/X509Utilities.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-28 20:13:02 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-28 20:13:02 +0700
commita375c08770711d4265a1606baae162c185ef916f (patch)
tree4ddb6a00add42ab5249d6a37caacd2db29dcb7cd /crypto/src/x509/X509Utilities.cs
parentRefactoring around digest calculation (diff)
downloadBouncyCastle.NET-ed25519-a375c08770711d4265a1606baae162c185ef916f.tar.xz
Refactoring around digest calculation
Diffstat (limited to 'crypto/src/x509/X509Utilities.cs')
-rw-r--r--crypto/src/x509/X509Utilities.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/crypto/src/x509/X509Utilities.cs b/crypto/src/x509/X509Utilities.cs
index 5051b1b4e..e7dfeb2c5 100644
--- a/crypto/src/x509/X509Utilities.cs
+++ b/crypto/src/x509/X509Utilities.cs
@@ -129,14 +129,22 @@ namespace Org.BouncyCastle.X509
 			m_exParams.Add("SHA512WITHRSAANDMGF1", CreatePssParams(sha512AlgId, 64));
 		}
 
-		internal static byte[] CalculateDigest(DerObjectIdentifier oid, Asn1Encodable asn1Encodable)
+		internal static byte[] CalculateDigest(AlgorithmIdentifier digestAlgorithm, Asn1Encodable asn1Encodable)
 		{
-            var digest = DigestUtilities.GetDigest(oid);
+            var digest = DigestUtilities.GetDigest(digestAlgorithm.Algorithm);
             var digestCalculator = new DefaultDigestCalculator(digest);
             var digestResult = CalculateResult(digestCalculator, asn1Encodable);
 			return digestResult.Collect();
         }
 
+        internal static byte[] CalculateDigest(IDigestFactory digestFactory,
+            Asn1Encodable asn1Encodable)
+        {
+            var digestCalculator = digestFactory.CreateCalculator();
+            var digestResult = CalculateResult(digestCalculator, asn1Encodable);
+            return digestResult.Collect();
+        }
+
         internal static TResult CalculateResult<TResult>(IStreamCalculator<TResult> streamCalculator,
             Asn1Encodable asn1Encodable)
         {
@@ -220,11 +228,11 @@ namespace Org.BouncyCastle.X509
             return GenerateBitString(signatureFactory.CreateCalculator(), asn1Encodable);
         }
 
-        internal static bool VerifyMac(IMacFactory macFactory, Asn1Encodable asn1Encodable, DerBitString protection)
+        internal static bool VerifyMac(IMacFactory macFactory, Asn1Encodable asn1Encodable, DerBitString expected)
         {
             var result = CalculateResult(macFactory.CreateCalculator(), asn1Encodable);
 
-            return Arrays.FixedTimeEquals(result.Collect(), protection.GetBytes());
+            return Arrays.FixedTimeEquals(result.Collect(), expected.GetOctets());
         }
 
         internal static bool VerifySignature(IVerifierFactory verifierFactory, Asn1Encodable asn1Encodable,