summary refs log tree commit diff
path: root/crypto/src/x509/X509Certificate.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2024-01-19 10:35:58 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2024-01-19 10:35:58 +0700
commit8e43e0440c06bf8cacabc6879439c9a75475bcb5 (patch)
tree498e5763229d53a9c6eac0f9558ba03ca08ad250 /crypto/src/x509/X509Certificate.cs
parentLazy creation of SigAlgName (diff)
downloadBouncyCastle.NET-ed25519-8e43e0440c06bf8cacabc6879439c9a75475bcb5.tar.xz
Align sig alg checks in X509Certificate, X509Crl
Diffstat (limited to 'crypto/src/x509/X509Certificate.cs')
-rw-r--r--crypto/src/x509/X509Certificate.cs21
1 files changed, 2 insertions, 19 deletions
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index 316eaad99..572acb2c7 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -717,7 +717,7 @@ namespace Org.BouncyCastle.X509
         {
             var tbsCertificate = c.TbsCertificate;
 
-            if (!IsAlgIDEqual(c.SignatureAlgorithm, tbsCertificate.Signature))
+            if (!X509SignatureUtilities.AreEquivalentAlgorithms(c.SignatureAlgorithm, tbsCertificate.Signature))
                 throw new CertificateException("signature algorithm in TBS cert not same as outer cert");
 
             return X509Utilities.VerifySignature(verifier, tbsCertificate, c.Signature);
@@ -748,22 +748,5 @@ namespace Org.BouncyCastle.X509
         {
             return PublicKeyFactory.CreateKey(c.SubjectPublicKeyInfo);
         }
-
-        private static bool IsAlgIDEqual(AlgorithmIdentifier id1, AlgorithmIdentifier id2)
-        {
-            if (!id1.Algorithm.Equals(id2.Algorithm))
-                return false;
-
-            Asn1Encodable p1 = id1.Parameters;
-            Asn1Encodable p2 = id2.Parameters;
-
-            if ((p1 == null) == (p2 == null))
-                return Objects.Equals(p1, p2);
-
-            // Exactly one of p1, p2 is null at this point
-            return p1 == null
-                ? p2.ToAsn1Object() is Asn1Null
-                : p1.ToAsn1Object() is Asn1Null;
-        }
     }
-}
\ No newline at end of file
+}