Method: SSHData::Encoding#decode_certificate
- Defined in:
- lib/ssh_data/encoding.rb
#decode_certificate(raw, offset = 0) ⇒ Object
Decode the fields in a certificate.
raw - Binary String certificate as described by RFC4253 section 6.6. offset - Integer number of bytes into raw at which we should start
reading.
Returns an Array containing a Hash describing the certificate and the Integer number of bytes read.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/ssh_data/encoding.rb', line 352 def decode_certificate(raw, offset=0) total_read = 0 algo, read = decode_string(raw, offset + total_read) total_read += read unless key_algo = PUBLIC_KEY_ALGO_BY_CERT_ALGO[algo] raise AlgorithmError, "unknown algorithm: #{algo.inspect}" end data, read = decode_fields(raw, [ [:nonce, :string], [:public_key, :public_key, key_algo], [:serial, :uint64], [:type, :uint32], [:key_id, :string], [:valid_principals, :list], [:valid_after, :time], [:valid_before, :time], [:critical_options, :options], [:extensions, :options], [:reserved, :string], [:signature_key, :string_public_key], [:signature, :string], ], offset + total_read) total_read += read data[:algo] = algo [data, total_read] end |