Class: Net::SSH::Authentication::ED25519::PubKey

Inherits:
Object
  • Object
show all
Includes:
PubKeyFingerprint
Defined in:
lib/net/ssh/authentication/ed25519.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PubKeyFingerprint

#fingerprint, fingerprint

Constructor Details

#initialize(data) ⇒ PubKey

Returns a new instance of PubKey.



186
187
188
189
# File 'lib/net/ssh/authentication/ed25519.rb', line 186

def initialize(data)
  ED25519.validate_key_bytes!(data, "public key", KEY_BYTES)
  @public_key_bytes = data.dup.force_encoding('BINARY')
end

Class Method Details

.read_keyblob(buffer) ⇒ Object



191
192
193
# File 'lib/net/ssh/authentication/ed25519.rb', line 191

def self.read_keyblob(buffer)
  PubKey.new(buffer.read_string)
end

Instance Method Details

#public_key_bytes ⇒ Object



216
217
218
# File 'lib/net/ssh/authentication/ed25519.rb', line 216

def public_key_bytes
  @public_key_bytes.dup
end

#ssh_do_verify(sig, data, options = {}) ⇒ Object



207
208
209
# File 'lib/net/ssh/authentication/ed25519.rb', line 207

def ssh_do_verify(sig, data, options = {})
  ED25519.verify(verify_key, sig, data)
end

#ssh_signature_type ⇒ Object



203
204
205
# File 'lib/net/ssh/authentication/ed25519.rb', line 203

def ssh_signature_type
  ssh_type
end

#ssh_type ⇒ Object



199
200
201
# File 'lib/net/ssh/authentication/ed25519.rb', line 199

def ssh_type
  "ssh-ed25519"
end

#to_blob ⇒ Object



195
196
197
# File 'lib/net/ssh/authentication/ed25519.rb', line 195

def to_blob
  Net::SSH::Buffer.from(:mstring, "ssh-ed25519".dup, :string, public_key_bytes).to_s
end

#to_pem ⇒ Object



211
212
213
214
# File 'lib/net/ssh/authentication/ed25519.rb', line 211

def to_pem
  # TODO this is not pem
  ssh_type + [public_key_bytes].pack("m")
end

#verify_key ⇒ Object



220
221
222
# File 'lib/net/ssh/authentication/ed25519.rb', line 220

def verify_key
  @verify_key ||= ED25519.new_public_key(@public_key_bytes)
end