File tree Expand file tree Collapse file tree 3 files changed +23
-23
lines changed Expand file tree Collapse file tree 3 files changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -717,7 +717,7 @@ protected virtual bool CheckSignatureValid(IVerifierFactory verifier)
717
717
{
718
718
var tbsCertificate = c . TbsCertificate ;
719
719
720
- if ( ! IsAlgIDEqual ( c . SignatureAlgorithm , tbsCertificate . Signature ) )
720
+ if ( ! X509SignatureUtilities . AreEquivalentAlgorithms ( c . SignatureAlgorithm , tbsCertificate . Signature ) )
721
721
throw new CertificateException ( "signature algorithm in TBS cert not same as outer cert" ) ;
722
722
723
723
return X509Utilities . VerifySignature ( verifier , tbsCertificate , c . Signature ) ;
@@ -748,22 +748,5 @@ private static AsymmetricKeyParameter CreatePublicKey(X509CertificateStructure c
748
748
{
749
749
return PublicKeyFactory . CreateKey ( c . SubjectPublicKeyInfo ) ;
750
750
}
751
-
752
- private static bool IsAlgIDEqual ( AlgorithmIdentifier id1 , AlgorithmIdentifier id2 )
753
- {
754
- if ( ! id1 . Algorithm . Equals ( id2 . Algorithm ) )
755
- return false ;
756
-
757
- Asn1Encodable p1 = id1 . Parameters ;
758
- Asn1Encodable p2 = id2 . Parameters ;
759
-
760
- if ( ( p1 == null ) == ( p2 == null ) )
761
- return Objects . Equals ( p1 , p2 ) ;
762
-
763
- // Exactly one of p1, p2 is null at this point
764
- return p1 == null
765
- ? p2 . ToAsn1Object ( ) is Asn1Null
766
- : p1 . ToAsn1Object ( ) is Asn1Null ;
767
- }
768
751
}
769
- }
752
+ }
Original file line number Diff line number Diff line change @@ -181,8 +181,7 @@ protected virtual bool CheckSignatureValid(IVerifierFactory verifier)
181
181
{
182
182
var tbsCertList = c . TbsCertList ;
183
183
184
- // TODO Compare IsAlgIDEqual in X509Certificate.CheckSignature
185
- if ( ! c . SignatureAlgorithm . Equals ( tbsCertList . Signature ) )
184
+ if ( ! X509SignatureUtilities . AreEquivalentAlgorithms ( c . SignatureAlgorithm , tbsCertList . Signature ) )
186
185
throw new CrlException ( "Signature algorithm on CertificateList does not match TbsCertList." ) ;
187
186
188
187
return X509Utilities . VerifySignature ( verifier , tbsCertList , c . Signature ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,25 @@ namespace Org.BouncyCastle.X509
12
12
{
13
13
internal class X509SignatureUtilities
14
14
{
15
- internal static string GetSignatureName ( AlgorithmIdentifier sigAlgID )
15
+ internal static bool AreEquivalentAlgorithms ( AlgorithmIdentifier id1 , AlgorithmIdentifier id2 )
16
+ {
17
+ if ( ! id1 . Algorithm . Equals ( id2 . Algorithm ) )
18
+ return false ;
19
+
20
+ Asn1Encodable p1 = id1 . Parameters ;
21
+ Asn1Encodable p2 = id2 . Parameters ;
22
+
23
+ if ( p1 == p2 )
24
+ return true ;
25
+ if ( p1 == null )
26
+ return p2 . ToAsn1Object ( ) is Asn1Null ;
27
+ if ( p2 == null )
28
+ return p1 . ToAsn1Object ( ) is Asn1Null ;
29
+
30
+ return p1 . Equals ( p2 ) ;
31
+ }
32
+
33
+ internal static string GetSignatureName ( AlgorithmIdentifier sigAlgID )
16
34
{
17
35
DerObjectIdentifier sigAlgOid = sigAlgID . Algorithm ;
18
36
Asn1Encodable parameters = sigAlgID . Parameters ;
@@ -87,5 +105,5 @@ private static string GetDigestAlgName(DerObjectIdentifier digestAlgOID)
87
105
return digestAlgOID . GetID ( ) ;
88
106
}
89
107
}
90
- }
108
+ }
91
109
}
You can’t perform that action at this time.
0 commit comments