Class: SSLyze::X509::PublicKey
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SSLyze::X509::PublicKey
- Defined in:
- lib/sslyze/x509/public_key.rb
Overview
Wrapper class around OpenSSL::PKey classes that provide #algorithm and #size methods.
Instance Method Summary collapse
-
#algorithm ⇒ :rsa, ...
The algorithm that generated the public key.
-
#size ⇒ Integer
The size of the public key.
Instance Method Details
#algorithm ⇒ :rsa, ...
The algorithm that generated the public key.
20 21 22 23 24 25 26 27 |
# File 'lib/sslyze/x509/public_key.rb', line 20 def algorithm case __getobj__ when OpenSSL::PKey::RSA then :rsa when OpenSSL::PKey::DSA then :dsa when OpenSSL::PKey::DH then :dh when OpenSSL::PKey::EC then :ec end end |
#size ⇒ Integer
The size of the public key.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sslyze/x509/public_key.rb', line 39 def size pkey = __getobj__ case pkey when OpenSSL::PKey::RSA then pkey.n.num_bits when OpenSSL::PKey::DSA then pkey.p.num_bits when OpenSSL::PKey::DH then pkey.p.num_bits when OpenSSL::PKey::EC raise(NotImplementedError,"key size for #{pkey.inspect} not implemented") end end |