tanker-core 2.4.0.alpha.7 → 2.4.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rst +1 -1
- data/lib/tanker/c_tanker.rb +3 -4
- data/lib/tanker/c_tanker/c_string.rb +5 -1
- data/lib/tanker/core/encryption.rb +10 -21
- data/lib/tanker/core/init.rb +3 -1
- data/lib/tanker/core/session.rb +1 -1
- data/lib/tanker/core/stream.rb +1 -1
- data/lib/tanker/core/version.rb +1 -1
- data/lib/tanker/encryption_options.rb +33 -0
- data/lib/tanker/sharing_options.rb +16 -27
- data/vendor/libctanker/linux64/tanker/lib/libctanker.so +0 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a37fb24ae73f9a21200437cf2704dfe3e0565e8e25d20fad0a06d99b6dcf0d5
|
4
|
+
data.tar.gz: 79aed128e1597abc688c9cc0dae80623bbe86ba323bfbff51518069cba1d75f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7075056d331cd601fedb0f78bfa0f86aef99622761e7dca92a95e0aba370bb8037dcf7240f95694e1c53e9b261602d88afc6e4a349780901288603983166fa02
|
7
|
+
data.tar.gz: 4809b89af65a676d07fa1b748dd2886951e528e1a3ad6427211ea9dd26842d8d6754c5396b474f86de635fe7bbc1d288be4248cbea8d51dd122d706d6e3637a1
|
data/README.rst
CHANGED
@@ -26,5 +26,5 @@ Checking vulnerabilities in the dependencies: `bundle exec bundle-audit check --
|
|
26
26
|
Documentation
|
27
27
|
-------------
|
28
28
|
|
29
|
-
See the `API documentation <https://
|
29
|
+
See the `API documentation <https://docs.tanker.io/latest/api/core/ruby>`_.
|
30
30
|
|
data/lib/tanker/c_tanker.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'ffi'
|
4
4
|
require_relative 'core/options'
|
5
5
|
require_relative 'sharing_options'
|
6
|
+
require_relative 'encryption_options'
|
6
7
|
require_relative 'c_tanker/c_future'
|
7
8
|
require_relative 'c_tanker/c_verification'
|
8
9
|
require_relative 'c_tanker/c_verification_method'
|
@@ -59,8 +60,7 @@ module Tanker
|
|
59
60
|
blocking_attach_function :tanker_encrypt, [:session_pointer, :pointer, :pointer, :uint64,
|
60
61
|
Tanker::EncryptionOptions], CFuture
|
61
62
|
blocking_attach_function :tanker_decrypt, [:session_pointer, :pointer, :pointer, :uint64], CFuture
|
62
|
-
blocking_attach_function :tanker_share, [:session_pointer, :pointer, :
|
63
|
-
:pointer, :uint64], CFuture
|
63
|
+
blocking_attach_function :tanker_share, [:session_pointer, :pointer, :uint32, Tanker::SharingOptions], CFuture
|
64
64
|
|
65
65
|
blocking_attach_function :tanker_future_wait, [CFuture], :void
|
66
66
|
blocking_attach_function :tanker_future_has_error, [CFuture], :bool
|
@@ -72,8 +72,7 @@ module Tanker
|
|
72
72
|
blocking_attach_function :tanker_update_group_members, [:session_pointer, :string,
|
73
73
|
:pointer, :uint64], CFuture
|
74
74
|
|
75
|
-
blocking_attach_function :tanker_encryption_session_open, [:session_pointer,
|
76
|
-
:pointer, :uint64], CFuture
|
75
|
+
blocking_attach_function :tanker_encryption_session_open, [:session_pointer, Tanker::EncryptionOptions], CFuture
|
77
76
|
blocking_attach_function :tanker_encryption_session_close, [:enc_sess_pointer], CFuture
|
78
77
|
blocking_attach_function :tanker_encryption_session_encrypted_size, [:uint64], :uint64
|
79
78
|
blocking_attach_function :tanker_encryption_session_get_resource_id, [:enc_sess_pointer], CFuture
|
@@ -17,7 +17,11 @@ module Tanker::CTanker
|
|
17
17
|
|
18
18
|
def self.new_cstring_array(strings)
|
19
19
|
cstrings = FFI::MemoryPointer.new(:pointer, strings.length)
|
20
|
-
|
20
|
+
ruby_strings = strings.map { |id| new_cstring id }
|
21
|
+
# keep alive the ruby objects to prevent GC
|
22
|
+
# I could not find any other place to store these
|
23
|
+
cstrings.instance_variable_set(:@ruby_strings, ruby_strings)
|
24
|
+
cstrings.write_array_of_pointer(ruby_strings)
|
21
25
|
cstrings
|
22
26
|
end
|
23
27
|
|
@@ -59,31 +59,16 @@ module Tanker
|
|
59
59
|
end
|
60
60
|
|
61
61
|
cresource_ids = CTanker.new_cstring_array resource_ids
|
62
|
-
|
63
|
-
|
64
|
-
cgroups = sharing_options[:recipient_group_ids]
|
65
|
-
nb_cgroups = sharing_options[:nb_recipient_group_ids]
|
66
|
-
|
67
|
-
CTanker.tanker_share(@ctanker, cusers, nb_cusers,
|
68
|
-
cgroups, nb_cgroups,
|
69
|
-
cresource_ids, resource_ids.length).get
|
62
|
+
|
63
|
+
CTanker.tanker_share(@ctanker, cresource_ids, resource_ids.length, sharing_options).get
|
70
64
|
end
|
71
65
|
|
72
|
-
def create_encryption_session(
|
73
|
-
|
74
|
-
|
75
|
-
nb_cusers = 0
|
76
|
-
cgroups = nil
|
77
|
-
nb_cgroups = 0
|
78
|
-
else
|
79
|
-
cusers = sharing_options[:recipient_public_identities]
|
80
|
-
nb_cusers = sharing_options[:nb_recipient_public_identities]
|
81
|
-
cgroups = sharing_options[:recipient_group_ids]
|
82
|
-
nb_cgroups = sharing_options[:nb_recipient_group_ids]
|
66
|
+
def create_encryption_session(encryption_options = nil)
|
67
|
+
unless !encryption_options || encryption_options.is_a?(EncryptionOptions)
|
68
|
+
raise TypeError, "expected encryption_options to be a EncryptionOptions, but got a #{encryption_options.class}"
|
83
69
|
end
|
84
70
|
|
85
|
-
csession = CTanker.tanker_encryption_session_open(@ctanker,
|
86
|
-
cgroups, nb_cgroups).get
|
71
|
+
csession = CTanker.tanker_encryption_session_open(@ctanker, encryption_options).get
|
87
72
|
EncryptionSession.new(csession)
|
88
73
|
end
|
89
74
|
|
@@ -96,6 +81,10 @@ module Tanker
|
|
96
81
|
private
|
97
82
|
|
98
83
|
def encrypt_common(data, encryption_options = nil)
|
84
|
+
unless !encryption_options || encryption_options.is_a?(EncryptionOptions)
|
85
|
+
raise TypeError, "expected encryption_options to be a EncryptionOptions, but got a #{encryption_options.class}"
|
86
|
+
end
|
87
|
+
|
99
88
|
inbuf = FFI::MemoryPointer.from_string(data)
|
100
89
|
|
101
90
|
encrypted_size = CTanker.tanker_encrypted_size data.bytesize
|
data/lib/tanker/core/init.rb
CHANGED
@@ -13,7 +13,9 @@ module Tanker
|
|
13
13
|
CTanker.tanker_destroy(FFI::Pointer.new(:void, ctanker_addr)).get
|
14
14
|
end
|
15
15
|
|
16
|
-
@device_revoked_handler =
|
16
|
+
@device_revoked_handler = lambda { |_|
|
17
|
+
Thread.new { @revoke_event_handlers.each(&:call) }
|
18
|
+
}
|
17
19
|
CTanker.tanker_event_connect(@ctanker, CTanker::CTankerEvent::DEVICE_REVOKED, @device_revoked_handler, nil).get
|
18
20
|
end
|
19
21
|
|
data/lib/tanker/core/session.rb
CHANGED
@@ -74,7 +74,7 @@ module Tanker
|
|
74
74
|
attach_ptr = CTanker.tanker_attach_provisional_identity(@ctanker, provisional_identity).get
|
75
75
|
attach_status = attach_ptr.get(:uint8, 1)
|
76
76
|
method_ptr = attach_ptr.get_pointer(FFI::Pointer.size)
|
77
|
-
method = CTanker::CVerificationMethod.new(method_ptr).to_verification_method
|
77
|
+
method = (CTanker::CVerificationMethod.new(method_ptr).to_verification_method if method_ptr.address != 0)
|
78
78
|
AttachResult.new attach_status, method
|
79
79
|
end
|
80
80
|
|
data/lib/tanker/core/stream.rb
CHANGED
@@ -6,7 +6,7 @@ require 'tanker/c_tanker'
|
|
6
6
|
module Tanker
|
7
7
|
class Core
|
8
8
|
def encrypt_stream(stream, encryption_options = nil)
|
9
|
-
Stream.do_stream_action(stream) { |cb| CTanker.tanker_stream_encrypt(@ctanker, cb,
|
9
|
+
Stream.do_stream_action(stream) { |cb| CTanker.tanker_stream_encrypt(@ctanker, cb, nil, encryption_options) }
|
10
10
|
end
|
11
11
|
|
12
12
|
def decrypt_stream(stream)
|
data/lib/tanker/core/version.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
require 'tanker/c_tanker/c_string'
|
5
|
+
|
6
|
+
module Tanker
|
7
|
+
# Options that can be given when encrypting data
|
8
|
+
class EncryptionOptions < FFI::Struct
|
9
|
+
def initialize(share_with_users: [], share_with_groups: [], share_with_self: true)
|
10
|
+
@users_objs = share_with_users.map { |id| CTanker.new_cstring id }
|
11
|
+
users = FFI::MemoryPointer.new(:pointer, share_with_users.length)
|
12
|
+
users.write_array_of_pointer(@users_objs)
|
13
|
+
|
14
|
+
@groups_objs = share_with_groups.map { |id| CTanker.new_cstring id }
|
15
|
+
groups = FFI::MemoryPointer.new(:pointer, share_with_groups.length)
|
16
|
+
groups.write_array_of_pointer(@groups_objs)
|
17
|
+
|
18
|
+
self[:version] = 3
|
19
|
+
self[:recipient_public_identities] = users
|
20
|
+
self[:nb_recipient_public_identities] = share_with_users.length
|
21
|
+
self[:recipient_group_ids] = groups
|
22
|
+
self[:nb_recipient_group_ids] = share_with_groups.length
|
23
|
+
self[:share_with_self] = share_with_self
|
24
|
+
end
|
25
|
+
|
26
|
+
layout :version, :uint8,
|
27
|
+
:recipient_public_identities, :pointer,
|
28
|
+
:nb_recipient_public_identities, :uint32,
|
29
|
+
:recipient_group_ids, :pointer,
|
30
|
+
:nb_recipient_group_ids, :uint32,
|
31
|
+
:share_with_self, :bool
|
32
|
+
end
|
33
|
+
end
|
@@ -4,39 +4,28 @@ require 'ffi'
|
|
4
4
|
require 'tanker/c_tanker/c_string'
|
5
5
|
|
6
6
|
module Tanker
|
7
|
-
|
7
|
+
# Options that can be given when sharing data
|
8
|
+
class SharingOptions < FFI::Struct
|
8
9
|
def initialize(share_with_users: [], share_with_groups: [])
|
9
|
-
@
|
10
|
-
|
10
|
+
@users_objs = share_with_users.map { |id| CTanker.new_cstring id }
|
11
|
+
users = FFI::MemoryPointer.new(:pointer, share_with_users.length)
|
12
|
+
users.write_array_of_pointer(@users_objs)
|
11
13
|
|
12
|
-
@
|
13
|
-
|
14
|
+
@groups_objs = share_with_groups.map { |id| CTanker.new_cstring id }
|
15
|
+
groups = FFI::MemoryPointer.new(:pointer, share_with_groups.length)
|
16
|
+
groups.write_array_of_pointer(@groups_objs)
|
14
17
|
|
15
|
-
self[:version] =
|
16
|
-
self[:recipient_public_identities] =
|
18
|
+
self[:version] = 1
|
19
|
+
self[:recipient_public_identities] = users
|
17
20
|
self[:nb_recipient_public_identities] = share_with_users.length
|
18
|
-
self[:recipient_group_ids] =
|
21
|
+
self[:recipient_group_ids] = groups
|
19
22
|
self[:nb_recipient_group_ids] = share_with_groups.length
|
20
23
|
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
:nb_recipient_group_ids, :uint32
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Options that can be given when sharing data
|
32
|
-
class SharingOptions < FFI::Struct
|
33
|
-
include CommonSharingOptions
|
25
|
+
layout :version, :uint8,
|
26
|
+
:recipient_public_identities, :pointer,
|
27
|
+
:nb_recipient_public_identities, :uint32,
|
28
|
+
:recipient_group_ids, :pointer,
|
29
|
+
:nb_recipient_group_ids, :uint32
|
34
30
|
end
|
35
|
-
|
36
|
-
# Options that can be given when encrypting data
|
37
|
-
class EncryptionOptions < FFI::Struct
|
38
|
-
include CommonSharingOptions
|
39
|
-
end
|
40
|
-
|
41
|
-
private_constant :CommonSharingOptions
|
42
31
|
end
|
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.4.
|
4
|
+
version: 2.4.1.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanker team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/tanker/core/verification.rb
|
162
162
|
- lib/tanker/core/verification_method.rb
|
163
163
|
- lib/tanker/core/version.rb
|
164
|
+
- lib/tanker/encryption_options.rb
|
164
165
|
- lib/tanker/error.rb
|
165
166
|
- lib/tanker/sharing_options.rb
|
166
167
|
- vendor/libctanker/linux64/tanker/lib/libctanker.so
|
@@ -178,14 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
179
|
requirements:
|
179
180
|
- - ">="
|
180
181
|
- !ruby/object:Gem::Version
|
181
|
-
version: 2.
|
182
|
+
version: 2.6.0
|
182
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
184
|
requirements:
|
184
185
|
- - ">"
|
185
186
|
- !ruby/object:Gem::Version
|
186
187
|
version: 1.3.1
|
187
188
|
requirements: []
|
188
|
-
rubygems_version: 3.
|
189
|
+
rubygems_version: 3.0.8
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Ruby SDK for Tanker
|