diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-02 15:34:54 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-02 15:34:54 +0700 |
commit | fe33e6090225fd173df691e307b034dd712f4e07 (patch) | |
tree | e6152f508adb3bb89cfabe6af826f76e6a6950e9 /crypto/src/x509/X509CrlEntry.cs | |
parent | SHA-256 performance tweak (diff) | |
download | BouncyCastle.NET-ed25519-fe33e6090225fd173df691e307b034dd712f4e07.tar.xz |
Refactor Equals/GetHashCode in X509 objects
- cache public key in X509Certificate
Diffstat (limited to 'crypto/src/x509/X509CrlEntry.cs')
-rw-r--r-- | crypto/src/x509/X509CrlEntry.cs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/crypto/src/x509/X509CrlEntry.cs b/crypto/src/x509/X509CrlEntry.cs index caca29470..9e3608c18 100644 --- a/crypto/src/x509/X509CrlEntry.cs +++ b/crypto/src/x509/X509CrlEntry.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.IO; using System.Text; using Org.BouncyCastle.Asn1; @@ -27,6 +26,9 @@ namespace Org.BouncyCastle.X509 private X509Name previousCertificateIssuer; private X509Name certificateIssuer; + private volatile bool hashValueSet; + private volatile int hashValue; + public X509CrlEntry( CrlEntry c) { @@ -132,6 +134,35 @@ namespace Org.BouncyCastle.X509 get { return c.Extensions != null; } } + public override bool Equals(object other) + { + if (this == other) + return true; + + X509CrlEntry that = other as X509CrlEntry; + if (null == that) + return false; + + if (this.hashValueSet && that.hashValueSet) + { + if (this.hashValue != that.hashValue) + return false; + } + + return this.c.Equals(that.c); + } + + public override int GetHashCode() + { + if (!hashValueSet) + { + hashValue = this.c.GetHashCode(); + hashValueSet = true; + } + + return hashValue; + } + public override string ToString() { StringBuilder buf = new StringBuilder(); |