diff options
Diffstat (limited to 'crypto/src/tsp')
-rw-r--r-- | crypto/src/tsp/TimeStampRequestGenerator.cs | 50 |
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)); |