summary refs log tree commit diff
path: root/crypto/src/cmp/CertificateStatus.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cmp/CertificateStatus.cs')
-rw-r--r--crypto/src/cmp/CertificateStatus.cs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crypto/src/cmp/CertificateStatus.cs b/crypto/src/cmp/CertificateStatus.cs
index 53227d062..8ccf89562 100644
--- a/crypto/src/cmp/CertificateStatus.cs
+++ b/crypto/src/cmp/CertificateStatus.cs
@@ -1,9 +1,6 @@
-using System;
-
-using Org.BouncyCastle.Asn1.Cmp;
+using Org.BouncyCastle.Asn1.Cmp;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Cms;
-using Org.BouncyCastle.Crypto.IO;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
@@ -13,8 +10,6 @@ namespace Org.BouncyCastle.Cmp
 {
     public class CertificateStatus
     {
-        private static readonly DefaultSignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder();
-
         private readonly DefaultDigestAlgorithmIdentifierFinder digestAlgFinder;
         private readonly CertStatus certStatus;
 
@@ -30,11 +25,13 @@ namespace Org.BouncyCastle.Cmp
 
         public virtual bool IsVerified(X509Certificate cert)
         {
-            AlgorithmIdentifier digAlg = digestAlgFinder.Find(sigAlgFinder.Find(cert.SigAlgName));
-            if (null == digAlg)
-                throw new CmpException("cannot find algorithm for digest from signature " + cert.SigAlgName);
+            var sigAlgID = DefaultSignatureAlgorithmIdentifierFinder.Instance.Find(cert.SigAlgName)
+                ?? throw new CmpException("cannot find algorithm identifier for signature name");
+
+            var digAlgID = digestAlgFinder.Find(sigAlgID)
+                ?? throw new CmpException("cannot find algorithm for digest from signature " + cert.SigAlgName);
 
-            byte[] digest = DigestUtilities.CalculateDigest(digAlg.Algorithm, cert.GetEncoded());
+            byte[] digest = DigestUtilities.CalculateDigest(digAlgID.Algorithm, cert.GetEncoded());
 
             return Arrays.FixedTimeEquals(certStatus.CertHash.GetOctets(), digest);
         }