Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::Security.create_key
create_key(algorithm)
lib/rubygems/security.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/security.rb, line 493
def self.create_key(algorithm)
if defined?(OpenSSL::PKey)
case algorithm.downcase
when "rsa"
OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH)
when "dsa"
OpenSSL::PKey::DSA.new(RSA_DSA_KEY_LENGTH)
when "ec"
OpenSSL::PKey::EC.generate(EC_NAME)
when "ml-dsa-44"
create_ml_dsa_key(ML_DSA_44_NAME)
when "ml-dsa-65"
create_ml_dsa_key(ML_DSA_65_NAME)
when "ml-dsa-87"
create_ml_dsa_key(ML_DSA_87_NAME)
else
raise Gem::Security::Exception,
"#{algorithm} algorithm not found. RSA, DSA, EC, ML-DSA-44, "\
"ML-DSA-65, and ML-DSA-87 algorithms are supported."
end
end
end
Creates a new key pair of the specified algorithm. RSA, DSA, EC, ML-DSA-44, ML-DSA-65, and ML-DSA-87 are supported.
See also
.create_digest
.create_ml_dsa_key
.create_cert_self_signed
.digest_required?
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0