tanker-core 2.32.0 → 2.32.2.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tanker/c_tanker.rb +2 -2
- data/lib/tanker/core/encryption.rb +7 -4
- data/lib/tanker/core/encryption_session.rb +1 -1
- data/lib/tanker/core/version.rb +1 -1
- data/lib/tanker/encryption_options.rb +32 -3
- data/vendor/tanker/darwin-aarch64/libctanker.dylib +0 -0
- data/vendor/tanker/darwin-x86_64/libctanker.dylib +0 -0
- data/vendor/tanker/linux-x86_64/libctanker.so +0 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8986ce0f00de4082f8ff592ffbfdc317527465d45c1a4b1d57c9113b74cfe516
|
4
|
+
data.tar.gz: 202538493b3c7db78ae98a69477bf0ec2c449b06aff6bebe3ef90030d0b2b5a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e01dfc8021de188756fc8bdb51441ffec1bba823476e1f45c01442b6fe6bcddcda9bf9a11173e55af3bbe5f913648df9a24d5c47641cb2e6ce3f9d5342c2bc
|
7
|
+
data.tar.gz: 01cccf53b530a88cf5efaf12e644e066b066ee31de7d314b03d31e4419c9fb35d70dcfccebe8cf89515c2fbee037764cc9eacb86df8fc903031cd30c67fde96b
|
data/lib/tanker/c_tanker.rb
CHANGED
@@ -47,7 +47,7 @@ module Tanker
|
|
47
47
|
blocking_attach_function :tanker_attach_provisional_identity, [:session_pointer, :string], CFuture
|
48
48
|
blocking_attach_function :tanker_verify_provisional_identity, [:session_pointer, CVerification], CFuture
|
49
49
|
|
50
|
-
blocking_attach_function :tanker_encrypted_size, [:uint64], :uint64
|
50
|
+
blocking_attach_function :tanker_encrypted_size, [:uint64, :uint32], :uint64
|
51
51
|
blocking_attach_function :tanker_decrypted_size, [:pointer, :uint64], CFuture
|
52
52
|
blocking_attach_function :tanker_get_resource_id, [:pointer, :uint64], CFuture
|
53
53
|
|
@@ -68,7 +68,7 @@ module Tanker
|
|
68
68
|
|
69
69
|
blocking_attach_function :tanker_encryption_session_open, [:session_pointer, Tanker::EncryptionOptions], CFuture
|
70
70
|
blocking_attach_function :tanker_encryption_session_close, [:enc_sess_pointer], CFuture
|
71
|
-
blocking_attach_function :tanker_encryption_session_encrypted_size, [:uint64], :uint64
|
71
|
+
blocking_attach_function :tanker_encryption_session_encrypted_size, [:enc_sess_pointer, :uint64], :uint64
|
72
72
|
blocking_attach_function :tanker_encryption_session_get_resource_id, [:enc_sess_pointer], CFuture
|
73
73
|
blocking_attach_function :tanker_encryption_session_encrypt, [:enc_sess_pointer, :pointer,
|
74
74
|
:pointer, :uint64], CFuture
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'tanker/c_tanker'
|
4
|
+
require 'tanker/encryption_options'
|
4
5
|
require_relative 'encryption_session'
|
5
6
|
|
6
7
|
module Tanker
|
@@ -80,17 +81,19 @@ module Tanker
|
|
80
81
|
|
81
82
|
private
|
82
83
|
|
83
|
-
def encrypt_common(data, encryption_options
|
84
|
-
unless
|
84
|
+
def encrypt_common(data, encryption_options)
|
85
|
+
unless encryption_options.nil? || encryption_options.is_a?(EncryptionOptions)
|
85
86
|
raise TypeError, "expected encryption_options to be a EncryptionOptions, but got a #{encryption_options.class}"
|
86
87
|
end
|
87
88
|
|
88
89
|
inbuf = FFI::MemoryPointer.from_string(data)
|
89
90
|
|
90
|
-
|
91
|
+
options = encryption_options || EncryptionOptions.new
|
92
|
+
|
93
|
+
encrypted_size = CTanker.tanker_encrypted_size(data.bytesize, options[:padding_step])
|
91
94
|
outbuf = FFI::MemoryPointer.new(:char, encrypted_size)
|
92
95
|
|
93
|
-
CTanker.tanker_encrypt(@ctanker, outbuf, inbuf, data.bytesize,
|
96
|
+
CTanker.tanker_encrypt(@ctanker, outbuf, inbuf, data.bytesize, options).get
|
94
97
|
|
95
98
|
outbuf.read_string encrypted_size
|
96
99
|
end
|
@@ -33,7 +33,7 @@ module Tanker
|
|
33
33
|
def encrypt_common(data)
|
34
34
|
inbuf = FFI::MemoryPointer.from_string(data)
|
35
35
|
|
36
|
-
encrypted_size = CTanker.tanker_encryption_session_encrypted_size data.bytesize
|
36
|
+
encrypted_size = CTanker.tanker_encryption_session_encrypted_size(@csession, data.bytesize)
|
37
37
|
outbuf = FFI::MemoryPointer.new(:char, encrypted_size)
|
38
38
|
|
39
39
|
CTanker.tanker_encryption_session_encrypt(@csession, outbuf, inbuf, data.bytesize).get
|
data/lib/tanker/core/version.rb
CHANGED
@@ -6,7 +6,8 @@ require 'tanker/c_tanker/c_string'
|
|
6
6
|
module Tanker
|
7
7
|
# Options that can be given when encrypting data
|
8
8
|
class EncryptionOptions < FFI::Struct
|
9
|
-
def initialize(share_with_users: [], share_with_groups: [], share_with_self: true
|
9
|
+
def initialize(share_with_users: [], share_with_groups: [], share_with_self: true,
|
10
|
+
padding_step: Padding::AUTO)
|
10
11
|
super()
|
11
12
|
|
12
13
|
@users_objs = share_with_users.map { |id| CTanker.new_cstring id }
|
@@ -17,12 +18,13 @@ module Tanker
|
|
17
18
|
groups = FFI::MemoryPointer.new(:pointer, share_with_groups.length)
|
18
19
|
groups.write_array_of_pointer(@groups_objs)
|
19
20
|
|
20
|
-
self[:version] =
|
21
|
+
self[:version] = 4
|
21
22
|
self[:recipient_public_identities] = users
|
22
23
|
self[:nb_recipient_public_identities] = share_with_users.length
|
23
24
|
self[:recipient_group_ids] = groups
|
24
25
|
self[:nb_recipient_group_ids] = share_with_groups.length
|
25
26
|
self[:share_with_self] = share_with_self
|
27
|
+
self[:padding_step] = padding_step.native_value
|
26
28
|
end
|
27
29
|
|
28
30
|
layout :version, :uint8,
|
@@ -30,6 +32,33 @@ module Tanker
|
|
30
32
|
:nb_recipient_public_identities, :uint32,
|
31
33
|
:recipient_group_ids, :pointer,
|
32
34
|
:nb_recipient_group_ids, :uint32,
|
33
|
-
:share_with_self, :bool
|
35
|
+
:share_with_self, :bool,
|
36
|
+
:padding_step, :uint32
|
37
|
+
end
|
38
|
+
|
39
|
+
class Padding
|
40
|
+
private_class_method :new
|
41
|
+
attr_reader :native_value
|
42
|
+
|
43
|
+
def initialize(native_value)
|
44
|
+
super()
|
45
|
+
@native_value = native_value
|
46
|
+
end
|
47
|
+
|
48
|
+
AUTO = new 0
|
49
|
+
OFF = new 1
|
50
|
+
|
51
|
+
def self.step(value)
|
52
|
+
unless value.is_a?(Integer)
|
53
|
+
raise TypeError,
|
54
|
+
"expected step to be an Integer >= 2, but got a #{value.class}"
|
55
|
+
end
|
56
|
+
unless value >= 2
|
57
|
+
raise ArgumentError,
|
58
|
+
"expected step to be an Integer >= 2, but got #{value}"
|
59
|
+
end
|
60
|
+
|
61
|
+
new(value)
|
62
|
+
end
|
34
63
|
end
|
35
64
|
end
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanker-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.32.
|
4
|
+
version: 2.32.2.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanker team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -101,9 +101,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: 2.7.0
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- - "
|
104
|
+
- - ">"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: 1.3.1
|
107
107
|
requirements: []
|
108
108
|
rubygems_version: 3.3.7
|
109
109
|
signing_key:
|