From 18c67ac1339c9ca4f3604f5e5d44da0263b9ad21 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 28 Jun 2022 11:01:05 +0700 Subject: Generics migration in Cms --- .../src/cms/test/AuthenticatedDataStreamTest.cs | 5 +-- crypto/test/src/cms/test/AuthenticatedDataTest.cs | 11 +++--- crypto/test/src/cms/test/CMSTestUtil.cs | 1 - .../test/src/cms/test/EnvelopedDataStreamTest.cs | 22 +++++------ crypto/test/src/cms/test/EnvelopedDataTest.cs | 46 +++++++++++----------- crypto/test/src/cms/test/MiscDataStreamTest.cs | 1 - crypto/test/src/cms/test/Rfc4134Test.cs | 13 +++--- crypto/test/src/cms/test/SignedDataStreamTest.cs | 18 ++++----- crypto/test/src/cms/test/SignedDataTest.cs | 41 ++++++++++--------- crypto/test/src/tsp/test/NewTspTest.cs | 13 +++--- 10 files changed, 79 insertions(+), 92 deletions(-) (limited to 'crypto/test') diff --git a/crypto/test/src/cms/test/AuthenticatedDataStreamTest.cs b/crypto/test/src/cms/test/AuthenticatedDataStreamTest.cs index 68f38d190..8ae275a69 100644 --- a/crypto/test/src/cms/test/AuthenticatedDataStreamTest.cs +++ b/crypto/test/src/cms/test/AuthenticatedDataStreamTest.cs @@ -1,15 +1,12 @@ using System; -using System.Collections; using System.IO; using System.Text; using NUnit.Framework; -using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Pkcs; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Utilities; -using Org.BouncyCastle.Utilities.Encoders; using Org.BouncyCastle.X509; namespace Org.BouncyCastle.Cms.Tests @@ -94,7 +91,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ad.MacAlgOid, macAlg); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); diff --git a/crypto/test/src/cms/test/AuthenticatedDataTest.cs b/crypto/test/src/cms/test/AuthenticatedDataTest.cs index 55f220265..f1e7103b2 100644 --- a/crypto/test/src/cms/test/AuthenticatedDataTest.cs +++ b/crypto/test/src/cms/test/AuthenticatedDataTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Text; using NUnit.Framework; @@ -167,7 +166,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(CmsAuthenticatedDataGenerator.DesEde3Cbc, ad.MacAlgOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -199,7 +198,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(CmsAuthenticatedDataGenerator.DesEde3Cbc, ad.MacAlgOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -230,7 +229,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ad.MacAlgOid, macAlg); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -266,7 +265,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(CmsAuthenticatedDataGenerator.DesEde3Cbc, ad.MacAlgOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -297,7 +296,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(CmsAuthenticatedDataGenerator.DesEde3Cbc, ad.MacAlgOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); diff --git a/crypto/test/src/cms/test/CMSTestUtil.cs b/crypto/test/src/cms/test/CMSTestUtil.cs index 596072937..b6818bb8a 100644 --- a/crypto/test/src/cms/test/CMSTestUtil.cs +++ b/crypto/test/src/cms/test/CMSTestUtil.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; diff --git a/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs b/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs index 39776e852..ddf14e9a6 100644 --- a/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs +++ b/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.IO; using System.Text; @@ -7,14 +6,12 @@ using NUnit.Framework; using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Pkcs; -using Org.BouncyCastle.Cms; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Security; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Encoders; using Org.BouncyCastle.Utilities.IO; -using Org.BouncyCastle.Utilities.Test; using Org.BouncyCastle.X509; namespace Org.BouncyCastle.Cms.Tests @@ -109,7 +106,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ep.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); // PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyData); // KeyFactory keyFact = KeyFactory.GetInstance("RSA"); @@ -138,7 +135,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ep.EncryptionAlgOid, expectedOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); foreach (RecipientInformation recipient in c) { @@ -319,15 +316,14 @@ namespace Org.BouncyCastle.Cms.Tests outStream.Close(); - CmsEnvelopedDataParser ep = new CmsEnvelopedDataParser(bOut.ToArray()); - RecipientInformationStore recipients = ep.GetRecipientInfos(); - ICollection c = recipients.GetRecipients(); - - IEnumerator e = c.GetEnumerator(); + CmsEnvelopedDataParser ep = new CmsEnvelopedDataParser(bOut.ToArray()); + RecipientInformationStore recipients = ep.GetRecipientInfos(); + var c = recipients.GetRecipients(); + var e = c.GetEnumerator(); if (e.MoveNext()) { - RecipientInformation recipient = (RecipientInformation) e.Current; + RecipientInformation recipient = e.Current; Assert.AreEqual(recipient.KeyEncryptionAlgOid, PkcsObjectIdentifiers.RsaEncryption.Id); @@ -382,7 +378,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ep.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); foreach (RecipientInformation recipient in c) { @@ -423,7 +419,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ep.EncryptionAlgOid, CmsEnvelopedDataGenerator.DesEde3Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); foreach (RecipientInformation recipient in c) { diff --git a/crypto/test/src/cms/test/EnvelopedDataTest.cs b/crypto/test/src/cms/test/EnvelopedDataTest.cs index 1017d35db..9df25f41e 100644 --- a/crypto/test/src/cms/test/EnvelopedDataTest.cs +++ b/crypto/test/src/cms/test/EnvelopedDataTest.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.Text; using NUnit.Framework; @@ -10,11 +10,9 @@ using Org.BouncyCastle.Asn1.Ntt; using Org.BouncyCastle.Asn1.Oiw; using Org.BouncyCastle.Asn1.Pkcs; using Org.BouncyCastle.Asn1.X509; -using Org.BouncyCastle.Cms; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Operators; using Org.BouncyCastle.Crypto.Parameters; -using Org.BouncyCastle.Operators; using Org.BouncyCastle.Security; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Encoders; @@ -194,7 +192,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.DesEde3Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -225,7 +223,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, "1.2.840.113549.3.4"); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -255,7 +253,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, "1.2.840.113549.3.4"); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -284,7 +282,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, OiwObjectIdentifiers.DesCbc.Id); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -314,7 +312,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -344,7 +342,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -373,7 +371,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -410,7 +408,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -443,7 +441,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -537,7 +535,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.IsTrue(asn1Params.IsInstanceOfType(ed.EncryptionAlgorithmID.Parameters)); } - ArrayList c = new ArrayList(recipients.GetRecipients()); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -565,7 +563,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.DesEde3Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -654,7 +652,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.DesEde3Cbc); - ArrayList c = new ArrayList(recipients.GetRecipients()); + var c = recipients.GetRecipients(); Assert.IsTrue(c.Count > 0); @@ -727,7 +725,7 @@ namespace Org.BouncyCastle.Cms.Tests CmsEnvelopedDataGenerator edGen = new CmsEnvelopedDataGenerator(); - ArrayList recipientCerts = new ArrayList(); + var recipientCerts = new List(); recipientCerts.Add(ReciECCert); recipientCerts.Add(ReciECCert2); @@ -817,7 +815,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual("1.2.840.113549.3.7", ed.EncryptionAlgOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -844,14 +842,14 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual("1.2.840.113549.3.2", ed.EncryptionAlgOid); - ICollection c = recipients.GetRecipients(); - IEnumerator e = c.GetEnumerator(); + var c = recipients.GetRecipients(); + var e = c.GetEnumerator(); if (e.MoveNext()) { do { - RecipientInformation recipient = (RecipientInformation) e.Current; + RecipientInformation recipient = e.Current; if (recipient is KeyTransRecipientInformation) { @@ -895,7 +893,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -928,7 +926,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(ed.EncryptionAlgOid, CmsEnvelopedDataGenerator.Aes128Cbc); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -956,7 +954,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(wrapAlg, ed.EncryptionAlgOid); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(1, c.Count); @@ -981,7 +979,7 @@ namespace Org.BouncyCastle.Cms.Tests RecipientInformationStore recipients = ed.GetRecipientInfos(); - ICollection c = recipients.GetRecipients(); + var c = recipients.GetRecipients(); Assert.AreEqual(wrapAlg, ed.EncryptionAlgOid); Assert.AreEqual(1, c.Count); diff --git a/crypto/test/src/cms/test/MiscDataStreamTest.cs b/crypto/test/src/cms/test/MiscDataStreamTest.cs index 58259998b..6e665c887 100644 --- a/crypto/test/src/cms/test/MiscDataStreamTest.cs +++ b/crypto/test/src/cms/test/MiscDataStreamTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; diff --git a/crypto/test/src/cms/test/Rfc4134Test.cs b/crypto/test/src/cms/test/Rfc4134Test.cs index d47dd84ff..072f0655c 100644 --- a/crypto/test/src/cms/test/Rfc4134Test.cs +++ b/crypto/test/src/cms/test/Rfc4134Test.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using NUnit.Framework; @@ -158,15 +157,15 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(envelopedData.EncryptionAlgOid, symAlgorithmOID); - ArrayList c = new ArrayList(recipients.GetRecipients()); + var c = recipients.GetRecipients(); Assert.LessOrEqual(1, c.Count); Assert.GreaterOrEqual(2, c.Count); - VerifyRecipient((RecipientInformation)c[0], privKey); + VerifyRecipient(c[0], privKey); if (c.Count == 2) { - RecipientInformation recInfo = (RecipientInformation)c[1]; + RecipientInformation recInfo = c[1]; Assert.AreEqual(PkcsObjectIdentifiers.IdAlgCmsRC2Wrap.Id, recInfo.KeyEncryptionAlgOid); } @@ -183,7 +182,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(envelopedParser.EncryptionAlgOid, symAlgorithmOID); - ArrayList c = new ArrayList(recipients.GetRecipients()); + var c = recipients.GetRecipients(); Assert.LessOrEqual(1, c.Count); Assert.GreaterOrEqual(2, c.Count); @@ -217,9 +216,9 @@ namespace Org.BouncyCastle.Cms.Tests private SignerInformation GetFirstSignerInfo(SignerInformationStore store) { - IEnumerator e = store.GetSigners().GetEnumerator(); + var e = store.GetSigners().GetEnumerator(); e.MoveNext(); - return (SignerInformation)e.Current; + return e.Current; } private void VerifyCounterSignature(SignerInformation signInfo, byte[] certificate) diff --git a/crypto/test/src/cms/test/SignedDataStreamTest.cs b/crypto/test/src/cms/test/SignedDataStreamTest.cs index 15924cc47..37f41783d 100644 --- a/crypto/test/src/cms/test/SignedDataStreamTest.cs +++ b/crypto/test/src/cms/test/SignedDataStreamTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; @@ -541,7 +540,7 @@ namespace Org.BouncyCastle.Cms.Tests byte[] contentDigest = (byte[])gen.GetGeneratedDigests()[CmsSignedGenerator.DigestSha1]; - ArrayList signers = new ArrayList(sp.GetSignerInfos().GetSigners()); + var signers = sp.GetSignerInfos().GetSigners(); AttributeTable table = ((SignerInformation) signers[0]).SignedAttributes; Asn1.Cms.Attribute hash = table[CmsAttributes.MessageDigest]; @@ -576,7 +575,7 @@ namespace Org.BouncyCastle.Cms.Tests private class SignedGenAttributeTableGenerator : DefaultSignedAttributeTableGenerator { - public override AttributeTable GetAttributes(IDictionary parameters) + public override AttributeTable GetAttributes(IDictionary parameters) { var table = CreateStandardAttributeTable(parameters); @@ -592,8 +591,7 @@ namespace Org.BouncyCastle.Cms.Tests private class UnsignedGenAttributeTableGenerator : CmsAttributeTableGenerator { - public AttributeTable GetAttributes( - IDictionary parameters) + public AttributeTable GetAttributes(IDictionary parameters) { DerOctetString val = new DerOctetString((byte[])parameters[CmsAttributeTableParameter.Signature]); Asn1.Cms.Attribute attr = new Asn1.Cms.Attribute(dummyOid2, new DerSet(val)); @@ -629,7 +627,7 @@ namespace Org.BouncyCastle.Cms.Tests byte[] contentDigest = (byte[])gen.GetGeneratedDigests()[CmsSignedGenerator.DigestSha1]; - ArrayList signers = new ArrayList(sp.GetSignerInfos().GetSigners()); + var signers = sp.GetSignerInfos().GetSigners(); AttributeTable table = ((SignerInformation) signers[0]).SignedAttributes; Asn1.Cms.Attribute hash = table[CmsAttributes.MessageDigest]; @@ -787,9 +785,9 @@ namespace Org.BouncyCastle.Cms.Tests sd = new CmsSignedData(new CmsProcessableByteArray(data), newOut.ToArray()); - IEnumerator signerEnum = sd.GetSignerInfos().GetSigners().GetEnumerator(); + var signerEnum = sd.GetSignerInfos().GetSigners().GetEnumerator(); signerEnum.MoveNext(); - SignerInformation signer = (SignerInformation)signerEnum.Current; + SignerInformation signer = signerEnum.Current; Assert.AreEqual(signer.DigestAlgOid, CmsSignedDataStreamGenerator.DigestSha224); @@ -844,9 +842,9 @@ namespace Org.BouncyCastle.Cms.Tests sd = new CmsSignedData(newOut.ToArray()); - IEnumerator signerEnum = sd.GetSignerInfos().GetSigners().GetEnumerator(); + var signerEnum = sd.GetSignerInfos().GetSigners().GetEnumerator(); signerEnum.MoveNext(); - SignerInformation signer = (SignerInformation) signerEnum.Current; + SignerInformation signer = signerEnum.Current; Assert.AreEqual(signer.DigestAlgOid, CmsSignedDataStreamGenerator.DigestSha224); diff --git a/crypto/test/src/cms/test/SignedDataTest.cs b/crypto/test/src/cms/test/SignedDataTest.cs index 7147bc8da..d0702c836 100644 --- a/crypto/test/src/cms/test/SignedDataTest.cs +++ b/crypto/test/src/cms/test/SignedDataTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; @@ -381,7 +380,7 @@ namespace Org.BouncyCastle.Cms.Tests var x509Certs = s.GetCertificates(); SignerInformationStore signers = s.GetSignerInfos(); - ICollection c = signers.GetSigners(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -408,7 +407,7 @@ namespace Org.BouncyCastle.Cms.Tests var x509Certs = s.GetCertificates(); SignerInformationStore signers = s.GetSignerInfos(); - ICollection c = signers.GetSigners(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -444,15 +443,15 @@ namespace Org.BouncyCastle.Cms.Tests var x509Certs = CmsTestUtil.MakeCertStore(OrigCert, SignCert); CmsSignedDataGenerator gen = new CmsSignedDataGenerator(); - gen.AddSigner(OrigKP.Private, OrigCert, CmsSignedDataGenerator.DigestSha1); - gen.AddSigner(OrigKP.Private, OrigCert, CmsSignedDataGenerator.DigestMD5); + gen.AddSigner(OrigKP.Private, OrigCert, CmsSignedGenerator.DigestSha1); + gen.AddSigner(OrigKP.Private, OrigCert, CmsSignedGenerator.DigestMD5); gen.AddCertificates(x509Certs); CmsSignedData s = gen.Generate(msg); - IDictionary hashes = new Hashtable(); - hashes.Add(CmsSignedDataGenerator.DigestSha1, DigestUtilities.CalculateDigest("SHA1", data)); - hashes.Add(CmsSignedDataGenerator.DigestMD5, DigestUtilities.CalculateDigest("MD5", data)); + var hashes = new Dictionary(StringComparer.OrdinalIgnoreCase); + hashes.Add(CmsSignedGenerator.DigestSha1, DigestUtilities.CalculateDigest("SHA1", data)); + hashes.Add(CmsSignedGenerator.DigestMD5, DigestUtilities.CalculateDigest("MD5", data)); s = new CmsSignedData(hashes, s.GetEncoded()); @@ -482,7 +481,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(2, signers.Count); SignerID sid = null; - ICollection c = signers.GetSigners(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -576,7 +575,7 @@ namespace Org.BouncyCastle.Cms.Tests Assert.AreEqual(2, signers.Count); SignerID sid = null; - ICollection c = signers.GetSigners(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -969,7 +968,7 @@ namespace Org.BouncyCastle.Cms.Tests gen.AddCrls(x509Crls); CmsSignedData s = gen.Generate(msg, true); - SignerInformation origSigner = (SignerInformation) new ArrayList(s.GetSignerInfos().GetSigners())[0]; + SignerInformation origSigner = s.GetSignerInfos().GetSigners()[0]; SignerInformationStore counterSigners1 = gen.GenerateCounterSigners(origSigner); SignerInformationStore counterSigners2 = gen.GenerateCounterSigners(origSigner); @@ -977,7 +976,7 @@ namespace Org.BouncyCastle.Cms.Tests SignerInformation signer2 = SignerInformation.AddCounterSigners(signer1, counterSigners2); SignerInformationStore cs = signer2.GetCounterSignatures(); - ICollection csSigners = cs.GetSigners(); + var csSigners = cs.GetSigners(); Assert.AreEqual(2, csSigners.Count); foreach (SignerInformation cSigner in csSigners) @@ -1150,7 +1149,7 @@ namespace Org.BouncyCastle.Cms.Tests x509Crls = s.GetCrls(); SignerInformationStore signers = s.GetSignerInfos(); - ICollection c = signers.GetSigners(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -1223,7 +1222,7 @@ namespace Org.BouncyCastle.Cms.Tests var x509Certs = s.GetCertificates(); signers = s.GetSignerInfos(); - ICollection c = signers.GetSigners(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -1245,8 +1244,8 @@ namespace Org.BouncyCastle.Cms.Tests var x509Certs = s.GetCertificates(); - SignerInformationStore signers = s.GetSignerInfos(); - ICollection c = signers.GetSigners(); + SignerInformationStore signers = s.GetSignerInfos(); + var c = signers.GetSigners(); foreach (SignerInformation signer in c) { @@ -1459,9 +1458,9 @@ namespace Org.BouncyCastle.Cms.Tests // CmsSignedData sd = CmsSignedData.ReplaceSigners(original, newSD.GetSignerInfos()); - IEnumerator signerEnum = sd.GetSignerInfos().GetSigners().GetEnumerator(); + var signerEnum = sd.GetSignerInfos().GetSigners().GetEnumerator(); signerEnum.MoveNext(); - SignerInformation signer = (SignerInformation) signerEnum.Current; + SignerInformation signer = signerEnum.Current; Assert.AreEqual(CmsSignedDataGenerator.DigestSha224, signer.DigestAlgOid); @@ -1496,10 +1495,10 @@ namespace Org.BouncyCastle.Cms.Tests CmsSignedData sig = new CmsSignedData(GetInput("counterSig.p7m")); SignerInformationStore ss = sig.GetSignerInfos(); - ArrayList signers = new ArrayList(ss.GetSigners()); + var signers = ss.GetSigners(); SignerInformationStore cs = ((SignerInformation)signers[0]).GetCounterSignatures(); - ArrayList csSigners = new ArrayList(cs.GetSigners()); + var csSigners = cs.GetSigners(); Assert.AreEqual(1, csSigners.Count); foreach (SignerInformation cSigner in csSigners) @@ -1544,7 +1543,7 @@ namespace Org.BouncyCastle.Cms.Tests foreach (SignerInformation sigI in sd.GetSignerInfos().GetSigners()) { SignerInformationStore counter = sigI.GetCounterSignatures(); - IList sigs = new ArrayList(counter.GetSigners()); + var sigs = counter.GetSigners(); Assert.AreEqual(2, sigs.Count); } diff --git a/crypto/test/src/tsp/test/NewTspTest.cs b/crypto/test/src/tsp/test/NewTspTest.cs index 34be0dadf..c188cb26a 100644 --- a/crypto/test/src/tsp/test/NewTspTest.cs +++ b/crypto/test/src/tsp/test/NewTspTest.cs @@ -893,7 +893,8 @@ namespace Org.BouncyCastle.Tsp.Tests .Build(sigfact, cert); } - private class TestAttrGen : CmsAttributeTableGenerator + private class TestAttrGen + : CmsAttributeTableGenerator { private readonly EssCertID mEssCertID; private readonly EssCertIDv2 mEssCertIDv2; @@ -914,15 +915,17 @@ namespace Org.BouncyCastle.Tsp.Tests get { return mEssCertIDv2; } } - public Asn1.Cms.AttributeTable GetAttributes(IDictionary parameters) + public Asn1.Cms.AttributeTable GetAttributes(IDictionary parameters) { CmsAttributeTableGenerator attrGen = new DefaultSignedAttributeTableGenerator(); Asn1.Cms.AttributeTable table = attrGen.GetAttributes(parameters); - table = table.Add(PkcsObjectIdentifiers.IdAASigningCertificate, new SigningCertificate(EssCertID)); - table = table.Add(PkcsObjectIdentifiers.IdAASigningCertificateV2, new SigningCertificateV2(new EssCertIDv2[] { EssCertIDv2 })); - return table; + return table.Add( + new Asn1.Cms.Attribute(PkcsObjectIdentifiers.IdAASigningCertificate, + new DerSet(new SigningCertificate(EssCertID))), + new Asn1.Cms.Attribute(PkcsObjectIdentifiers.IdAASigningCertificateV2, + new DerSet(new SigningCertificateV2(new EssCertIDv2[]{ EssCertIDv2 })))); } } } -- cgit 1.4.1