Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::Security.ml_dsa_key?
ml_dsa_key?(key)
lib/rubygems/security.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/security.rb, line 534
def self.ml_dsa_key?(key)
algorithm = OpenSSL::ASN1.decode(key.public_to_der).value.first.value.first
ML_DSA_OIDS.include?(algorithm.oid)
rescue OpenSSL::ASN1::ASN1Error, OpenSSL::PKey::PKeyError, NoMethodError
false
end
Returns whether key uses ML-DSA. OpenSSL::PKey::PKey#oid raises for the provider-backed keys ML-DSA uses, so the algorithm is read from the SubjectPublicKeyInfo instead.