diff options
Diffstat (limited to 'crypto/src/x509/X509Crl.cs')
-rw-r--r-- | crypto/src/x509/X509Crl.cs | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs index ecfb14132..8903e69d0 100644 --- a/crypto/src/x509/X509Crl.cs +++ b/crypto/src/x509/X509Crl.cs @@ -6,6 +6,7 @@ using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Utilities; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.Crypto.Operators; using Org.BouncyCastle.Math; using Org.BouncyCastle.Security; using Org.BouncyCastle.Security.Certificates; @@ -14,7 +15,6 @@ using Org.BouncyCastle.Utilities.Collections; using Org.BouncyCastle.Utilities.Date; using Org.BouncyCastle.Utilities.Encoders; using Org.BouncyCastle.X509.Extension; -using Org.BouncyCastle.Crypto.Operators; namespace Org.BouncyCastle.X509 { @@ -36,6 +36,9 @@ namespace Org.BouncyCastle.X509 private readonly byte[] sigAlgParams; private readonly bool isIndirect; + private volatile bool hashValueSet; + private volatile int hashValue; + public X509Crl( CertificateList c) { @@ -229,27 +232,41 @@ namespace Org.BouncyCastle.X509 return Arrays.Clone(sigAlgParams); } - public override bool Equals( - object obj) + public override bool Equals(object other) { - if (obj == this) - return true; + if (this == other) + return true; - X509Crl other = obj as X509Crl; + X509Crl that = other as X509Crl; + if (null == that) + return false; - if (other == null) - return false; + if (this.hashValueSet && that.hashValueSet) + { + if (this.hashValue != that.hashValue) + return false; + } + else if (!this.c.Signature.Equals(that.c.Signature)) + { + return false; + } - return c.Equals(other.c); + return this.c.Equals(that.c); - // NB: May prefer this implementation of Equals if more than one certificate implementation in play - //return Arrays.AreEqual(this.GetEncoded(), other.GetEncoded()); + // NB: May prefer this implementation of Equals if more than one CRL implementation in play + //return Arrays.AreEqual(this.GetEncoded(), that.GetEncoded()); } - public override int GetHashCode() - { - return c.GetHashCode(); - } + public override int GetHashCode() + { + if (!hashValueSet) + { + hashValue = this.c.GetHashCode(); + hashValueSet = true; + } + + return hashValue; + } /** * Returns a string representation of this CRL. |