/** * reset the generator */ public void Reset() { tbsGen = new V2TbsCertListGenerator(); extGenerator.Reset(); }
public X509V2CrlGenerator() { tbsGen = new V2TbsCertListGenerator(); }
private void TbsV2CertListGenerate() { V2TbsCertListGenerator gen = new V2TbsCertListGenerator(); gen.SetIssuer(new X509Name("CN=AU,O=Bouncy Castle")); gen.AddCrlEntry(new DerInteger(1), new Time(new DateTime(1970, 1, 1, 0, 0, 1)), ReasonFlags.AACompromise); gen.SetNextUpdate(new Time(new DateTime(1970, 1, 1, 0, 0, 2))); gen.SetThisUpdate(new Time(new DateTime(1970, 1, 1, 0, 0, 0, 500))); gen.SetSignature(new AlgorithmIdentifier(PkcsObjectIdentifiers.Sha1WithRsaEncryption, DerNull.Instance)); // // extensions // IList order = new ArrayList(); IDictionary extensions = new Hashtable(); SubjectPublicKeyInfo info = new SubjectPublicKeyInfo( new AlgorithmIdentifier( OiwObjectIdentifiers.ElGamalAlgorithm, new ElGamalParameter(BigInteger.One, BigInteger.Two)), new DerInteger(3)); order.Add(X509Extensions.AuthorityKeyIdentifier); order.Add(X509Extensions.IssuerAlternativeName); order.Add(X509Extensions.CrlNumber); order.Add(X509Extensions.IssuingDistributionPoint); extensions.Add(X509Extensions.AuthorityKeyIdentifier, new X509Extension(true, new DerOctetString(CreateAuthorityKeyId(info, new X509Name("CN=AU,O=Bouncy Castle,OU=Test 2"), 2)))); extensions.Add(X509Extensions.IssuerAlternativeName, new X509Extension(false, new DerOctetString(GeneralNames.GetInstance(new DerSequence(new GeneralName(new X509Name("CN=AU,O=Bouncy Castle,OU=Test 3"))))))); extensions.Add(X509Extensions.CrlNumber, new X509Extension(false, new DerOctetString(new DerInteger(1)))); extensions.Add(X509Extensions.IssuingDistributionPoint, new X509Extension(true, new DerOctetString(IssuingDistributionPoint.GetInstance(DerSequence.Empty)))); X509Extensions ex = new X509Extensions(order, extensions); gen.SetExtensions(ex); TbsCertificateList tbs = gen.GenerateTbsCertList(); if (!Arrays.AreEqual(tbs.GetEncoded(), v2CertList)) { Fail("failed v2 cert list generation"); } // // read back test // Asn1InputStream aIn = new Asn1InputStream(v2CertList); Asn1Object o = aIn.ReadObject(); if (!Arrays.AreEqual(o.GetEncoded(), v2CertList)) { Fail("failed v2 cert list read back test"); } }