Method: Rnp#import_keys

Defined in:
lib/rnp/rnp.rb

#import_keys(input:, public_keys: true, secret_keys: true) ⇒ Hash

Import keys

Parameters:

  • input (Input)

    the input to read the (OpenPGP-format) keys from

  • public_keys (Boolean) (defaults to: true)

    whether to load public keys

  • secret_keys (Boolean) (defaults to: true)

    whether to load secret keys

Returns:

  • (Hash)

    information on the imported keys



632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/rnp/rnp.rb', line 632

def import_keys(input:, public_keys: true, secret_keys: true)
  flags = 0
  flags |= LibRnp::RNP_LOAD_SAVE_PUBLIC_KEYS if public_keys
  flags |= LibRnp::RNP_LOAD_SAVE_SECRET_KEYS if secret_keys
  pptr = FFI::MemoryPointer.new(:pointer)
  Rnp.call_ffi(:rnp_import_keys, @ptr, input.ptr, flags, pptr)
  begin
    presults = pptr.read_pointer
    JSON.parse(presults.read_string) unless pptr.null?
  ensure
    LibRnp.rnp_buffer_destroy(presults)
  end
end