summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-02-09 12:57:16 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-02-09 12:57:16 +0700
commit860ce04ebcf75718e94cdadcd486895d67fd7e98 (patch)
tree53f49393147f17950a4aa09333621d3b8d730c96
parentNew HasValue methods (diff)
downloadBouncyCastle.NET-ed25519-860ce04ebcf75718e94cdadcd486895d67fd7e98.tar.xz
Equals/GetHashCode for SignatureSubpacket
-rw-r--r--crypto/src/bcpg/SignatureSubpacket.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/src/bcpg/SignatureSubpacket.cs b/crypto/src/bcpg/SignatureSubpacket.cs
index d99315599..5accadc14 100644
--- a/crypto/src/bcpg/SignatureSubpacket.cs
+++ b/crypto/src/bcpg/SignatureSubpacket.cs
@@ -1,5 +1,7 @@
 using System.IO;
 
+using Org.BouncyCastle.Utilities;
+
 namespace Org.BouncyCastle.Bcpg
 {
 	/// <remarks>Basic type for a PGP Signature sub-packet.</remarks>
@@ -90,5 +92,24 @@ namespace Org.BouncyCastle.Bcpg
 
             os.Write(data, 0, data.Length);
         }
+
+        public override int GetHashCode()
+        {
+            return (critical ? 1 : 0) + 7 * (int)type + 49 * Arrays.GetHashCode(data);
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (obj == this)
+                return true;
+
+            SignatureSubpacket other = obj as SignatureSubpacket;
+            if (null == other)
+                return false;
+
+            return this.type == other.type
+                && this.critical == other.critical
+                && Arrays.AreEqual(this.data, other.data);
+        }
     }
 }