summary refs log tree commit diff
path: root/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/DefaultSignedAttributeTableGenerator.cs')
-rw-r--r--crypto/src/cms/DefaultSignedAttributeTableGenerator.cs48
1 files changed, 14 insertions, 34 deletions
diff --git a/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs b/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
index fad80b52b..8d0bca083 100644
--- a/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
+++ b/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
@@ -13,14 +14,14 @@ namespace Org.BouncyCastle.Cms
 	public class DefaultSignedAttributeTableGenerator
 		: CmsAttributeTableGenerator
 	{
-		private readonly IDictionary table;
+		private readonly IDictionary<DerObjectIdentifier, object> m_table;
 
 		/**
 		 * Initialise to use all defaults
 		 */
 		public DefaultSignedAttributeTableGenerator()
 		{
-			table = Platform.CreateHashtable();
+			m_table = new Dictionary<DerObjectIdentifier, object>();
 		}
 
 		/**
@@ -28,38 +29,18 @@ namespace Org.BouncyCastle.Cms
 		 *
 		 * @param attributeTable initial attribute table to use.
 		 */
-		public DefaultSignedAttributeTableGenerator(
-			AttributeTable attributeTable)
+		public DefaultSignedAttributeTableGenerator(AttributeTable attributeTable)
 		{
 			if (attributeTable != null)
 			{
-				table = attributeTable.ToDictionary();
+				m_table = attributeTable.ToDictionary();
 			}
 			else
 			{
-				table = Platform.CreateHashtable();
+				m_table = new Dictionary<DerObjectIdentifier, object>();
 			}
 		}
 
-#if PORTABLE
-		/**
-		 * Create a standard attribute table from the passed in parameters - this will
-		 * normally include contentType, signingTime, and messageDigest. If the constructor
-		 * using an AttributeTable was used, entries in it for contentType, signingTime, and
-		 * messageDigest will override the generated ones.
-		 *
-		 * @param parameters source parameters for table generation.
-		 *
-		 * @return a filled in Hashtable of attributes.
-		 */
-		protected virtual IDictionary createStandardAttributeTable(
-			IDictionary parameters)
-		{
-            IDictionary std = Platform.CreateHashtable(table);
-            DoCreateStandardAttributeTable(parameters, std);
-            return std;
-		}
-#else
         /**
 		 * Create a standard attribute table from the passed in parameters - this will
 		 * normally include contentType, signingTime, and messageDigest. If the constructor
@@ -70,21 +51,20 @@ namespace Org.BouncyCastle.Cms
 		 *
 		 * @return a filled in Hashtable of attributes.
 		 */
-		protected virtual Hashtable createStandardAttributeTable(
-			IDictionary parameters)
+		protected virtual IDictionary<DerObjectIdentifier, object> CreateStandardAttributeTable(IDictionary parameters)
 		{
-            Hashtable std = new Hashtable(table);
+            var std = new Dictionary<DerObjectIdentifier, object>(m_table);
             DoCreateStandardAttributeTable(parameters, std);
 			return std;
 		}
-#endif
 
-        private void DoCreateStandardAttributeTable(IDictionary parameters, IDictionary std)
+        private void DoCreateStandardAttributeTable(IDictionary parameters,
+			IDictionary<DerObjectIdentifier, object> std)
         {
             // contentType will be absent if we're trying to generate a counter signature.
             if (parameters.Contains(CmsAttributeTableParameter.ContentType))
             {
-                if (!std.Contains(CmsAttributes.ContentType))
+                if (!std.ContainsKey(CmsAttributes.ContentType))
                 {
                     DerObjectIdentifier contentType = (DerObjectIdentifier)
                         parameters[CmsAttributeTableParameter.ContentType];
@@ -94,14 +74,14 @@ namespace Org.BouncyCastle.Cms
                 }
             }
 
-            if (!std.Contains(CmsAttributes.SigningTime))
+            if (!std.ContainsKey(CmsAttributes.SigningTime))
             {
                 Asn1.Cms.Attribute attr = new Asn1.Cms.Attribute(CmsAttributes.SigningTime,
                     new DerSet(new Time(DateTime.UtcNow)));
                 std[attr.AttrType] = attr;
             }
 
-            if (!std.Contains(CmsAttributes.MessageDigest))
+            if (!std.ContainsKey(CmsAttributes.MessageDigest))
             {
                 byte[] messageDigest = (byte[])parameters[CmsAttributeTableParameter.Digest];
                 Asn1.Cms.Attribute attr = new Asn1.Cms.Attribute(CmsAttributes.MessageDigest,
@@ -117,7 +97,7 @@ namespace Org.BouncyCastle.Cms
 		public virtual AttributeTable GetAttributes(
 			IDictionary parameters)
 		{
-            IDictionary table = createStandardAttributeTable(parameters);
+            var table = CreateStandardAttributeTable(parameters);
 			return new AttributeTable(table);
 		}
 	}