Class: Sshkeyproof::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_string) ⇒ Server

Returns a new instance of Server.



28
29
30
# File 'lib/sshkeyauth.rb', line 28

def initialize(request_string)
  (@fingerprint,@random,@ciphertext) = request_string.to_s.split("|")
end

Instance Attribute Details

#fingerprintObject (readonly)

Returns the value of attribute fingerprint.



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

def fingerprint
  @fingerprint
end

Instance Method Details

#correct?(key) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/sshkeyauth.rb', line 32

def correct?(key)
  openssl_key = String===key ? OpenSSL::PKey::RSA.new(key) : key
  @fingerprint && @random && @ciphertext && openssl_key.public_key.public_decrypt([@ciphertext].pack('H*')) == [@random].pack('H*') rescue nil
end