class OpenPGP::Packet::PublicKey
OpenPGP
Public-Key packet (tag 6).
@see tools.ietf.org/html/rfc4880#section-5.5.1.1 @see tools.ietf.org/html/rfc4880#section-5.5.2 @see tools.ietf.org/html/rfc4880#section-11.1 @see tools.ietf.org/html/rfc4880#section-12
Attributes
algorithm[RW]
fingerprint[RW]
key[RW]
key_fields[RW]
key_id[RW]
size[RW]
timestamp[RW]
version[RW]
Public Class Methods
parse_body(body, options = {})
click to toggle source
def parse(data) # FIXME
# File lib/openpgp/packet.rb, line 249 def self.parse_body(body, options = {}) case version = body.read_byte when 2, 3 # TODO when 4 packet = self.new(:version => version, :timestamp => body.read_timestamp, :algorithm => body.read_byte, :key => {}, :size => body.size) packet.read_key_material(body) packet else raise "Invalid OpenPGP public-key packet version: #{version}" end end
Public Instance Methods
read_key_material(body)
click to toggle source
@see tools.ietf.org/html/rfc4880#section-5.5.2
# File lib/openpgp/packet.rb, line 264 def read_key_material(body) @key_fields = case algorithm when Algorithm::Asymmetric::RSA then [:n, :e] when Algorithm::Asymmetric::ELG_E then [:p, :g, :y] when Algorithm::Asymmetric::DSA then [:p, :q, :g, :y] else raise "Unknown OpenPGP key algorithm: #{algorithm}" end @key_fields.each { |field| key[field] = body.read_mpi } @key_id = fingerprint[-8..-1] end