summary refs log tree commit diff
path: root/crypto/test/src/pkcs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@gmail.com>2022-06-22 14:25:40 +0700
committerPeter Dettman <peter.dettman@gmail.com>2022-06-22 14:25:40 +0700
commitd2c5b877bf9dad0ef9b393af2c17a6445780f0c4 (patch)
treeb95ffdebbb8dcfc175530d9281baa1b77b035e9b /crypto/test/src/pkcs
parentObsoleteAttribute cleanup (diff)
downloadBouncyCastle.NET-ed25519-d2c5b877bf9dad0ef9b393af2c17a6445780f0c4.tar.xz
ObsoleteAttribute cleanup
Diffstat (limited to 'crypto/test/src/pkcs')
-rw-r--r--crypto/test/src/pkcs/examples/PKCS12Example.cs23
-rw-r--r--crypto/test/src/pkcs/test/PKCS12StoreTest.cs7
2 files changed, 12 insertions, 18 deletions
diff --git a/crypto/test/src/pkcs/examples/PKCS12Example.cs b/crypto/test/src/pkcs/examples/PKCS12Example.cs
index 002e14c38..06247bc3f 100644
--- a/crypto/test/src/pkcs/examples/PKCS12Example.cs
+++ b/crypto/test/src/pkcs/examples/PKCS12Example.cs
@@ -6,10 +6,10 @@ using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Pkcs;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Utilities.Date;
 using Org.BouncyCastle.X509;
 using Org.BouncyCastle.X509.Extension;
 
@@ -26,9 +26,6 @@ namespace Org.BouncyCastle.Pkcs.Examples
 	{
 		private static readonly char[] passwd = "hello world".ToCharArray();
 
-		private static readonly X509V1CertificateGenerator v1CertGen = new X509V1CertificateGenerator();
-		private static readonly X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
-
 		/**
 		* we generate the CA's certificate
 		*/
@@ -49,16 +46,16 @@ namespace Org.BouncyCastle.Pkcs.Examples
 			//
 			// create the certificate - version 1
 			//
+			ISignatureFactory signatureFactory = new Asn1SignatureFactory("SHA1WithRSAEncryption", privKey, null);
 
+			X509V1CertificateGenerator v1CertGen = new X509V1CertificateGenerator();
 			v1CertGen.SetSerialNumber(BigInteger.One);
 			v1CertGen.SetIssuerDN(new X509Name(issuer));
 			v1CertGen.SetNotBefore(DateTime.UtcNow.AddMonths(-1));
 			v1CertGen.SetNotAfter(DateTime.UtcNow.AddMonths(1));
 			v1CertGen.SetSubjectDN(new X509Name(subject));
 			v1CertGen.SetPublicKey(pubKey);
-			v1CertGen.SetSignatureAlgorithm("SHA1WithRSAEncryption");
-
-			X509Certificate cert = v1CertGen.Generate(privKey);
+			X509Certificate cert = v1CertGen.Generate(signatureFactory);
 
 			cert.CheckValidity(DateTime.UtcNow);
 
@@ -107,15 +104,13 @@ namespace Org.BouncyCastle.Pkcs.Examples
 			//
 			// create the certificate - version 3
 			//
-			v3CertGen.Reset();
-
+			X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
 			v3CertGen.SetSerialNumber(BigInteger.Two);
 			v3CertGen.SetIssuerDN(PrincipalUtilities.GetSubjectX509Principal(caCert));
 			v3CertGen.SetNotBefore(DateTime.UtcNow.AddMonths(-1));
 			v3CertGen.SetNotAfter(DateTime.UtcNow.AddMonths(1));
 			v3CertGen.SetSubjectDN(new X509Name(order, attrs));
 			v3CertGen.SetPublicKey(pubKey);
-			v3CertGen.SetSignatureAlgorithm("SHA1WithRSAEncryption");
 
 			//
 			// extensions
@@ -135,7 +130,7 @@ namespace Org.BouncyCastle.Pkcs.Examples
 				true,
 				new BasicConstraints(0));
 
-			X509Certificate cert = v3CertGen.Generate(caPrivKey);
+			X509Certificate cert = v3CertGen.Generate(new Asn1SignatureFactory("SHA1WithRSAEncryption", caPrivKey, null));
 
 			cert.CheckValidity(DateTime.UtcNow);
 
@@ -202,15 +197,13 @@ namespace Org.BouncyCastle.Pkcs.Examples
 			//
 			// create the certificate - version 3
 			//
-			v3CertGen.Reset();
-
+			X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
 			v3CertGen.SetSerialNumber(BigInteger.Three);
 			v3CertGen.SetIssuerDN(new X509Name(sOrder, sAttrs));
 			v3CertGen.SetNotBefore(DateTime.UtcNow.AddMonths(-1));
 			v3CertGen.SetNotAfter(DateTime.UtcNow.AddMonths(1));
 			v3CertGen.SetSubjectDN(new X509Name(order, attrs));
 			v3CertGen.SetPublicKey(pubKey);
-			v3CertGen.SetSignatureAlgorithm("SHA1WithRSAEncryption");
 
 			//
 			// add the extensions
@@ -225,7 +218,7 @@ namespace Org.BouncyCastle.Pkcs.Examples
 				false,
 				new AuthorityKeyIdentifierStructure(caPubKey));
 
-			X509Certificate cert = v3CertGen.Generate(caPrivKey);
+			X509Certificate cert = v3CertGen.Generate(new Asn1SignatureFactory("SHA1WithRSAEncryption", caPrivKey, null));
 
 			cert.CheckValidity(DateTime.UtcNow);
 
diff --git a/crypto/test/src/pkcs/test/PKCS12StoreTest.cs b/crypto/test/src/pkcs/test/PKCS12StoreTest.cs
index 1b49a5d02..884fd7449 100644
--- a/crypto/test/src/pkcs/test/PKCS12StoreTest.cs
+++ b/crypto/test/src/pkcs/test/PKCS12StoreTest.cs
@@ -8,9 +8,9 @@ using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Pkcs;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Pkcs;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
@@ -897,9 +897,10 @@ namespace Org.BouncyCastle.Pkcs.Tests
 			certGen.SetNotAfter(DateTime.UtcNow.AddDays(30));
 			certGen.SetSubjectDN(new X509Name(order, subjectAttrs));
 			certGen.SetPublicKey(pubKey);
-			certGen.SetSignatureAlgorithm("MD5WithRSAEncryption");
 
-			return new X509CertificateEntry(certGen.Generate(privKey));
+			ISignatureFactory signatureFactory = new Asn1SignatureFactory("MD5WithRSAEncryption", privKey, null);
+			X509Certificate cert = certGen.Generate(signatureFactory);
+			return new X509CertificateEntry(cert);
 		}
 
         private void DoTestCertsOnly()