diff options
Diffstat (limited to 'crypto/src/cms/SignerId.cs')
-rw-r--r-- | crypto/src/cms/SignerId.cs | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/crypto/src/cms/SignerId.cs b/crypto/src/cms/SignerId.cs index 3d38a58dc..ca84a6cf7 100644 --- a/crypto/src/cms/SignerId.cs +++ b/crypto/src/cms/SignerId.cs @@ -1,51 +1,30 @@ using System; -using Org.BouncyCastle.Asn1.X509; -using Org.BouncyCastle.Math; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.X509.Store; namespace Org.BouncyCastle.Cms { - /** - * a basic index for a signer. - */ + // TODO[api] sealed public class SignerID - : X509CertStoreSelector + : X509CertStoreSelector, IEquatable<SignerID> { - public override int GetHashCode() + public virtual bool Equals(SignerID other) { - int code = Arrays.GetHashCode(this.SubjectKeyIdentifier); - - BigInteger serialNumber = this.SerialNumber; - if (serialNumber != null) - { - code ^= serialNumber.GetHashCode(); - } - - X509Name issuer = this.Issuer; - if (issuer != null) - { - code ^= issuer.GetHashCode(); - } - - return code; + return other == null ? false + : other == this ? true + : MatchesSubjectKeyIdentifier(other) + && MatchesSerialNumber(other) + && MatchesIssuer(other); } - public override bool Equals( - object obj) - { - if (obj == this) - return true; + public override bool Equals(object obj) => Equals(obj as SignerID); - SignerID id = obj as SignerID; - - if (id == null) - return false; - - return Arrays.AreEqual(SubjectKeyIdentifier, id.SubjectKeyIdentifier) - && Objects.Equals(SerialNumber, id.SerialNumber) - && IssuersMatch(Issuer, id.Issuer); + public override int GetHashCode() + { + return GetHashCodeOfSubjectKeyIdentifier() + ^ Objects.GetHashCode(SerialNumber) + ^ Objects.GetHashCode(Issuer); } } } |