summary refs log tree commit diff
path: root/crypto/src/tls/PskIdentity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/tls/PskIdentity.cs')
-rw-r--r--crypto/src/tls/PskIdentity.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crypto/src/tls/PskIdentity.cs b/crypto/src/tls/PskIdentity.cs
index 082907419..1887d0af4 100644
--- a/crypto/src/tls/PskIdentity.cs
+++ b/crypto/src/tls/PskIdentity.cs
@@ -1,6 +1,8 @@
 using System;
 using System.IO;
 
+using Org.BouncyCastle.Utilities;
+
 namespace Org.BouncyCastle.Tls
 {
     public sealed class PskIdentity
@@ -48,5 +50,20 @@ namespace Org.BouncyCastle.Tls
             long obfuscatedTicketAge = TlsUtilities.ReadUint32(input);
             return new PskIdentity(identity, obfuscatedTicketAge);
         }
+
+        public override bool Equals(object obj)
+        {
+            PskIdentity that = obj as PskIdentity;
+            if (null == that)
+                return false;
+
+            return this.m_obfuscatedTicketAge == that.m_obfuscatedTicketAge
+                && Arrays.ConstantTimeAreEqual(this.m_identity, that.m_identity);
+        }
+
+        public override int GetHashCode()
+        {
+            return Arrays.GetHashCode(m_identity) ^ m_obfuscatedTicketAge.GetHashCode();
+        }
     }
 }