Class: HrrRbSsh::Algorithm::Publickey::SshEd25519
- Inherits:
-
HrrRbSsh::Algorithm::Publickey
show all
- Includes:
- Loggable
- Defined in:
- lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb,
lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb,
lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature.rb,
lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob.rb,
lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key.rb,
lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content.rb
Defined Under Namespace
Classes: OpenSSHPrivateKey, OpenSSHPrivateKeyContent, PKey, PublicKeyBlob, Signature
Constant Summary
collapse
- NAME =
'ssh-ed25519'
Instance Method Summary
collapse
Constructor Details
#initialize(arg, logger: nil) ⇒ SshEd25519
Returns a new instance of SshEd25519.
14
15
16
17
18
19
20
21
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 14
def initialize arg, logger: nil
self.logger = logger
begin
new_by_key_str arg
rescue PKey::Error
new_by_public_key_blob arg
end
end
|
Instance Method Details
#new_by_key_str(key_str) ⇒ Object
23
24
25
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 23
def new_by_key_str key_str
@publickey = PKey.new key_str, logger: logger
end
|
#new_by_public_key_blob(public_key_blob) ⇒ Object
27
28
29
30
31
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 27
def new_by_public_key_blob public_key_blob
public_key_blob_h = PublicKeyBlob.new(logger: logger).decode public_key_blob
@publickey = PKey.new logger: logger
@publickey.set_public_key(public_key_blob_h[:key])
end
|
#sign(signature_blob) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 45
def sign signature_blob
signature_h = {
:'public key algorithm name' => self.class::NAME,
:'signature blob' => @publickey.sign(signature_blob),
}
Signature.new(logger: logger).encode signature_h
end
|
#to_pem ⇒ Object
33
34
35
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 33
def to_pem
@publickey.public_key.to_pem
end
|
#to_public_key_blob ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 37
def to_public_key_blob
public_key_blob_h = {
:'public key algorithm name' => self.class::NAME,
:'key' => @publickey.public_key.key_str,
}
PublicKeyBlob.new(logger: logger).encode public_key_blob_h
end
|
#verify(signature, signature_blob) ⇒ Object
53
54
55
56
|
# File 'lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb', line 53
def verify signature, signature_blob
signature_h = Signature.new(logger: logger).decode signature
signature_h[:'public key algorithm name'] == self.class::NAME && @publickey.public_key.verify(signature_h[:'signature blob'], signature_blob)
end
|