class method
OpenSSL::PKey.generate_key
OpenSSL::PKey.generate_key(algo_name [, options]) → pkey
OpenSSL::PKey.generate_key(pkey [, options]) → pkey
ext/openssl/ossl_pkey.c
View on GitHub ↗
static VALUE
ossl_pkey_s_generate_key(int argc, VALUE *argv, VALUE self)
{
return pkey_generate(argc, argv, self, 0);
}
Generates a new key (pair).
If a String is given as the first argument, it generates a new random key for the algorithm specified by the name just as ::generate_parameters does. If an OpenSSL::PKey::PKey is given instead, it generates a new random key for the same algorithm as the key, using the parameters the key contains.
See ::generate_parameters for the details of options and the given block.
Example
Example
pkey_params = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) pkey_params.priv_key #=> nil pkey = OpenSSL::PKey.generate_key(pkey_params) pkey.priv_key #=> #<OpenSSL::BN 6277...