summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/asn1/Asn1Encodable.cs5
-rw-r--r--crypto/src/asn1/Asn1Set.cs18
-rw-r--r--crypto/src/cms/SignerInformation.cs14
-rw-r--r--crypto/test/src/cms/test/SignedDataTest.cs17
4 files changed, 29 insertions, 25 deletions
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);
diff --git a/crypto/src/cms/SignerInformation.cs b/crypto/src/cms/SignerInformation.cs
index 2bb808ae2..58bb312b3 100644
--- a/crypto/src/cms/SignerInformation.cs
+++ b/crypto/src/cms/SignerInformation.cs
@@ -23,11 +23,7 @@ namespace Org.BouncyCastle.Cms
 		private static readonly CmsSignedHelper Helper = CmsSignedHelper.Instance;
 
 		private SignerID			sid;
-		private SignerInfo			info;
-		private AlgorithmIdentifier	digestAlgorithm;
-		private AlgorithmIdentifier	encryptionAlgorithm;
-		private readonly Asn1Set	signedAttributeSet;
-		private readonly Asn1Set	unsignedAttributeSet;
+
 		private CmsProcessable		content;
 		private byte[]				signature;
 		private DerObjectIdentifier	contentType;
@@ -39,6 +35,12 @@ namespace Org.BouncyCastle.Cms
 		private Asn1.Cms.AttributeTable	unsignedAttributeTable;
 		private readonly bool isCounterSignature;
 
+		protected SignerInfo info;
+		protected AlgorithmIdentifier digestAlgorithm;
+		protected AlgorithmIdentifier encryptionAlgorithm;
+		protected readonly Asn1Set signedAttributeSet;
+		protected readonly Asn1Set unsignedAttributeSet;
+
 		internal SignerInformation(
 			SignerInfo			info,
 			DerObjectIdentifier	contentType,
@@ -309,7 +311,7 @@ namespace Org.BouncyCastle.Cms
 		* return the DER encoding of the signed attributes.
 		* @throws IOException if an encoding error occurs.
 		*/
-		public byte[] GetEncodedSignedAttributes()
+		public virtual byte[] GetEncodedSignedAttributes()
 		{
 			return signedAttributeSet == null
 				?	null
diff --git a/crypto/test/src/cms/test/SignedDataTest.cs b/crypto/test/src/cms/test/SignedDataTest.cs
index 65e0c4d57..68214c3c8 100644
--- a/crypto/test/src/cms/test/SignedDataTest.cs
+++ b/crypto/test/src/cms/test/SignedDataTest.cs
@@ -1258,7 +1258,22 @@ namespace Org.BouncyCastle.Cms.Tests
 				certEnum.MoveNext();
 				X509Certificate cert = (X509Certificate) certEnum.Current;
 
-				Assert.IsTrue(signer.Verify(cert));
+				Assert.IsTrue(new AsIsSignerInformation(signer).Verify(cert));
+			}
+		}
+
+	    class AsIsSignerInformation : SignerInformation
+		{
+			public AsIsSignerInformation(SignerInformation sInfo): base(sInfo)
+			{
+
+			}
+
+			public override byte[] GetEncodedSignedAttributes()
+			{
+				return signedAttributeSet == null
+					? null
+					: signedAttributeSet.GetEncoded();
 			}
 		}