diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-05-04 13:08:25 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-05-04 13:08:25 +0700 |
commit | 525dad93ce6d9444bab33f68fa5a43d8d9b9f94b (patch) | |
tree | 2cec4a9619a2f2edf88dc7b3536f106d96544ad7 /crypto/src/x509/store/X509CertStoreSelector.cs | |
parent | When there is reference equality, Equals() should return true. (diff) | |
download | BouncyCastle.NET-ed25519-525dad93ce6d9444bab33f68fa5a43d8d9b9f94b.tar.xz |
Refactoring in CMS cert selectors
Diffstat (limited to 'crypto/src/x509/store/X509CertStoreSelector.cs')
-rw-r--r-- | crypto/src/x509/store/X509CertStoreSelector.cs | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/crypto/src/x509/store/X509CertStoreSelector.cs b/crypto/src/x509/store/X509CertStoreSelector.cs index 357b5e76d..30cd44a8e 100644 --- a/crypto/src/x509/store/X509CertStoreSelector.cs +++ b/crypto/src/x509/store/X509CertStoreSelector.cs @@ -110,8 +110,8 @@ namespace Org.BouncyCastle.X509.Store public bool[] KeyUsage { - get { return CopyBoolArray(keyUsage); } - set { keyUsage = CopyBoolArray(value); } + get { return Arrays.Clone(keyUsage); } + set { keyUsage = Arrays.Clone(value); } } /// <summary> @@ -286,17 +286,19 @@ namespace Org.BouncyCastle.X509.Store return true; } - internal static bool IssuersMatch( - X509Name a, - X509Name b) - { - return a == null ? b == null : a.Equivalent(b, true); - } + protected internal int GetHashCodeOfSubjectKeyIdentifier() => Arrays.GetHashCode(subjectKeyIdentifier); + + protected internal bool MatchesIssuer(X509CertStoreSelector other) => IssuersMatch(issuer, other.issuer); - private static bool[] CopyBoolArray( - bool[] b) + protected internal bool MatchesSerialNumber(X509CertStoreSelector other) => + Objects.Equals(serialNumber, other.SerialNumber); + + protected internal bool MatchesSubjectKeyIdentifier(X509CertStoreSelector other) => + Arrays.AreEqual(subjectKeyIdentifier, other.subjectKeyIdentifier); + + private static bool IssuersMatch(X509Name a, X509Name b) { - return b == null ? null : (bool[]) b.Clone(); + return a == null ? b == null : a.Equivalent(b, true); } private static ISet<T> CopySet<T>(ISet<T> s) @@ -304,16 +306,12 @@ namespace Org.BouncyCastle.X509.Store return s == null ? null : new HashSet<T>(s); } - private static SubjectPublicKeyInfo GetSubjectPublicKey( - X509Certificate c) + private static SubjectPublicKeyInfo GetSubjectPublicKey(X509Certificate c) { - return SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(c.GetPublicKey()); + return c.CertificateStructure.SubjectPublicKeyInfo; } - private static bool MatchExtension( - byte[] b, - X509Certificate c, - DerObjectIdentifier oid) + private static bool MatchExtension(byte[] b, X509Certificate c, DerObjectIdentifier oid) { if (b == null) return true; |