Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
OpenSSL::PKey.new_raw_private_key
OpenSSL::PKey.new_raw_private_key(algo, string) → PKey
ext/openssl/ossl_pkey.c
View on GitHub ↗
static VALUE
ossl_pkey_new_raw_private_key(VALUE self, VALUE type, VALUE key)
{
EVP_PKEY *pkey;
const EVP_PKEY_ASN1_METHOD *ameth;
int pkey_id;
size_t keylen;
StringValue(type);
StringValue(key);
ameth = EVP_PKEY_asn1_find_str(NULL, RSTRING_PTR(type), RSTRING_LENINT(type));
if (!ameth)
ossl_raise(ePKeyError, "algorithm %"PRIsVALUE" not found", type);
EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
keylen = RSTRING_LEN(key);
pkey = EVP_PKEY_new_raw_private_key(pkey_id, NULL, (unsigned char *)RSTRING_PTR(key), keylen);
if (!pkey)
ossl_raise(ePKeyError, "EVP_PKEY_new_raw_private_key");
return ossl_pkey_new(pkey);
}
See the OpenSSL documentation for EVP_PKEY_new_raw_private_key()