summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-04-04 16:51:56 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-04-04 16:51:56 +0700
commite44889a47921e5af3d60d5b83a54b4b7313f797e (patch)
treed66d8610b591a751dc39315dbeaaa4ba7387fd61
parentAdd constructor from template certificate (diff)
downloadBouncyCastle.NET-ed25519-e44889a47921e5af3d60d5b83a54b4b7313f797e.tar.xz
Add constructor from template CRL
-rw-r--r--crypto/src/x509/X509V2CRLGenerator.cs35
1 files changed, 34 insertions, 1 deletions
diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs
index 01d7aee4a..d7c72d673 100644
--- a/crypto/src/x509/X509V2CRLGenerator.cs
+++ b/crypto/src/x509/X509V2CRLGenerator.cs
@@ -24,7 +24,40 @@ namespace Org.BouncyCastle.X509
 			tbsGen = new V2TbsCertListGenerator();
 		}
 
-		/**
+        /// <summary>Create a builder for a version 2 CRL, initialised with another CRL.</summary>
+		/// <param name="template">Template CRL to base the new one on.</param>
+        public X509V2CrlGenerator(X509Crl template)
+			: this(template.CertificateList)
+		{
+		}
+
+        public X509V2CrlGenerator(CertificateList template)
+        {
+            tbsGen = new V2TbsCertListGenerator();
+            tbsGen.SetIssuer(template.Issuer);
+            tbsGen.SetThisUpdate(template.ThisUpdate);
+            tbsGen.SetNextUpdate(template.NextUpdate);
+
+            AddCrl(new X509Crl(template));
+
+            var extensions = template.TbsCertList.Extensions;
+            if (extensions != null)
+            {
+				foreach (var oid in extensions.ExtensionOids)
+				{
+					if (X509Extensions.AltSignatureAlgorithm.Equals(oid) ||
+						X509Extensions.AltSignatureValue.Equals(oid))
+					{
+						continue;
+					}
+
+					X509Extension ext = extensions.GetExtension(oid);
+					extGenerator.AddExtension(oid, ext.critical, ext.Value.GetOctets());
+				}
+            }
+        }
+
+        /**
 		* reset the generator
 		*/
 		public void Reset()