Method: SSHData::Encoding#decode_public_key
- Defined in:
- lib/ssh_data/encoding.rb
#decode_public_key(raw, offset = 0, algo = nil) ⇒ Object
Decode the fields in a public key.
raw - Binary String public key as described by RFC4253 section 6.6. 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.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/ssh_data/encoding.rb', line 288 def decode_public_key(raw, offset=0, algo=nil) total_read = 0 if algo.nil? algo, read = decode_string(raw, offset + total_read) total_read += read end unless fields = KEY_FIELDS_BY_PUBLIC_KEY_ALGO[algo] raise AlgorithmError, "unknown algorithm: #{algo.inspect}" end data, read = decode_fields(raw, fields, offset + total_read) total_read += read data[:algo] = algo [data, total_read] end |