Method: SSHData::Encoding#decode_string_public_key

Defined in:
lib/ssh_data/encoding.rb

#decode_string_public_key(raw, offset = 0, algo = nil) ⇒ Object

Decode the fields in a public key encoded as an SSH string.

raw - Binary public key as described by RFC4253 section 6.6 wrapped in

an SSH string..

algo - String public key algorithm identifier (optional). offset - Integer number of bytes into raw at which we should start

reading.

Returns an Array containing a Hash describing the public key and the Integer number of bytes read.



286
287
288
289
290
291
292
293
294
295
# File 'lib/ssh_data/encoding.rb', line 286

def decode_string_public_key(raw, offset=0, algo=nil)
  key_raw, str_read = decode_string(raw, offset)
  key, cert_read = decode_public_key(key_raw, 0, algo)

  if cert_read != key_raw.bytesize
    raise DecodeError, "unexpected trailing data"
  end

  [key, str_read]
end