summary refs log tree commit diff
path: root/crypto/src/x509
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/src/x509
parentObsoleteAttribute cleanup (diff)
downloadBouncyCastle.NET-ed25519-d2c5b877bf9dad0ef9b393af2c17a6445780f0c4.tar.xz
ObsoleteAttribute cleanup
Diffstat (limited to 'crypto/src/x509')
-rw-r--r--crypto/src/x509/X509V1CertificateGenerator.cs69
-rw-r--r--crypto/src/x509/X509V2AttributeCertificateGenerator.cs54
-rw-r--r--crypto/src/x509/X509V2CRLGenerator.cs55
-rw-r--r--crypto/src/x509/X509V3CertificateGenerator.cs55
4 files changed, 10 insertions, 223 deletions
diff --git a/crypto/src/x509/X509V1CertificateGenerator.cs b/crypto/src/x509/X509V1CertificateGenerator.cs
index c571d2525..99543778b 100644
--- a/crypto/src/x509/X509V1CertificateGenerator.cs
+++ b/crypto/src/x509/X509V1CertificateGenerator.cs
@@ -4,9 +4,7 @@ using System.Collections;
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.X509
@@ -16,10 +14,7 @@ namespace Org.BouncyCastle.X509
 	/// </summary>
 	public class X509V1CertificateGenerator
 	{
-		private V1TbsCertificateGenerator   tbsGen;
-		private DerObjectIdentifier         sigOID;
-		private AlgorithmIdentifier         sigAlgId;
-		private string                      signatureAlgorithm;
+		private V1TbsCertificateGenerator tbsGen;
 
 		/// <summary>
 		/// Default Constructor.
@@ -115,68 +110,17 @@ namespace Org.BouncyCastle.X509
 		}
 
 		/// <summary>
-		/// Set the signature algorithm that will be used to sign this certificate.
-		/// This can be either a name or an OID, names are treated as case insensitive.
-		/// </summary>
-		/// <param name="signatureAlgorithm">string representation of the algorithm name</param>
-		[Obsolete("Not needed if Generate used with an ISignatureFactory")]
-		public void SetSignatureAlgorithm(
-			string signatureAlgorithm)
-		{
-			this.signatureAlgorithm = signatureAlgorithm;
-
-			try
-			{
-				sigOID = X509Utilities.GetAlgorithmOid(signatureAlgorithm);
-			}
-			catch (Exception)
-			{
-				throw new ArgumentException("Unknown signature type requested", "signatureAlgorithm");
-			}
-
-			sigAlgId = X509Utilities.GetSigAlgID(sigOID, signatureAlgorithm);
-
-			tbsGen.SetSignature(sigAlgId);
-		}
-
-		/// <summary>
-		/// Generate a new X509Certificate.
-		/// </summary>
-		/// <param name="privateKey">The private key of the issuer used to sign this certificate.</param>
-		/// <returns>An X509Certificate.</returns>
-		[Obsolete("Use Generate with an ISignatureFactory")]
-		public X509Certificate Generate(
-			AsymmetricKeyParameter privateKey)
-		{
-			return Generate(privateKey, null);
-		}
-
-        /// <summary>
-        /// Generate a new X509Certificate specifying a SecureRandom instance that you would like to use.
-        /// </summary>
-        /// <param name="privateKey">The private key of the issuer used to sign this certificate.</param>
-        /// <param name="random">The Secure Random you want to use.</param>
-        /// <returns>An X509Certificate.</returns>
-		[Obsolete("Use Generate with an ISignatureFactory")]
-		public X509Certificate Generate(
-			AsymmetricKeyParameter	privateKey,
-			SecureRandom			random)
-		{
-			return Generate(new Asn1SignatureFactory(signatureAlgorithm, privateKey, random));
-		}
-
-		/// <summary>
 		/// Generate a new X509Certificate using the passed in SignatureCalculator.
 		/// </summary>
-		/// <param name="signatureCalculatorFactory">A signature calculator factory with the necessary algorithm details.</param>
+		/// <param name="signatureFactory">A signature calculator factory with the necessary algorithm details.</param>
 		/// <returns>An X509Certificate.</returns>
-		public X509Certificate Generate(ISignatureFactory signatureCalculatorFactory)
+		public X509Certificate Generate(ISignatureFactory signatureFactory)
 		{
-			tbsGen.SetSignature ((AlgorithmIdentifier)signatureCalculatorFactory.AlgorithmDetails);
+			tbsGen.SetSignature((AlgorithmIdentifier)signatureFactory.AlgorithmDetails);
 
 			TbsCertificateStructure tbsCert = tbsGen.GenerateTbsCertificate();
 
-            IStreamCalculator streamCalculator = signatureCalculatorFactory.CreateCalculator();
+            IStreamCalculator streamCalculator = signatureFactory.CreateCalculator();
 
             byte[] encoded = tbsCert.GetDerEncoded();
 
@@ -184,7 +128,8 @@ namespace Org.BouncyCastle.X509
 
             Platform.Dispose(streamCalculator.Stream);
 
-            return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculatorFactory.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Collect());
+            return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureFactory.AlgorithmDetails,
+				((IBlockResult)streamCalculator.GetResult()).Collect());
 		}
 
 		private X509Certificate GenerateJcaObject(
diff --git a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
index f49eea63f..643604181 100644
--- a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
+++ b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
@@ -4,9 +4,7 @@ using System.Collections;
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Security.Certificates;
 using Org.BouncyCastle.Utilities;
 
@@ -17,10 +15,7 @@ namespace Org.BouncyCastle.X509
 	{
 		private readonly X509ExtensionsGenerator extGenerator = new X509ExtensionsGenerator();
 
-		private V2AttributeCertificateInfoGenerator	acInfoGen;
-		private DerObjectIdentifier sigOID;
-		private AlgorithmIdentifier sigAlgId;
-		private string signatureAlgorithm;
+		private V2AttributeCertificateInfoGenerator acInfoGen;
 
 		public X509V2AttributeCertificateGenerator()
 		{
@@ -67,31 +62,6 @@ namespace Org.BouncyCastle.X509
 			acInfoGen.SetEndDate(new DerGeneralizedTime(date));
 		}
 
-        /// <summary>
-        /// Set the signature algorithm. This can be either a name or an OID, names
-        /// are treated as case insensitive.
-        /// </summary>
-        /// <param name="signatureAlgorithm">The algorithm name.</param>
-        [Obsolete("Not needed if Generate used with an ISignatureFactory")]
-        public void SetSignatureAlgorithm(
-			string signatureAlgorithm)
-		{
-			this.signatureAlgorithm = signatureAlgorithm;
-
-			try
-			{
-				sigOID = X509Utilities.GetAlgorithmOid(signatureAlgorithm);
-			}
-			catch (Exception)
-			{
-				throw new ArgumentException("Unknown signature type requested");
-			}
-
-			sigAlgId = X509Utilities.GetSigAlgID(sigOID, signatureAlgorithm);
-
-			acInfoGen.SetSignature(sigAlgId);
-		}
-
 		/// <summary>Add an attribute.</summary>
 		public void AddAttribute(
 			X509Attribute attribute)
@@ -130,28 +100,6 @@ namespace Org.BouncyCastle.X509
 		}
 
         /// <summary>
-        /// Generate an X509 certificate, based on the current issuer and subject.
-        /// </summary>
-        [Obsolete("Use Generate with an ISignatureFactory")]
-        public IX509AttributeCertificate Generate(
-			AsymmetricKeyParameter privateKey)
-		{
-			return Generate(privateKey, null);
-		}
-
-        /// <summary>
-        /// Generate an X509 certificate, based on the current issuer and subject,
-        /// using the supplied source of randomness, if required.
-        /// </summary>
-        [Obsolete("Use Generate with an ISignatureFactory")]
-        public IX509AttributeCertificate Generate(
-			AsymmetricKeyParameter	privateKey,
-			SecureRandom			random)
-        {
-            return Generate(new Asn1SignatureFactory(signatureAlgorithm, privateKey, random));
-        }
-
-        /// <summary>
         /// Generate a new X.509 Attribute Certificate using the passed in SignatureCalculator.
         /// </summary>
         /// <param name="signatureCalculatorFactory">A signature calculator factory with the necessary algorithm details.</param>
diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs
index d16178ffa..ba5c7de2d 100644
--- a/crypto/src/x509/X509V2CRLGenerator.cs
+++ b/crypto/src/x509/X509V2CRLGenerator.cs
@@ -21,10 +21,7 @@ namespace Org.BouncyCastle.X509
 	{
 		private readonly X509ExtensionsGenerator extGenerator = new X509ExtensionsGenerator();
 
-		private V2TbsCertListGenerator	tbsGen;
-		private DerObjectIdentifier		sigOID;
-		private AlgorithmIdentifier		sigAlgId;
-		private string					signatureAlgorithm;
+		private V2TbsCertListGenerator tbsGen;
 
 		public X509V2CrlGenerator()
 		{
@@ -130,30 +127,6 @@ namespace Org.BouncyCastle.X509
 			}
 		}
 
-        /// <summary>
-        /// Set the signature algorithm that will be used to sign this CRL.
-        /// </summary>
-        /// <param name="signatureAlgorithm"/>
-        [Obsolete("Not needed if Generate used with an ISignatureFactory")]
-        public void SetSignatureAlgorithm(
-			string signatureAlgorithm)
-		{
-			this.signatureAlgorithm = signatureAlgorithm;
-
-			try
-			{
-				sigOID = X509Utilities.GetAlgorithmOid(signatureAlgorithm);
-			}
-			catch (Exception e)
-			{
-				throw new ArgumentException("Unknown signature type requested", e);
-			}
-
-			sigAlgId = X509Utilities.GetSigAlgID(sigOID, signatureAlgorithm);
-
-			tbsGen.SetSignature(sigAlgId);
-		}
-
 		/**
 		* add a given extension field for the standard extensions tag (tag 0)
 		*/
@@ -199,32 +172,6 @@ namespace Org.BouncyCastle.X509
 		}
 
         /// <summary>
-        /// Generate an X.509 CRL, based on the current issuer and subject.
-        /// </summary>
-        /// <param name="privateKey">The private key of the issuer that is signing this certificate.</param>
-        /// <returns>An X509Crl.</returns>
-        [Obsolete("Use Generate with an ISignatureFactory")]
-        public X509Crl Generate(
-            AsymmetricKeyParameter privateKey)
-        {
-            return Generate(privateKey, null);
-        }
-
-        /// <summary>
-        /// Generate an X.509 CRL, based on the current issuer and subject using the specified secure random.
-        /// </summary>
-        /// <param name="privateKey">The private key of the issuer that is signing this certificate.</param>
-        /// <param name="random">Your Secure Random instance.</param>
-        /// <returns>An X509Crl.</returns>
-        [Obsolete("Use Generate with an ISignatureFactory")]
-        public X509Crl Generate(
-            AsymmetricKeyParameter privateKey,
-            SecureRandom random)
-        {
-            return Generate(new Asn1SignatureFactory(signatureAlgorithm, privateKey, random));
-        }
-
-        /// <summary>
         /// Generate a new X509Crl using the passed in SignatureCalculator.
         /// </summary>
 		/// <param name="signatureCalculatorFactory">A signature calculator factory with the necessary algorithm details.</param>
diff --git a/crypto/src/x509/X509V3CertificateGenerator.cs b/crypto/src/x509/X509V3CertificateGenerator.cs
index bc619c37b..47e58ddb5 100644
--- a/crypto/src/x509/X509V3CertificateGenerator.cs
+++ b/crypto/src/x509/X509V3CertificateGenerator.cs
@@ -20,10 +20,7 @@ namespace Org.BouncyCastle.X509
     {
 		private readonly X509ExtensionsGenerator extGenerator = new X509ExtensionsGenerator();
 
-		private V3TbsCertificateGenerator	tbsGen;
-        private DerObjectIdentifier			sigOid;
-        private AlgorithmIdentifier			sigAlgId;
-        private string						signatureAlgorithm;
+		private V3TbsCertificateGenerator tbsGen;
 
 		public X509V3CertificateGenerator()
         {
@@ -108,30 +105,6 @@ namespace Org.BouncyCastle.X509
         }
 
 		/// <summary>
-        /// Set the signature algorithm that will be used to sign this certificate.
-        /// </summary>
-        /// <param name="signatureAlgorithm"/>
-		[Obsolete("Not needed if Generate used with an ISignatureFactory")]
-        public void SetSignatureAlgorithm(
-			string signatureAlgorithm)
-        {
-			this.signatureAlgorithm = signatureAlgorithm;
-
-			try
-			{
-				sigOid = X509Utilities.GetAlgorithmOid(signatureAlgorithm);
-			}
-			catch (Exception)
-			{
-				throw new ArgumentException("Unknown signature type requested: " + signatureAlgorithm);
-			}
-
-			sigAlgId = X509Utilities.GetSigAlgID(sigOid, signatureAlgorithm);
-
-			tbsGen.SetSignature(sigAlgId);
-		}
-
-		/// <summary>
 		/// Set the subject unique ID - note: it is very rare that it is correct to do this.
 		/// </summary>
 		/// <param name="uniqueID"/>
@@ -272,32 +245,6 @@ namespace Org.BouncyCastle.X509
 		}
 
 		/// <summary>
-        /// Generate an X509Certificate.
-        /// </summary>
-        /// <param name="privateKey">The private key of the issuer that is signing this certificate.</param>
-        /// <returns>An X509Certificate.</returns>
-		[Obsolete("Use Generate with an ISignatureFactory")]
-		public X509Certificate Generate(
-			AsymmetricKeyParameter privateKey)
-        {
-            return Generate(privateKey, null);
-        }
-
-		/// <summary>
-		/// Generate an X509Certificate using your own SecureRandom.
-		/// </summary>
-		/// <param name="privateKey">The private key of the issuer that is signing this certificate.</param>
-		/// <param name="random">You Secure Random instance.</param>
-		/// <returns>An X509Certificate.</returns>
-		[Obsolete("Use Generate with an ISignatureFactory")]
-		public X509Certificate Generate(
-			AsymmetricKeyParameter	privateKey,
-			SecureRandom			random)
-		{
-			return Generate(new Asn1SignatureFactory(signatureAlgorithm, privateKey, random));
-		}
-
-		/// <summary>
 		/// Generate a new X509Certificate using the passed in SignatureCalculator.
 		/// </summary>
 		/// <param name="signatureCalculatorFactory">A signature calculator factory with the necessary algorithm details.</param>