Class: SSHScan::Crypto::PublicKey
- Inherits:
-
Object
- Object
- SSHScan::Crypto::PublicKey
- Defined in:
- lib/ssh_scan/crypto.rb
Overview
House methods helpful in analysing SSH public keys.
Instance Method Summary collapse
-
#bad_key? ⇒ Boolean
Is the current key known to be in our known bad key list.
-
#fingerprint_md5 ⇒ String
Generate MD5 fingerprint for this PublicKey instance.
-
#fingerprint_sha1 ⇒ String
Generate SHA1 fingerprint for this PublicKey instance.
-
#fingerprint_sha256 ⇒ String
Generate SHA256 fingerprint for this PublicKey instance.
-
#initialize(key) ⇒ PublicKey
constructor
A new instance of PublicKey.
Constructor Details
#initialize(key) ⇒ PublicKey
Returns a new instance of PublicKey.
10 11 12 |
# File 'lib/ssh_scan/crypto.rb', line 10 def initialize(key) @key = key end |
Instance Method Details
#bad_key? ⇒ Boolean
Is the current key known to be in our known bad key list
18 19 20 21 22 23 24 25 26 |
# File 'lib/ssh_scan/crypto.rb', line 18 def bad_key? SSHScan::Crypto.bad_public_keys.each do |other_key| if self.fingerprint_sha256 == other_key.fingerprint_sha256 return true end end return false end |
#fingerprint_md5 ⇒ String
Generate MD5 fingerprint for this SSHScan::Crypto::PublicKey instance.
30 31 32 |
# File 'lib/ssh_scan/crypto.rb', line 30 def fingerprint_md5 OpenSSL::Digest::MD5.hexdigest(::Base64.decode64(@key)).scan(/../).join(':') end |
#fingerprint_sha1 ⇒ String
Generate SHA1 fingerprint for this SSHScan::Crypto::PublicKey instance.
36 37 38 |
# File 'lib/ssh_scan/crypto.rb', line 36 def fingerprint_sha1 OpenSSL::Digest::SHA1.hexdigest(::Base64.decode64(@key)).scan(/../).join(':') end |
#fingerprint_sha256 ⇒ String
Generate SHA256 fingerprint for this SSHScan::Crypto::PublicKey instance.
42 43 44 |
# File 'lib/ssh_scan/crypto.rb', line 42 def fingerprint_sha256 OpenSSL::Digest::SHA256.hexdigest(::Base64.decode64(@key)).scan(/../).join(':') end |