Beispiel #1
0
        public PKCS12KeyStore(string keyAlias, RSAKeyPair keyPair, X509CertificateBase certificate)
        {
            m_KeyStore = new Pkcs12StoreBuilder().SetUseDerEncoding(true).Build();

            m_KeyStore.SetKeyEntry(keyAlias,
                                   new AsymmetricKeyEntry(PrivateKeyFactory.CreateKey(keyPair.PrivateKey)),
                                   new[] { new X509CertificateEntry(new X509CertificateParser().ReadCertificate(certificate.GetEncoded())) });
        }
Beispiel #2
0
        public static RSAKeyPair Encrypt(string passphrase, RSAKeyPair keyPair)
        {
            var salt = new byte[20];

            new SecureRandom().NextBytes(salt);

            return(new RSAKeyPair(keyPair.PublicKey,
                                  EncryptedPrivateKeyInfoFactory.CreateEncryptedPrivateKeyInfo(PkcsObjectIdentifiers.PbeWithShaAnd3KeyTripleDesCbc.Id,
                                                                                               passphrase.ToArray(),
                                                                                               salt,
                                                                                               1024,
                                                                                               PrivateKeyInfo.GetInstance(keyPair.PrivateKey)).GetDerEncoded(),
                                  true));
        }
Beispiel #3
0
 public static OneAsymmetricKeyInfo CreateOneAsymmetricKeyInfo(RSAKeyPair keyPair)
 {
     return(CreateOneAsymmetricKeyInfo(PrivateKeyInfo.GetInstance(keyPair.PrivateKey), SubjectPublicKeyInfo.GetInstance(keyPair.PublicKey)));
 }
Beispiel #4
0
        public override CertificateRevocationListBase Generate(RSAKeyPair keyPair)
        {
            var r = m_Generator.Generate(PrivateKeyFactory.CreateKey(keyPair.PrivateKey));

            return(new CertificateRevocationListBC(new MemoryStream(r.GetEncoded())));
        }
Beispiel #5
0
 public abstract CertificateRevocationListBase Generate(RSAKeyPair keyPair);