Class: OpenPGP::Packet::PublicKey
- Inherits:
-
OpenPGP::Packet
- Object
- OpenPGP::Packet
- OpenPGP::Packet::PublicKey
- Defined in:
- lib/openpgp/packet.rb
Overview
OpenPGP Public-Key packet (tag 6).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
- #fingerprint ⇒ Object
-
#key ⇒ Object
Returns the value of attribute key.
-
#key_fields ⇒ Object
Returns the value of attribute key_fields.
-
#key_id ⇒ Object
Returns the value of attribute key_id.
-
#size ⇒ Object
Returns the value of attribute size.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#version ⇒ Object
Returns the value of attribute version.
Attributes inherited from OpenPGP::Packet
Class Method Summary collapse
-
.parse_body(body, options = {}) ⇒ Object
def parse(data) # FIXME.
Instance Method Summary collapse
Methods inherited from OpenPGP::Packet
#body, for, #initialize, parse, parse_new_format, parse_old_format, tag
Constructor Details
This class inherits a constructor from OpenPGP::Packet
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
225 226 227 |
# File 'lib/openpgp/packet.rb', line 225 def algorithm @algorithm end |
#fingerprint ⇒ Object
258 259 260 |
# File 'lib/openpgp/packet.rb', line 258 def fingerprint @fingerprint end |
#key ⇒ Object
Returns the value of attribute key.
226 227 228 |
# File 'lib/openpgp/packet.rb', line 226 def key @key end |
#key_fields ⇒ Object
Returns the value of attribute key_fields.
226 227 228 |
# File 'lib/openpgp/packet.rb', line 226 def key_fields @key_fields end |
#key_id ⇒ Object
Returns the value of attribute key_id.
226 227 228 |
# File 'lib/openpgp/packet.rb', line 226 def key_id @key_id end |
#size ⇒ Object
Returns the value of attribute size.
224 225 226 |
# File 'lib/openpgp/packet.rb', line 224 def size @size end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
225 226 227 |
# File 'lib/openpgp/packet.rb', line 225 def @timestamp end |
#version ⇒ Object
Returns the value of attribute version.
225 226 227 |
# File 'lib/openpgp/packet.rb', line 225 def version @version end |
Class Method Details
.parse_body(body, options = {}) ⇒ Object
def parse(data) # FIXME
229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/openpgp/packet.rb', line 229 def self.parse_body(body, = {}) case version = body.read_byte when 2, 3 # TODO when 4 packet = self.new(:version => version, :timestamp => body., :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 |
Instance Method Details
#read_key_material(body) ⇒ Object
244 245 246 247 248 249 250 251 252 253 |
# File 'lib/openpgp/packet.rb', line 244 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 |