Exemplo n.º 1
0
 public void SetSerialNumber(BigInteger serialNumber)
 {
     if (serialNumber.SignValue <= 0)
     {
         throw new ArgumentException("serial number must be a positive integer", "serialNumber");
     }
     tbsGen.SetSerialNumber(new DerInteger(serialNumber));
 }
 public void SetSerialNumber(BigInteger serialNumber)
 {
     //IL_0013: Unknown result type (might be due to invalid IL or missing references)
     if (serialNumber.SignValue <= 0)
     {
         throw new ArgumentException("serial number must be a positive integer", "serialNumber");
     }
     tbsGen.SetSerialNumber(new DerInteger(serialNumber));
 }
Exemplo n.º 3
0
        private void TbsV1CertGenerate()
        {
            V1TbsCertificateGenerator gen = new V1TbsCertificateGenerator();
            DateTime startDate            = MakeUtcDateTime(1970, 1, 1, 0, 0, 1);
            DateTime endDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 12);

            gen.SetSerialNumber(new DerInteger(1));

            gen.SetStartDate(new Time(startDate));
            gen.SetEndDate(new Time(endDate));

            gen.SetIssuer(new X509Name("CN=AU,O=Bouncy Castle"));
            gen.SetSubject(new X509Name("CN=AU,O=Bouncy Castle,OU=Test 1"));

            gen.SetSignature(new AlgorithmIdentifier(PkcsObjectIdentifiers.MD5WithRsaEncryption, DerNull.Instance));

            SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PkcsObjectIdentifiers.RsaEncryption, DerNull.Instance),
                                                                 new RsaPublicKeyStructure(BigInteger.One, BigInteger.Two));

            gen.SetSubjectPublicKeyInfo(info);

            TbsCertificateStructure tbs = gen.GenerateTbsCertificate();

            if (!Arrays.AreEqual(tbs.GetEncoded(), v1Cert))
            {
                Fail("failed v1 cert generation");
            }

            //
            // read back test
            //
            Asn1InputStream aIn = new Asn1InputStream(v1Cert);
            Asn1Object      o   = aIn.ReadObject();

            if (!Arrays.AreEqual(o.GetEncoded(), v1Cert))
            {
                Fail("failed v1 cert read back test");
            }
        }