diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-01-19 10:35:58 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-01-19 10:35:58 +0700 |
commit | 8e43e0440c06bf8cacabc6879439c9a75475bcb5 (patch) | |
tree | 498e5763229d53a9c6eac0f9558ba03ca08ad250 /crypto/src/x509/X509SignatureUtil.cs | |
parent | Lazy creation of SigAlgName (diff) | |
download | BouncyCastle.NET-ed25519-8e43e0440c06bf8cacabc6879439c9a75475bcb5.tar.xz |
Align sig alg checks in X509Certificate, X509Crl
Diffstat (limited to 'crypto/src/x509/X509SignatureUtil.cs')
-rw-r--r-- | crypto/src/x509/X509SignatureUtil.cs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/crypto/src/x509/X509SignatureUtil.cs b/crypto/src/x509/X509SignatureUtil.cs index 307d5a527..635e7d70b 100644 --- a/crypto/src/x509/X509SignatureUtil.cs +++ b/crypto/src/x509/X509SignatureUtil.cs @@ -12,7 +12,25 @@ namespace Org.BouncyCastle.X509 { internal class X509SignatureUtilities { - internal static string GetSignatureName(AlgorithmIdentifier sigAlgID) + internal static bool AreEquivalentAlgorithms(AlgorithmIdentifier id1, AlgorithmIdentifier id2) + { + if (!id1.Algorithm.Equals(id2.Algorithm)) + return false; + + Asn1Encodable p1 = id1.Parameters; + Asn1Encodable p2 = id2.Parameters; + + if (p1 == p2) + return true; + if (p1 == null) + return p2.ToAsn1Object() is Asn1Null; + if (p2 == null) + return p1.ToAsn1Object() is Asn1Null; + + return p1.Equals(p2); + } + + internal static string GetSignatureName(AlgorithmIdentifier sigAlgID) { DerObjectIdentifier sigAlgOid = sigAlgID.Algorithm; Asn1Encodable parameters = sigAlgID.Parameters; @@ -87,5 +105,5 @@ namespace Org.BouncyCastle.X509 return digestAlgOID.GetID(); } } - } + } } |