Skip to content

Commit

Permalink
Relocated attach_function in Ext module back into engine to resol…
Browse files Browse the repository at this point in the history
…ve gem complication issues
  • Loading branch information
johanns committed Nov 14, 2019
1 parent 56dc031 commit 3fd8137
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
5 changes: 3 additions & 2 deletions lib/scrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# A wrapper for the scrypt algorithm.

require 'scrypt/engine'
require 'scrypt/errors'
require 'scrypt/password'
require 'scrypt/scrypt_ext'
require 'scrypt/security_utils'

require 'scrypt/engine'
require 'scrypt/password'
17 changes: 17 additions & 0 deletions lib/scrypt/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@
require 'openssl'

module SCrypt
module Ext
# rubocop:disable Style/SymbolArray
# Bind the external functions
attach_function :sc_calibrate,
[:size_t, :double, :double, :pointer],
:int,
blocking: true

attach_function :crypto_scrypt,
[:pointer, :size_t, :pointer, :size_t, :uint64, :uint32, :uint32, :pointer, :size_t],
:int,
blocking: true # todo
# rubocop:enable
end

class Engine
# rubocop:disable Style/MutableConstant
DEFAULTS = {
key_len: 32,
salt_size: 32,
Expand All @@ -13,6 +29,7 @@ class Engine
max_time: 0.2,
cost: nil
}
# rubocop:enable

class Calibration < FFI::Struct
layout :n, :uint64,
Expand Down
15 changes: 0 additions & 15 deletions lib/scrypt/scrypt_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,5 @@ module Ext
extend FFI::Library

ffi_lib FFI::Compiler::Loader.find('scrypt_ext')

# rubocop:disable Style/SymbolArray

# Bind the external functions
attach_function :sc_calibrate,
[:size_t, :double, :double, :pointer],
:int,
blocking: true

attach_function :crypto_scrypt,
[:pointer, :size_t, :pointer, :size_t, :uint64, :uint32, :uint32, :pointer, :size_t],
:int,
blocking: true # todo

# rubocop:enable
end
end

0 comments on commit 3fd8137

Please sign in to comment.