Class: SSHData::PrivateKey::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_data/private_key/base.rb

Direct Known Subclasses

DSA, ECDSA, ED25519, RSA

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/ssh_data/private_key/base.rb', line 6

def initialize(**kwargs)
  @algo = kwargs[:algo]
  @comment = kwargs[:comment]
end

Instance Attribute Details

#algoObject (readonly)

Returns the value of attribute algo.



4
5
6
# File 'lib/ssh_data/private_key/base.rb', line 4

def algo
  @algo
end

#commentObject (readonly)

Returns the value of attribute comment.



4
5
6
# File 'lib/ssh_data/private_key/base.rb', line 4

def comment
  @comment
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



4
5
6
# File 'lib/ssh_data/private_key/base.rb', line 4

def public_key
  @public_key
end

Class Method Details

.generate(**kwargs) ⇒ Object

Generate a new private key.

Returns a PublicKey::Base subclass instance.



14
15
16
# File 'lib/ssh_data/private_key/base.rb', line 14

def self.generate(**kwargs)
  raise "implement me"
end

Instance Method Details

#issue_certificate(signature_algo: nil, **kwargs) ⇒ Object

Issue a certificate using this private key.

signature_algo: - Optionally specify the signature algorithm to use. kwargs - See SSHData::Certificate.new.

Returns a SSHData::Certificate instance.



34
35
36
# File 'lib/ssh_data/private_key/base.rb', line 34

def issue_certificate(signature_algo: nil, **kwargs)
  Certificate.new(**kwargs).tap { |c| c.sign(self, algo: signature_algo) }
end

#sign(signed_data, algo: nil) ⇒ Object

Make an SSH signature.

signed_data - The String message over which to calculated the signature. algo: - Optionally specify the signature algorithm to use.

Returns a binary String signature.



24
25
26
# File 'lib/ssh_data/private_key/base.rb', line 24

def sign(signed_data, algo: nil)
  raise "implement me"
end