Class: Tanker::EncryptionOptions

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/tanker/encryption_options.rb

Overview

Options that can be given when encrypting data

Instance Method Summary collapse

Constructor Details

#initialize(share_with_users: [], share_with_groups: [], share_with_self: true, padding_step: Padding::AUTO) ⇒ EncryptionOptions

Returns a new instance of EncryptionOptions.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tanker/encryption_options.rb', line 9

def initialize(share_with_users: [], share_with_groups: [], share_with_self: true,
               padding_step: Padding::AUTO)
  super()

  @users_objs = share_with_users.map { |id| CTanker.new_cstring id }
  users = FFI::MemoryPointer.new(:pointer, share_with_users.length)
  users.write_array_of_pointer(@users_objs)

  @groups_objs = share_with_groups.map { |id| CTanker.new_cstring id }
  groups = FFI::MemoryPointer.new(:pointer, share_with_groups.length)
  groups.write_array_of_pointer(@groups_objs)

  self[:version] = 4
  self[:recipient_public_identities] = users
  self[:nb_recipient_public_identities] = share_with_users.length
  self[:recipient_group_ids] = groups
  self[:nb_recipient_group_ids] = share_with_groups.length
  self[:share_with_self] = share_with_self
  self[:padding_step] = padding_step.native_value
end