From b9b0bae81c983a9076c4749eace11f4e4c77e075 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 30 Jul 2023 22:39:07 +0700 Subject: Refactoring around X509 --- .../test/src/cms/test/EnvelopedDataStreamTest.cs | 2 +- crypto/test/src/cms/test/EnvelopedDataTest.cs | 2 +- crypto/test/src/ocsp/test/OCSPTest.cs | 22 +++++++++++----------- crypto/test/src/test/AttrCertSelectorTest.cs | 2 +- crypto/test/src/test/TestUtilities.cs | 6 +++--- crypto/test/src/test/X509StoreTest.cs | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) (limited to 'crypto/test') diff --git a/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs b/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs index 365d0e671..0962d5bea 100644 --- a/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs +++ b/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs @@ -497,7 +497,7 @@ namespace Org.BouncyCastle.Cms.Tests var recSel = new RecipientID { - Issuer = PrincipalUtilities.GetIssuerX509Principal(ReciECCert), + Issuer = ReciECCert.IssuerDN, SerialNumber = ReciECCert.SerialNumber }; diff --git a/crypto/test/src/cms/test/EnvelopedDataTest.cs b/crypto/test/src/cms/test/EnvelopedDataTest.cs index 1c5d1c953..02c76a0c1 100644 --- a/crypto/test/src/cms/test/EnvelopedDataTest.cs +++ b/crypto/test/src/cms/test/EnvelopedDataTest.cs @@ -910,7 +910,7 @@ namespace Org.BouncyCastle.Cms.Tests byte[] expectedData, X509Certificate reciCert, AsymmetricKeyParameter reciPrivKey) { RecipientID rid = new RecipientID(); - rid.Issuer = PrincipalUtilities.GetIssuerX509Principal(reciCert); + rid.Issuer = reciCert.IssuerDN; rid.SerialNumber = reciCert.SerialNumber; RecipientInformation recipient = recipients[rid]; diff --git a/crypto/test/src/ocsp/test/OCSPTest.cs b/crypto/test/src/ocsp/test/OCSPTest.cs index 73e2ff9f7..7b2e44781 100644 --- a/crypto/test/src/ocsp/test/OCSPTest.cs +++ b/crypto/test/src/ocsp/test/OCSPTest.cs @@ -221,7 +221,7 @@ namespace Org.BouncyCastle.Ocsp.Tests // // general id value for our test issuer cert and a serial number. // - CertificateID id = new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One); + CertificateID id = new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One); // // basic request generation @@ -260,7 +260,7 @@ namespace Org.BouncyCastle.Ocsp.Tests gen.SetRequestorName(new GeneralName(GeneralName.DirectoryName, new X509Name("CN=fred"))); - gen.AddRequest(new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + gen.AddRequest(new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); chain[0] = testCert; @@ -328,7 +328,7 @@ namespace Org.BouncyCastle.Ocsp.Tests gen.SetRequestExtensions(new X509Extensions(oids, values)); - gen.AddRequest(new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + gen.AddRequest(new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); chain[0] = testCert; @@ -407,7 +407,7 @@ namespace Org.BouncyCastle.Ocsp.Tests // // general id value for our test issuer cert and a serial number. // - CertificateID id = new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One); + CertificateID id = new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One); // // basic request generation @@ -415,7 +415,7 @@ namespace Org.BouncyCastle.Ocsp.Tests OcspReqGenerator gen = new OcspReqGenerator(); gen.AddRequest( - new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); OcspReq req = gen.Generate(); @@ -448,7 +448,7 @@ namespace Org.BouncyCastle.Ocsp.Tests gen.SetRequestorName(new GeneralName(GeneralName.DirectoryName, new X509Name("CN=fred"))); gen.AddRequest( - new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); chain[0] = testCert; @@ -517,7 +517,7 @@ namespace Org.BouncyCastle.Ocsp.Tests gen.SetRequestExtensions(new X509Extensions(oids, values)); gen.AddRequest( - new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); chain[0] = testCert; @@ -609,7 +609,7 @@ namespace Org.BouncyCastle.Ocsp.Tests // // general id value for our test issuer cert and a serial number. // - CertificateID id = new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One); + CertificateID id = new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One); // // basic request generation @@ -617,7 +617,7 @@ namespace Org.BouncyCastle.Ocsp.Tests OcspReqGenerator gen = new OcspReqGenerator(); gen.AddRequest( - new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); OcspReq req = gen.Generate(); @@ -650,7 +650,7 @@ namespace Org.BouncyCastle.Ocsp.Tests gen.SetRequestorName(new GeneralName(GeneralName.DirectoryName, new X509Name("CN=fred"))); gen.AddRequest( - new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); chain[0] = testCert; @@ -719,7 +719,7 @@ namespace Org.BouncyCastle.Ocsp.Tests gen.SetRequestExtensions(new X509Extensions(oids, values)); gen.AddRequest( - new CertificateID(CertificateID.HashSha1, testCert, BigInteger.One)); + new CertificateID(CertificateID.DigestSha1, testCert, BigInteger.One)); chain[0] = testCert; diff --git a/crypto/test/src/test/AttrCertSelectorTest.cs b/crypto/test/src/test/AttrCertSelectorTest.cs index 1e82f810c..664d2c2fc 100644 --- a/crypto/test/src/test/AttrCertSelectorTest.cs +++ b/crypto/test/src/test/AttrCertSelectorTest.cs @@ -105,7 +105,7 @@ namespace Org.BouncyCastle.Tests new DerSequence(roleSyntax)); gen.AddAttribute(attributes); - gen.SetHolder(new AttributeCertificateHolder(PrincipalUtilities.GetSubjectX509Principal(iCert))); + gen.SetHolder(new AttributeCertificateHolder(iCert.SubjectDN)); gen.SetIssuer(new AttributeCertificateIssuer(new X509Name("cn=test"))); gen.SetNotBefore(DateTime.UtcNow.AddSeconds(-50)); gen.SetNotAfter(DateTime.UtcNow.AddSeconds(50)); diff --git a/crypto/test/src/test/TestUtilities.cs b/crypto/test/src/test/TestUtilities.cs index be983637c..7a94288a9 100644 --- a/crypto/test/src/test/TestUtilities.cs +++ b/crypto/test/src/test/TestUtilities.cs @@ -53,7 +53,7 @@ namespace Org.BouncyCastle.Tests X509V3CertificateGenerator certGen = new X509V3CertificateGenerator(); certGen.SetSerialNumber(BigInteger.One); - certGen.SetIssuerDN(PrincipalUtilities.GetSubjectX509Principal(caCert)); + certGen.SetIssuerDN(caCert.SubjectDN); certGen.SetNotBefore(DateTime.UtcNow.AddSeconds(-50)); certGen.SetNotAfter(DateTime.UtcNow.AddSeconds(50)); certGen.SetSubjectDN(new X509Name("CN=Test Intermediate Certificate")); @@ -75,7 +75,7 @@ namespace Org.BouncyCastle.Tests X509V3CertificateGenerator certGen = new X509V3CertificateGenerator(); certGen.SetSerialNumber(BigInteger.One); - certGen.SetIssuerDN(PrincipalUtilities.GetSubjectX509Principal(caCert)); + certGen.SetIssuerDN(caCert.SubjectDN); certGen.SetNotBefore(DateTime.UtcNow.AddSeconds(-50)); certGen.SetNotAfter(DateTime.UtcNow.AddSeconds(50)); certGen.SetSubjectDN(new X509Name("CN=Test End Certificate")); @@ -97,7 +97,7 @@ namespace Org.BouncyCastle.Tests X509V2CrlGenerator crlGen = new X509V2CrlGenerator(); DateTime now = DateTime.UtcNow; - crlGen.SetIssuerDN(PrincipalUtilities.GetSubjectX509Principal(caCert)); + crlGen.SetIssuerDN(caCert.SubjectDN); crlGen.SetThisUpdate(now); crlGen.SetNextUpdate(now.AddSeconds(100)); diff --git a/crypto/test/src/test/X509StoreTest.cs b/crypto/test/src/test/X509StoreTest.cs index 2a8d44424..5ce46d0dc 100644 --- a/crypto/test/src/test/X509StoreTest.cs +++ b/crypto/test/src/test/X509StoreTest.cs @@ -81,7 +81,7 @@ namespace Org.BouncyCastle.Tests // Searching for rootCert by subjectDN X509CertStoreSelector targetConstraints = new X509CertStoreSelector(); - targetConstraints.Subject = PrincipalUtilities.GetSubjectX509Principal(rootCert); + targetConstraints.Subject = rootCert.SubjectDN; var certs = new List(certStore.EnumerateMatches(targetConstraints)); if (certs.Count != 1 || !certs.Contains(rootCert)) { @@ -90,7 +90,7 @@ namespace Org.BouncyCastle.Tests // Searching for rootCert by subjectDN encoded as byte targetConstraints = new X509CertStoreSelector(); - targetConstraints.Subject = PrincipalUtilities.GetSubjectX509Principal(rootCert); + targetConstraints.Subject = rootCert.SubjectDN; certs = new List(certStore.EnumerateMatches(targetConstraints)); if (certs.Count != 1 || !certs.Contains(rootCert)) { @@ -111,7 +111,7 @@ namespace Org.BouncyCastle.Tests // Searching for interCert by issuerDN targetConstraints = new X509CertStoreSelector(); - targetConstraints.Issuer = PrincipalUtilities.GetSubjectX509Principal(rootCert); + targetConstraints.Issuer = rootCert.SubjectDN; certs = new List(certStore.EnumerateMatches(targetConstraints)); if (certs.Count != 2) { -- cgit 1.4.1