OSSLRSAPrivateKey::OSSLRSAPrivateKey(const RSA* inRSA) { rsa = RSA_new(); // Use the OpenSSL implementation and not any engine RSA_set_method(rsa, RSA_PKCS1_SSLeay()); setFromOSSL(inRSA); }
OSSLECPrivateKey::OSSLECPrivateKey(const EC_KEY* inECKEY) { eckey = EC_KEY_new(); // For PKCS#8 encoding EC_KEY_set_enc_flags(eckey, EC_PKEY_NO_PUBKEY); setFromOSSL(inECKEY); }
// Decode from PKCS#8 BER bool OSSLECPrivateKey::PKCS8Decode(const ByteString& ber) { int len = ber.size(); if (len <= 0) return false; const unsigned char* priv = ber.const_byte_str(); PKCS8_PRIV_KEY_INFO* p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &priv, len); if (p8 == NULL) return false; EVP_PKEY* pkey = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); if (pkey == NULL) return false; EC_KEY* key = EVP_PKEY_get1_EC_KEY(pkey); EVP_PKEY_free(pkey); if (key == NULL) return false; setFromOSSL(key); EC_KEY_free(key); return true; }
OSSLECPublicKey::OSSLECPublicKey(const EC_KEY* inECKEY) { OSSLECPublicKey(); setFromOSSL(inECKEY); }
OSSLDSAPublicKey::OSSLDSAPublicKey(const DSA* inDSA) { dsa = NULL; setFromOSSL(inDSA); }
OSSLGOSTPrivateKey::OSSLGOSTPrivateKey(const EVP_PKEY* inPKEY) { OSSLGOSTPrivateKey(); setFromOSSL(inPKEY); }
OSSLDHPrivateKey::OSSLDHPrivateKey(const DH* inDH) { OSSLDHPrivateKey(); setFromOSSL(inDH); }
OSSLRSAPublicKey::OSSLRSAPublicKey(const RSA* inRSA) { OSSLRSAPublicKey(); setFromOSSL(inRSA); }
OSSLDHPublicKey::OSSLDHPublicKey(const DH* inDH) { dh = NULL; setFromOSSL(inDH); }
OSSLDSAPrivateKey::OSSLDSAPrivateKey(const DSA* inDSA) { OSSLDSAPrivateKey(); setFromOSSL(inDSA); }
OSSLGOSTPublicKey::OSSLGOSTPublicKey(const EVP_PKEY* inPKEY) { OSSLGOSTPublicKey(); setFromOSSL(inPKEY); }