rbthemis 0.13.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbthemis.rb +46 -3
  3. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b961537ca7de62ffe35b208cdb6cd859c30dcdea841f11ba313612018005da0
4
- data.tar.gz: 86e0f4632b5a651cd9ed5085bab004a054f49ce6f10b01056ac480af553f734d
3
+ metadata.gz: 737ccca2cb74d04c18abe43c4aa5ee65def9cef6c0d3bcd89410c76abf12e7fa
4
+ data.tar.gz: ce08155c7d83bbda14acc0a79185b7943b1ee6d39c28a28c99b92082accf216e
5
5
  SHA512:
6
- metadata.gz: ddb38e6216be4223661725ad06d126759dca0eaca658a884114515f0fb9982e4433a80231a1ad476d6a2a4ef355ae49231449d16dbfc720556ca74533bb82fb7
7
- data.tar.gz: 1299e49545f8e0ddecd6e5c446ad966e959d74474fd248a042f25889a34ba29d0a0ccbebd9fa8e001ad8d4f059398234636326006aad81542391f63e8107d86d
6
+ metadata.gz: a60a03fbd1947834c2cce2399f1c58ef71c1714feed534bd4cfe9f6445036eb1824bed92e60900249f89e785532d1d6233625c64b95309e19b16c27bfddb85d5
7
+ data.tar.gz: ffd1759217dab678e0554aa30566feaec18bbcc6e7b172072f1d77b101d1e95bac0d502db9d6fe971d41bd2770bf27eaddae7fb773c39265fedaf39020c7d4ff
data/lib/rbthemis.rb CHANGED
@@ -32,7 +32,50 @@ end
32
32
 
33
33
  module ThemisImport
34
34
  extend FFI::Library
35
- ffi_lib 'themis'
35
+
36
+ def self.canonical_themis_paths
37
+ host_os = RbConfig::CONFIG['host_os']
38
+ paths = []
39
+ if host_os.start_with? 'linux'
40
+ # Default library installation path for "make install"
41
+ paths.append '/usr/local/lib/libthemis.so.0'
42
+ # Don't bother figuring out the "right" absolute path, since
43
+ # that depends on the distro and non-distro-provided Rubies
44
+ # don't know about the right paths at all. The ones installed
45
+ # via RVM certainly don't. Use soname and let ld figure it out.
46
+ paths.append 'libthemis.so.0'
47
+ end
48
+ if host_os.start_with? 'darwin'
49
+ # Default library installation path for "make install"
50
+ paths.append '/usr/local/lib/libthemis.0.dylib'
51
+ # These are install names of libraries installed via Homebrew
52
+ # Add both M1 and Intel paths so that x86 Ruby works on M1
53
+ paths.append '/opt/homebrew/opt/libthemis/lib/libthemis.0.dylib'
54
+ paths.append '/usr/local/opt/libthemis/lib/libthemis.0.dylib'
55
+ # Last try, look for ABI-qualified name
56
+ paths.append 'libthemis.0.dylib'
57
+ end
58
+ return paths
59
+ end
60
+
61
+ def self.load_themis
62
+ for path in canonical_themis_paths
63
+ begin
64
+ return ffi_lib path
65
+ rescue LoadError
66
+ next
67
+ end
68
+ end
69
+ warn <<~EOF
70
+ WARN: failed to load the canonical Themis Core library
71
+
72
+ Proceeding to find 'themis' library in standard paths.
73
+ This might cause ABI mismatch and crash the process.
74
+ EOF
75
+ return ffi_lib 'themis'
76
+ end
77
+
78
+ load_themis
36
79
 
37
80
  callback :get_pub_key_by_id_type,
38
81
  [:pointer, :int, :pointer, :int, :pointer], :int
@@ -274,7 +317,7 @@ module Themis
274
317
  @session = secure_session_create(
275
318
  id_buf, id_length, private_key_buf, private_key_length, @callbacks)
276
319
 
277
- raise ThemisError, 'Secure Session failed creating' unless @session
320
+ raise ThemisError, 'Secure Session failed creating' if @session.null?
278
321
  end
279
322
 
280
323
  def is_established
@@ -925,7 +968,7 @@ module Themis
925
968
  shared_secret_buf, shared_secret_length =
926
969
  string_to_pointer_size(shared_secret)
927
970
  @comparator = secure_comparator_create
928
- raise ThemisError, 'Secure Comparator failed creating' unless @comparator
971
+ raise ThemisError, 'Secure Comparator failed creating' if @comparator.null?
929
972
  res = secure_comparator_append_secret(
930
973
  @comparator, shared_secret_buf, shared_secret_length)
931
974
  if res != SUCCESS
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbthemis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CossackLabs
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-08 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -44,7 +44,7 @@ homepage: http://cossacklabs.com/
44
44
  licenses:
45
45
  - Apache-2.0
46
46
  metadata: {}
47
- post_install_message:
47
+ post_install_message:
48
48
  rdoc_options: []
49
49
  require_paths:
50
50
  - lib
@@ -59,9 +59,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements:
62
- - libthemis, v0.13.0
63
- rubygems_version: 3.0.2
64
- signing_key:
62
+ - libthemis, v0.15.0
63
+ rubygems_version: 3.3.25
64
+ signing_key:
65
65
  specification_version: 4
66
66
  summary: Data security library for network communication and data storage for Ruby
67
67
  test_files: []