Class: OpenPGP::Packet::SymmetricSessionKey

Inherits:
  • Object
show all
Defined in:
lib/openpgp/packet.rb

Overview

OpenPGP Symmetric-Key Encrypted Session Key packet (tag 3).

See Also:

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from

#body, for, parse, parse_new_format, parse_old_format, tag

Constructor Details

- (SymmetricSessionKey) initialize(options = {}, &block)

A new instance of SymmetricSessionKey



212
213
214
215
216
217
218
219
# File 'lib/openpgp/packet.rb', line 212

def initialize(options = {}, &block)
  defaults = {
    :version   => 4,
    :algorithm => Cipher::DEFAULT.to_i,
    :s2k       => S2K::DEFAULT.new,
  }
  super(defaults.merge(options), &block)
end

Instance Attribute Details

- (Object) algorithm

Returns the value of attribute algorithm



201
202
203
# File 'lib/openpgp/packet.rb', line 201

def algorithm
  @algorithm
end

- (Object) s2k

Returns the value of attribute s2k



201
202
203
# File 'lib/openpgp/packet.rb', line 201

def s2k
  @s2k
end

- (Object) version

Returns the value of attribute version



201
202
203
# File 'lib/openpgp/packet.rb', line 201

def version
  @version
end

Class Method Details

+ (Object) parse_body(body, options = {})



203
204
205
206
207
208
209
210
# File 'lib/openpgp/packet.rb', line 203

def self.parse_body(body, options = {})
  case version = body.read_byte
    when 4
      self.new({:version => version, :algorithm => body.read_byte, :s2k => body.read_s2k}.merge(options))
    else
      raise "Invalid OpenPGP symmetric-key ESK packet version: #{version}"
  end
end

Instance Method Details

- (Object) write_body(buffer)



221
222
223
224
225
# File 'lib/openpgp/packet.rb', line 221

def write_body(buffer)
  buffer.write_byte(version)
  buffer.write_byte(algorithm.to_i)
  buffer.write_s2k(s2k)
end