tanker-core 2.32.0.beta.7 → 3.0.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tanker/c_tanker.rb +2 -6
- data/lib/tanker/core/encryption.rb +7 -4
- data/lib/tanker/core/encryption_session.rb +1 -1
- data/lib/tanker/core/session.rb +0 -20
- data/lib/tanker/core/version.rb +1 -1
- data/lib/tanker/encryption_options.rb +32 -3
- data/lib/tanker/error.rb +1 -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 +2 -3
- data/lib/tanker/c_tanker/c_device_info.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17ddab41e47eeed670862e0993b156aa1e7fcc171ce56b0ad9dc98fc1cb18e87
|
4
|
+
data.tar.gz: 2155a7f55ba95cbe0809695e4f754d256a41474d6a4f8a801acec625b9de7a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0e9b79f3cc6b4f0dbd41af27480c9b6f33fb6f805b2aa4a069fe1c1aec2edce9931d793b2966bab7df5810574e771b71c22607cee5a5a05cad8f3b842cd3141
|
7
|
+
data.tar.gz: 6ca06c88f82f15b30235c74ee8cf241f2c2fe0ccb9502c726675a2a8b7974e9d4d9ab98ee3b365da4c3656b0d0803a88c9f7fe43355dc23751ee1cdb3e8d6920
|
data/lib/tanker/c_tanker.rb
CHANGED
@@ -10,7 +10,6 @@ require_relative 'c_tanker/c_future'
|
|
10
10
|
require_relative 'c_tanker/c_verification'
|
11
11
|
require_relative 'c_tanker/c_verification_method'
|
12
12
|
require_relative 'c_tanker/c_log_record'
|
13
|
-
require_relative 'c_tanker/c_device_info'
|
14
13
|
|
15
14
|
module Tanker
|
16
15
|
module CTanker
|
@@ -38,8 +37,6 @@ module Tanker
|
|
38
37
|
blocking_attach_function :tanker_stop, [:session_pointer], CFuture
|
39
38
|
blocking_attach_function :tanker_status, [:session_pointer], :uint32
|
40
39
|
blocking_attach_function :tanker_generate_verification_key, [:session_pointer], CFuture
|
41
|
-
blocking_attach_function :tanker_device_id, [:session_pointer], CFuture
|
42
|
-
blocking_attach_function :tanker_get_device_list, [:session_pointer], CFuture
|
43
40
|
|
44
41
|
blocking_attach_function :tanker_create_oidc_nonce, [:session_pointer], CFuture
|
45
42
|
blocking_attach_function :tanker_set_oidc_test_nonce, [:session_pointer, :string], CFuture
|
@@ -47,7 +44,7 @@ module Tanker
|
|
47
44
|
blocking_attach_function :tanker_attach_provisional_identity, [:session_pointer, :string], CFuture
|
48
45
|
blocking_attach_function :tanker_verify_provisional_identity, [:session_pointer, CVerification], CFuture
|
49
46
|
|
50
|
-
blocking_attach_function :tanker_encrypted_size, [:uint64], :uint64
|
47
|
+
blocking_attach_function :tanker_encrypted_size, [:uint64, :uint32], :uint64
|
51
48
|
blocking_attach_function :tanker_decrypted_size, [:pointer, :uint64], CFuture
|
52
49
|
blocking_attach_function :tanker_get_resource_id, [:pointer, :uint64], CFuture
|
53
50
|
|
@@ -68,7 +65,7 @@ module Tanker
|
|
68
65
|
|
69
66
|
blocking_attach_function :tanker_encryption_session_open, [:session_pointer, Tanker::EncryptionOptions], CFuture
|
70
67
|
blocking_attach_function :tanker_encryption_session_close, [:enc_sess_pointer], CFuture
|
71
|
-
blocking_attach_function :tanker_encryption_session_encrypted_size, [:uint64], :uint64
|
68
|
+
blocking_attach_function :tanker_encryption_session_encrypted_size, [:enc_sess_pointer, :uint64], :uint64
|
72
69
|
blocking_attach_function :tanker_encryption_session_get_resource_id, [:enc_sess_pointer], CFuture
|
73
70
|
blocking_attach_function :tanker_encryption_session_encrypt, [:enc_sess_pointer, :pointer,
|
74
71
|
:pointer, :uint64], CFuture
|
@@ -94,7 +91,6 @@ module Tanker
|
|
94
91
|
|
95
92
|
blocking_attach_function :tanker_free_buffer, [:pointer], :void
|
96
93
|
blocking_attach_function :tanker_free_verification_method_list, [:pointer], :void
|
97
|
-
blocking_attach_function :tanker_free_device_list, [:pointer], :void
|
98
94
|
end
|
99
95
|
|
100
96
|
private_constant :CTanker
|
@@ -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/session.rb
CHANGED
@@ -48,26 +48,6 @@ module Tanker
|
|
48
48
|
method_list
|
49
49
|
end
|
50
50
|
|
51
|
-
def device_id
|
52
|
-
CTanker.tanker_device_id(@ctanker).get_string
|
53
|
-
end
|
54
|
-
|
55
|
-
def device_list
|
56
|
-
device_list_ptr = CTanker.tanker_get_device_list(@ctanker).get
|
57
|
-
count = device_list_ptr.get(:uint32, FFI::Pointer.size)
|
58
|
-
|
59
|
-
method_base_addr = device_list_ptr.read_pointer
|
60
|
-
device_info_list = count.times.map do |i|
|
61
|
-
method_ptr = method_base_addr + (i * CTanker::CDeviceInfo.size)
|
62
|
-
CTanker::CDeviceInfo.new(method_ptr)
|
63
|
-
end
|
64
|
-
CTanker.tanker_free_device_list device_list_ptr
|
65
|
-
device_info_list
|
66
|
-
end
|
67
|
-
|
68
|
-
deprecate :device_id, :none, 2022, 1
|
69
|
-
deprecate :device_list, :none, 2022, 1
|
70
|
-
|
71
51
|
def stop
|
72
52
|
CTanker.tanker_stop(@ctanker).get
|
73
53
|
end
|
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
|
data/lib/tanker/error.rb
CHANGED
@@ -26,7 +26,7 @@ module Tanker
|
|
26
26
|
TOO_MANY_ATTEMPTS = 9
|
27
27
|
EXPIRED_VERIFICATION = 10
|
28
28
|
IO_ERROR = 11
|
29
|
-
DEVICE_REVOKED = 12
|
29
|
+
# DEVICE_REVOKED = 12
|
30
30
|
CONFLICT = 13
|
31
31
|
UPGRADE_REQUIRED = 14
|
32
32
|
IDENTITY_ALREADY_ATTACHED = 15
|
@@ -43,7 +43,6 @@ module Tanker
|
|
43
43
|
class TooManyAttempts < self; end
|
44
44
|
class ExpiredVerification < self; end
|
45
45
|
class IOError < self; end
|
46
|
-
class DeviceRevoked < self; end
|
47
46
|
class Conflict < self; end
|
48
47
|
class UpgradeRequired < self; end
|
49
48
|
class IdentityAlreadyAttached < self; end
|
@@ -61,7 +60,6 @@ module Tanker
|
|
61
60
|
TOO_MANY_ATTEMPTS => TooManyAttempts,
|
62
61
|
EXPIRED_VERIFICATION => ExpiredVerification,
|
63
62
|
IO_ERROR => IOError,
|
64
|
-
DEVICE_REVOKED => DeviceRevoked,
|
65
63
|
CONFLICT => Conflict,
|
66
64
|
UPGRADE_REQUIRED => UpgradeRequired,
|
67
65
|
IDENTITY_ALREADY_ATTACHED => IdentityAlreadyAttached
|
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:
|
4
|
+
version: 3.0.0.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-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -52,7 +52,6 @@ files:
|
|
52
52
|
- lib/tanker-core.rb
|
53
53
|
- lib/tanker/c_tanker.rb
|
54
54
|
- lib/tanker/c_tanker/c_datastore.rb
|
55
|
-
- lib/tanker/c_tanker/c_device_info.rb
|
56
55
|
- lib/tanker/c_tanker/c_future.rb
|
57
56
|
- lib/tanker/c_tanker/c_http.rb
|
58
57
|
- lib/tanker/c_tanker/c_lib.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ffi'
|
4
|
-
|
5
|
-
module Tanker
|
6
|
-
module CTanker
|
7
|
-
class CDeviceInfo < FFI::Struct
|
8
|
-
layout :device_id, :string,
|
9
|
-
:is_revoked, :bool
|
10
|
-
|
11
|
-
attr_reader :device_id
|
12
|
-
|
13
|
-
def initialize(pointer)
|
14
|
-
super pointer
|
15
|
-
@device_id = self[:device_id]
|
16
|
-
@is_revoked = self[:is_revoked]
|
17
|
-
end
|
18
|
-
|
19
|
-
def revoked?
|
20
|
-
@is_revoked
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|