Class: SSHScan::Crypto::PublicKey

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_scan/crypto.rb

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ PublicKey

Returns a new instance of PublicKey.



8
9
10
# File 'lib/ssh_scan/crypto.rb', line 8

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

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'lib/ssh_scan/crypto.rb', line 13

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_md5Object



23
24
25
# File 'lib/ssh_scan/crypto.rb', line 23

def fingerprint_md5
  OpenSSL::Digest::MD5.hexdigest(::Base64.decode64(@key)).scan(/../).join(':')
end

#fingerprint_sha1Object



27
28
29
# File 'lib/ssh_scan/crypto.rb', line 27

def fingerprint_sha1
  OpenSSL::Digest::SHA1.hexdigest(::Base64.decode64(@key)).scan(/../).join(':')
end

#fingerprint_sha256Object



31
32
33
# File 'lib/ssh_scan/crypto.rb', line 31

def fingerprint_sha256
  OpenSSL::Digest::SHA256.hexdigest(::Base64.decode64(@key)).scan(/../).join(':')
end