Method: NetPGP::SecretKey#to_native_key

Defined in:
lib/netpgp/highlevel/secretkey.rb

#to_native_key(native_key) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/netpgp/highlevel/secretkey.rb', line 263

def to_native_key(native_key)
  raise if not native_key[:packets].null?
  native_key[:type] = :PGP_PTAG_CT_SECRET_KEY
  native_key[:sigid] = @public_key.key_id
  to_native(native_key[:key][:seckey])
  if not @parent
    @userids.each {|userid|
      LibNetPGP::dynarray_append_item(native_key, 'uid', :string, userid)
    }
  end
  @raw_subpackets.each {|bytes|
    packet = LibNetPGP::PGPSubPacket.new
    length = bytes.bytesize
    packet[:length] = length
    packet[:raw] = LibC::calloc(1, length)
    packet[:raw].write_bytes(bytes)
    LibNetPGP::dynarray_append_item(native_key, 'packet', LibNetPGP::PGPSubPacket, packet)
  }
end