consttime_memequal 1 → 2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de7388eb1294d6b13fe781c4ab9ac3b5b25cb240
4
- data.tar.gz: db1d1daa241d255fc4338a37d1c087f26fba125a
3
+ metadata.gz: 21438eb0c877ed5159fea334addbc864654eca7a
4
+ data.tar.gz: dc1bc232c52fa5cdc89a3e47a8b87d85296d96fe
5
5
  SHA512:
6
- metadata.gz: b61060e7f2f889eec00aa0d9f65f59b8c33349db6ab5f21ba64072570be9222ed59433919ffd091e1762c93162da25d5ba446f053d041184eca2cb4705b4a99a
7
- data.tar.gz: '079833b63df4252ef342fb764ae9708fecd4af253cb278658058739d0ead927cc84e0d9b8e2ea79d9c9dc397c73853af427b033440aedc8f85ac7681baf88cf6'
6
+ metadata.gz: 7c57c1357ddcd0fd13cb2f722b099a3239d41d63556de0e1fc24e7d166b8604f41183d1e752fa3b24cf0ac009f3fcf4a6e49c11ed83d7ac3b40d423d18b7fcae
7
+ data.tar.gz: f47543711df5e413e6790fb215a1bd1999984df556e0f207f19b2e962467aa0e85ebc3e9221d028ba744b94fceece5bddd2e346f29a66d0dcd63b2ad917bc92f
data/Gemfile CHANGED
@@ -25,4 +25,7 @@
25
25
 
26
26
  source 'https://rubygems.org'
27
27
  gemspec
28
- gem 'openssl'
28
+ if RUBY_VERSION >= '2.3.0'
29
+ gem 'openssl'
30
+ gem 'fiddle'
31
+ end
@@ -25,7 +25,7 @@
25
25
 
26
26
  Gem::Specification.new do |spec|
27
27
  spec.name = 'consttime_memequal'
28
- spec.version = 1
28
+ spec.version = 2
29
29
  spec.author = 'Urabe, Shyouhei'
30
30
  spec.email = 'shyouhei@ruby-lang.org'
31
31
  spec.summary = 'provides consttime_memequal?'
@@ -41,5 +41,4 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency 'rake'
42
42
  spec.add_development_dependency 'pry' # used in bin/console
43
43
  spec.required_ruby_version = '>= 2.0.0'
44
- spec.add_runtime_dependency 'fiddle'
45
44
  end
@@ -25,7 +25,8 @@
25
25
 
26
26
  dlsym = lambda do |symbol, lib = 'fiddle'|
27
27
  begin
28
- gem lib and require lib
28
+ gem lib if RUBY_VERSION >= '2.3.0'
29
+ require lib
29
30
  libc = Fiddle.dlopen nil
30
31
  ptr = libc.sym symbol
31
32
  func = Fiddle::Function.new ptr, \
@@ -43,7 +44,7 @@ end
43
44
 
44
45
  case
45
46
  when func = dlsym.call('consttime_memequal') then
46
- define_method :consttime_memequal do |this, that, len = this.bytesize|
47
+ define_method :consttime_memequal? do |this, that, len = this.bytesize|
47
48
  src = Fiddle::Pointer.to_ptr this
48
49
  dst = Fiddle::Pointer.to_ptr that
49
50
  ret = func.call src, dst, len
@@ -56,7 +57,7 @@ when func = dlsym.call('consttime_memequal') then
56
57
  end
57
58
 
58
59
  when func = dlsym.call('timingsafe_memcmp') then
59
- define_method :consttime_memequal do |this, that, len = this.bytesize|
60
+ define_method :consttime_memequal? do |this, that, len = this.bytesize|
60
61
  src = Fiddle::Pointer.to_ptr this
61
62
  dst = Fiddle::Pointer.to_ptr that
62
63
  ret = func.call src, dst, len
@@ -64,7 +65,7 @@ when func = dlsym.call('timingsafe_memcmp') then
64
65
  end
65
66
 
66
67
  when func = dlsym.call('timingsafe_bcmp') then
67
- define_method :consttime_memequal do |this, that, len = this.bytesize|
68
+ define_method :consttime_memequal? do |this, that, len = this.bytesize|
68
69
  src = Fiddle::Pointer.to_ptr this
69
70
  dst = Fiddle::Pointer.to_ptr that
70
71
  ret = func.call src, dst, len
@@ -72,7 +73,7 @@ when func = dlsym.call('timingsafe_bcmp') then
72
73
  end
73
74
 
74
75
  when func = dlsym.call('CRYPTO_memcmp', 'openssl') then
75
- define_method :consttime_memequal do |this, that, len = this.bytesize|
76
+ define_method :consttime_memequal? do |this, that, len = this.bytesize|
76
77
  src = Fiddle::Pointer.to_ptr this
77
78
  dst = Fiddle::Pointer.to_ptr that
78
79
  ret = func.call src, dst, len
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consttime_memequal
3
3
  version: !ruby/object:Gem::Version
4
- version: '1'
4
+ version: '2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urabe, Shyouhei
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: fiddle
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  description: Wrapper to OS-provided timing-safe memory comparison.
70
56
  email: shyouhei@ruby-lang.org
71
57
  executables: []