Exemplo n.º 1
0
 public void SetPublicKey(AsymmetricKeyParameter publicKey)
 {
     try
     {
         tbsGen.SetSubjectPublicKeyInfo(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey));
     }
     catch (Exception ex)
     {
         throw new ArgumentException("unable to process key - " + ex.ToString());
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Set the public key that this certificate identifies.
 /// </summary>
 /// <param name="publicKey">The public key to be carried by the generated certificate.</param>
 public void SetPublicKey(
     IAsymmetricPublicKey publicKey)
 {
     try
     {
         tbsGen.SetSubjectPublicKeyInfo(SubjectPublicKeyInfo.GetInstance(publicKey.GetEncoded()));
     }
     catch (Exception e)
     {
         throw new ArgumentException("unable to process key - " + e.ToString());
     }
 }
 public void SetPublicKey(AsymmetricKeyParameter publicKey)
 {
     //IL_0024: Unknown result type (might be due to invalid IL or missing references)
     try
     {
         tbsGen.SetSubjectPublicKeyInfo(SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey));
     }
     catch (global::System.Exception ex)
     {
         throw new ArgumentException("unable to process key - " + ex.ToString());
     }
 }
Exemplo n.º 4
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");
            }
        }