Skip to content

Commit 3fd8137

Browse files
committed
Relocated attach_function in Ext module back into engine to resolve gem complication issues
1 parent 56dc031 commit 3fd8137

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

lib/scrypt.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
# A wrapper for the scrypt algorithm.
44

5-
require 'scrypt/engine'
65
require 'scrypt/errors'
7-
require 'scrypt/password'
86
require 'scrypt/scrypt_ext'
97
require 'scrypt/security_utils'
8+
9+
require 'scrypt/engine'
10+
require 'scrypt/password'

lib/scrypt/engine.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@
44
require 'openssl'
55

66
module SCrypt
7+
module Ext
8+
# rubocop:disable Style/SymbolArray
9+
# Bind the external functions
10+
attach_function :sc_calibrate,
11+
[:size_t, :double, :double, :pointer],
12+
:int,
13+
blocking: true
14+
15+
attach_function :crypto_scrypt,
16+
[:pointer, :size_t, :pointer, :size_t, :uint64, :uint32, :uint32, :pointer, :size_t],
17+
:int,
18+
blocking: true # todo
19+
# rubocop:enable
20+
end
21+
722
class Engine
23+
# rubocop:disable Style/MutableConstant
824
DEFAULTS = {
925
key_len: 32,
1026
salt_size: 32,
@@ -13,6 +29,7 @@ class Engine
1329
max_time: 0.2,
1430
cost: nil
1531
}
32+
# rubocop:enable
1633

1734
class Calibration < FFI::Struct
1835
layout :n, :uint64,

lib/scrypt/scrypt_ext.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,5 @@ module Ext
88
extend FFI::Library
99

1010
ffi_lib FFI::Compiler::Loader.find('scrypt_ext')
11-
12-
# rubocop:disable Style/SymbolArray
13-
14-
# Bind the external functions
15-
attach_function :sc_calibrate,
16-
[:size_t, :double, :double, :pointer],
17-
:int,
18-
blocking: true
19-
20-
attach_function :crypto_scrypt,
21-
[:pointer, :size_t, :pointer, :size_t, :uint64, :uint32, :uint32, :pointer, :size_t],
22-
:int,
23-
blocking: true # todo
24-
25-
# rubocop:enable
2611
end
2712
end

0 commit comments

Comments
 (0)