Module: HrrRbSsh::Authentication::Method::Publickey::Algorithm::Functionable
- Included in:
- EcdsaSha2Nistp256, EcdsaSha2Nistp384, EcdsaSha2Nistp521, SshDss, SshEd25519, SshRsa
- Defined in:
- lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb
Instance Method Summary collapse
- #generate_public_key_blob(secret_key) ⇒ Object
- #generate_signature(session_id, username, service_name, method_name, secret_key) ⇒ Object
- #initialize ⇒ Object
- #verify_public_key(public_key_algorithm_name, public_key, public_key_blob) ⇒ Object
- #verify_signature(session_id, message) ⇒ Object
Instance Method Details
#generate_public_key_blob(secret_key) ⇒ Object
48 49 50 51 |
# File 'lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb', line 48 def generate_public_key_blob secret_key publickey = HrrRbSsh::Algorithm::Publickey[self.class::NAME].new secret_key publickey.to_public_key_blob end |
#generate_signature(session_id, username, service_name, method_name, secret_key) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb', line 53 def generate_signature session_id, username, service_name, method_name, secret_key publickey = HrrRbSsh::Algorithm::Publickey[self.class::NAME].new secret_key publickey_blob = publickey.to_public_key_blob signature_blob_h = { :'session identifier' => session_id, :'message number' => Message::SSH_MSG_USERAUTH_REQUEST::VALUE, :'user name' => username, :'service name' => service_name, :'method name' => method_name, :'with signature' => true, :'public key algorithm name' => self.class::NAME, :'public key blob' => publickey_blob } signature_blob = SignatureBlob.encode signature_blob_h publickey.sign signature_blob end |
#initialize ⇒ Object
13 14 15 |
# File 'lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb', line 13 def initialize @logger = Logger.new(self.class.name) end |
#verify_public_key(public_key_algorithm_name, public_key, public_key_blob) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb', line 17 def verify_public_key public_key_algorithm_name, public_key, public_key_blob begin publickey = HrrRbSsh::Algorithm::Publickey[self.class::NAME].new public_key public_key_algorithm_name == self.class::NAME && public_key_blob == publickey.to_public_key_blob rescue => e @logger.error { [e.backtrace[0], ": ", e., " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join } false end end |
#verify_signature(session_id, message) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb', line 27 def verify_signature session_id, begin signature_blob_h = { :'session identifier' => session_id, :'message number' => [:'message number'], :'user name' => [:'user name'], :'service name' => [:'service name'], :'method name' => [:'method name'], :'with signature' => [:'with signature'], :'public key algorithm name' => [:'public key algorithm name'], :'public key blob' => [:'public key blob'], } signature_blob = SignatureBlob.encode signature_blob_h publickey = HrrRbSsh::Algorithm::Publickey[self.class::NAME].new [:'public key blob'] publickey.verify [:'signature'], signature_blob rescue => e @logger.error { [e.backtrace[0], ": ", e., " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join } false end end |