Class: OpenPGP::Packet::SymmetricSessionKey
- Inherits:
-
OpenPGP::Packet
- Object
- OpenPGP::Packet
- OpenPGP::Packet::SymmetricSessionKey
- Defined in:
- lib/openpgp/packet.rb
Overview
OpenPGP Symmetric-Key Encrypted Session Key packet (tag 3).
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
Returns the value of attribute algorithm.
-
#s2k ⇒ Object
Returns the value of attribute s2k.
-
#version ⇒ Object
Returns the value of attribute version.
Attributes inherited from OpenPGP::Packet
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ SymmetricSessionKey
constructor
A new instance of SymmetricSessionKey.
- #write_body(buffer) ⇒ Object
Methods inherited from OpenPGP::Packet
#body, for, parse, parse_new_format, parse_old_format, tag
Constructor Details
#initialize(options = {}, &block) ⇒ SymmetricSessionKey
Returns a new instance of SymmetricSessionKey.
192 193 194 195 196 197 198 199 |
# File 'lib/openpgp/packet.rb', line 192 def initialize( = {}, &block) defaults = { :version => 4, :algorithm => Cipher::DEFAULT.to_i, :s2k => S2K::DEFAULT.new, } super(defaults.merge(), &block) end |
Instance Attribute Details
#algorithm ⇒ Object
Returns the value of attribute algorithm.
181 182 183 |
# File 'lib/openpgp/packet.rb', line 181 def algorithm @algorithm end |
#s2k ⇒ Object
Returns the value of attribute s2k.
181 182 183 |
# File 'lib/openpgp/packet.rb', line 181 def s2k @s2k end |
#version ⇒ Object
Returns the value of attribute version.
181 182 183 |
# File 'lib/openpgp/packet.rb', line 181 def version @version end |
Class Method Details
.parse_body(body, options = {}) ⇒ Object
183 184 185 186 187 188 189 190 |
# File 'lib/openpgp/packet.rb', line 183 def self.parse_body(body, = {}) case version = body.read_byte when 4 self.new({:version => version, :algorithm => body.read_byte, :s2k => body.read_s2k}.merge()) else raise "Invalid OpenPGP symmetric-key ESK packet version: #{version}" end end |
Instance Method Details
#write_body(buffer) ⇒ Object
201 202 203 204 205 |
# File 'lib/openpgp/packet.rb', line 201 def write_body(buffer) buffer.write_byte(version) buffer.write_byte(algorithm.to_i) buffer.write_s2k(s2k) end |