summary refs log tree commit diff
path: root/crypto/src/tsp
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-27 02:19:14 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-27 02:19:14 +0700
commit4ea1816cffd5c8663bc9ae1234df0a70ef23fcd6 (patch)
treeeb4fe294ef230435928a573fadef3047b4466e9b /crypto/src/tsp
parentImplement generic IEnumerable in ASN.1 classes (diff)
downloadBouncyCastle.NET-ed25519-4ea1816cffd5c8663bc9ae1234df0a70ef23fcd6.tar.xz
Generics migration work
Diffstat (limited to 'crypto/src/tsp')
-rw-r--r--crypto/src/tsp/TimeStampRequestGenerator.cs50
1 files changed, 17 insertions, 33 deletions
diff --git a/crypto/src/tsp/TimeStampRequestGenerator.cs b/crypto/src/tsp/TimeStampRequestGenerator.cs
index f4462659b..2d629e972 100644
--- a/crypto/src/tsp/TimeStampRequestGenerator.cs
+++ b/crypto/src/tsp/TimeStampRequestGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Tsp;
@@ -19,17 +19,16 @@ namespace Org.BouncyCastle.Tsp
 
 		private DerBoolean certReq;
 
-		private IDictionary extensions = Platform.CreateHashtable();
-        private IList       extOrdering = Platform.CreateArrayList();
+		private Dictionary<DerObjectIdentifier, X509Extension> m_extensions =
+			new Dictionary<DerObjectIdentifier, X509Extension>();
+		private List<DerObjectIdentifier> m_ordering = new List<DerObjectIdentifier>();
 
-		public void SetReqPolicy(
-			string reqPolicy)
+		public void SetReqPolicy(string reqPolicy)
 		{
 			this.reqPolicy = new DerObjectIdentifier(reqPolicy);
 		}
 
-		public void SetCertReq(
-			bool certReq)
+		public void SetCertReq(bool certReq)
 		{
 			this.certReq = DerBoolean.GetInstance(certReq);
 		}
@@ -38,10 +37,7 @@ namespace Org.BouncyCastle.Tsp
 		 * add a given extension field for the standard extensions tag (tag 3)
 		 * @throws IOException
 		 */
-		public virtual void AddExtension(
-			DerObjectIdentifier	oid,
-			bool				critical,
-			Asn1Encodable 		extValue)
+		public virtual void AddExtension(DerObjectIdentifier oid, bool critical, Asn1Encodable extValue)
 		{
 			this.AddExtension(oid, critical, extValue.GetEncoded());
 		}
@@ -51,47 +47,35 @@ namespace Org.BouncyCastle.Tsp
 		 * The value parameter becomes the contents of the octet string associated
 		 * with the extension.
 		 */
-		public virtual void AddExtension(
-			DerObjectIdentifier	oid,
-			bool				critical,
-			byte[]				extValue)
+		public virtual void AddExtension(DerObjectIdentifier oid, bool critical, byte[] extValue)
 		{
-			extensions.Add(oid, new X509Extension(critical, new DerOctetString(extValue)));
-			extOrdering.Add(oid);
+			m_extensions.Add(oid, new X509Extension(critical, new DerOctetString(extValue)));
+			m_ordering.Add(oid);
 		}
 
-		public TimeStampRequest Generate(
-			string	digestAlgorithm,
-			byte[]	digest)
+		public TimeStampRequest Generate(string digestAlgorithm, byte[] digest)
 		{
-			return this.Generate(digestAlgorithm, digest, null);
+			return Generate(digestAlgorithm, digest, null);
 		}
 
-		public TimeStampRequest Generate(
-			string		digestAlgorithmOid,
-			byte[]		digest,
-			BigInteger	nonce)
+		public TimeStampRequest Generate(string digestAlgorithmOid, byte[] digest, BigInteger nonce)
 		{
 			if (digestAlgorithmOid == null)
-			{
 				throw new ArgumentException("No digest algorithm specified");
-			}
 
 			DerObjectIdentifier digestAlgOid = new DerObjectIdentifier(digestAlgorithmOid);
 
 			AlgorithmIdentifier algID = new AlgorithmIdentifier(digestAlgOid, DerNull.Instance);
 			MessageImprint messageImprint = new MessageImprint(algID, digest);
 
-			X509Extensions  ext = null;
+			X509Extensions ext = null;
 
-			if (extOrdering.Count != 0)
+			if (m_ordering.Count > 0)
 			{
-				ext = new X509Extensions(extOrdering, extensions);
+				ext = new X509Extensions(m_ordering, m_extensions);
 			}
 
-			DerInteger derNonce = nonce == null
-				?	null
-				:	new DerInteger(nonce);
+			DerInteger derNonce = nonce == null ? null : new DerInteger(nonce);
 
 			return new TimeStampRequest(
 				new TimeStampReq(messageImprint, reqPolicy, derNonce, certReq, ext));