Class: SshSig::Signature
- Inherits:
-
Object
- Object
- SshSig::Signature
- Defined in:
- lib/ssh_sig/signature.rb
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
Class Method Summary collapse
-
.from_bytes(blob) ⇒ Object
While not described well in the protocol documenation, the signature has two parts.
Instance Method Summary collapse
-
#initialize(algorithm:, bytes:) ⇒ Signature
constructor
A new instance of Signature.
Constructor Details
#initialize(algorithm:, bytes:) ⇒ Signature
Returns a new instance of Signature.
6 7 8 9 10 11 12 |
# File 'lib/ssh_sig/signature.rb', line 6 def initialize( algorithm:, bytes: ) @algorithm = algorithm @bytes = bytes end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
4 5 6 |
# File 'lib/ssh_sig/signature.rb', line 4 def algorithm @algorithm end |
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
4 5 6 |
# File 'lib/ssh_sig/signature.rb', line 4 def bytes @bytes end |
Class Method Details
.from_bytes(blob) ⇒ Object
While not described well in the protocol documenation, the signature has two parts. There is a string describing the algorithm, which can be one of ssh-ed25519, rsa-sha2-512, or rsa-sha2-256, followed by the actual signature bytes.
string algorithm string signature_bytes
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ssh_sig/signature.rb', line 21 def self.from_bytes(blob) buf = ::Net::SSH::Buffer.new(blob) algorithm = buf.read_string raise DecodeError, 'Signature algorithm is missing' if algorithm.nil? bytes = buf.read_string raise DecodeError, 'Signature data is missing' if bytes.nil? Signature.new( algorithm: algorithm, bytes: bytes ) end |