From 81977ab62fb74af1624930718b83acd8c5c78f72 Mon Sep 17 00:00:00 2001 From: David Hook Date: Thu, 7 Oct 2021 11:20:11 +1100 Subject: added explicit sorting of DER encoded SET --- crypto/src/asn1/Asn1Encodable.cs | 5 +++++ crypto/src/asn1/Asn1Set.cs | 18 ------------------ 2 files changed, 5 insertions(+), 18 deletions(-) (limited to 'crypto/src/asn1') diff --git a/crypto/src/asn1/Asn1Encodable.cs b/crypto/src/asn1/Asn1Encodable.cs index 12628082d..c7fde6e07 100644 --- a/crypto/src/asn1/Asn1Encodable.cs +++ b/crypto/src/asn1/Asn1Encodable.cs @@ -26,6 +26,11 @@ namespace Org.BouncyCastle.Asn1 MemoryStream bOut = new MemoryStream(); DerOutputStream dOut = new DerOutputStream(bOut); + if (this is Asn1Set) + { + (this as Asn1Set).Sort(); + } + dOut.WriteObject(this); return bOut.ToArray(); diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs index 7b3c1ccf3..68ede2275 100644 --- a/crypto/src/asn1/Asn1Set.cs +++ b/crypto/src/asn1/Asn1Set.cs @@ -285,24 +285,6 @@ namespace Org.BouncyCastle.Asn1 #endif } - public override byte[] GetEncoded( - string encoding) - { - if (encoding.Equals(Der)) - { - this.Sort(); - - MemoryStream bOut = new MemoryStream(); - DerOutputStream dOut = new DerOutputStream(bOut); - - dOut.WriteObject(this); - - return bOut.ToArray(); - } - - return GetEncoded(); - } - public override string ToString() { return CollectionUtilities.ToString(elements); -- cgit 1.4.1