diff --git a/crypto/src/cms/CMSSignedDataGenerator.cs b/crypto/src/cms/CMSSignedDataGenerator.cs
index 20dc59f36..3db000896 100644
--- a/crypto/src/cms/CMSSignedDataGenerator.cs
+++ b/crypto/src/cms/CMSSignedDataGenerator.cs
@@ -136,12 +136,7 @@ namespace Org.BouncyCastle.Cms
}
IStreamCalculator calculator = sigCalc.CreateCalculator();
-
-#if PORTABLE
- Stream sigStr = calculator.Stream;
-#else
Stream sigStr = new BufferedStream(calculator.Stream);
-#endif
Asn1Set signedAttr = null;
if (sAttr != null)
@@ -155,9 +150,7 @@ namespace Org.BouncyCastle.Cms
{
if (signed != null && signed[CmsAttributes.ContentType] != null)
{
- IDictionary tmpSigned = signed.ToDictionary();
- tmpSigned.Remove(CmsAttributes.ContentType);
- signed = new Asn1.Cms.AttributeTable(tmpSigned);
+ signed = signed.Remove(CmsAttributes.ContentType);
}
}
diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
index e247beea0..91a8b4a43 100644
--- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
@@ -174,9 +174,7 @@ namespace Org.BouncyCastle.Cms
{
if (signed != null && signed[CmsAttributes.ContentType] != null)
{
- IDictionary tmpSigned = signed.ToDictionary();
- tmpSigned.Remove(CmsAttributes.ContentType);
- signed = new Asn1.Cms.AttributeTable(tmpSigned);
+ signed = signed.Remove(CmsAttributes.ContentType);
}
}
diff --git a/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs b/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs
index 2730d93e0..678d8269b 100644
--- a/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs
+++ b/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Cms
{
@@ -13,14 +13,14 @@ namespace Org.BouncyCastle.Cms
public class DefaultAuthenticatedAttributeTableGenerator
: CmsAttributeTableGenerator
{
- private readonly IDictionary table;
+ private readonly IDictionary<DerObjectIdentifier, object> m_table;
/**
* Initialise to use all defaults
*/
public DefaultAuthenticatedAttributeTableGenerator()
{
- table = Platform.CreateHashtable();
+ m_table = new Dictionary<DerObjectIdentifier, object>();
}
/**
@@ -33,11 +33,11 @@ namespace Org.BouncyCastle.Cms
{
if (attributeTable != null)
{
- table = attributeTable.ToDictionary();
+ m_table = attributeTable.ToDictionary();
}
else
{
- table = Platform.CreateHashtable();
+ m_table = new Dictionary<DerObjectIdentifier, object>();
}
}
@@ -51,12 +51,12 @@ namespace Org.BouncyCastle.Cms
*
* @return a filled in IDictionary of attributes.
*/
- protected virtual IDictionary CreateStandardAttributeTable(
+ protected virtual IDictionary<DerObjectIdentifier, object> CreateStandardAttributeTable(
IDictionary parameters)
{
- IDictionary std = Platform.CreateHashtable(table);
+ var std = new Dictionary<DerObjectIdentifier, object>(m_table);
- if (!std.Contains(CmsAttributes.ContentType))
+ if (!std.ContainsKey(CmsAttributes.ContentType))
{
DerObjectIdentifier contentType = (DerObjectIdentifier)
parameters[CmsAttributeTableParameter.ContentType];
@@ -65,7 +65,7 @@ namespace Org.BouncyCastle.Cms
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,
@@ -76,14 +76,13 @@ namespace Org.BouncyCastle.Cms
return std;
}
- /**
+ /**
* @param parameters source parameters
* @return the populated attribute table
*/
- public virtual AttributeTable GetAttributes(
- IDictionary parameters)
+ public virtual AttributeTable GetAttributes(IDictionary parameters)
{
- IDictionary table = CreateStandardAttributeTable(parameters);
+ var table = CreateStandardAttributeTable(parameters);
return new AttributeTable(table);
}
}
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);
}
}
|