From 860ce04ebcf75718e94cdadcd486895d67fd7e98 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 9 Feb 2021 12:57:16 +0700 Subject: Equals/GetHashCode for SignatureSubpacket --- crypto/src/bcpg/SignatureSubpacket.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'crypto') 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 { /// Basic type for a PGP Signature sub-packet. @@ -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); + } } } -- cgit 1.4.1