From e44889a47921e5af3d60d5b83a54b4b7313f797e Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 4 Apr 2023 16:51:56 +0700 Subject: Add constructor from template CRL --- crypto/src/x509/X509V2CRLGenerator.cs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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(); } - /** + /// Create a builder for a version 2 CRL, initialised with another CRL. + /// Template CRL to base the new one on. + 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() -- cgit 1.4.1