scrypt 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +33 -13
- data/Rakefile +37 -17
- data/ext/scrypt/Rakefile +9 -0
- data/ext/{mri → scrypt}/crypto_scrypt-sse.c +3 -2
- data/ext/{mri → scrypt}/crypto_scrypt.h +2 -1
- data/ext/{mri → scrypt}/memlimit.c +0 -0
- data/ext/{mri → scrypt}/memlimit.h +0 -0
- data/ext/{mri → scrypt}/scrypt_calibrate.c +0 -0
- data/ext/{mri → scrypt}/scrypt_calibrate.h +0 -0
- data/ext/scrypt/scrypt_ext.c +16 -0
- data/ext/scrypt/scrypt_ext.h +13 -0
- data/ext/{mri → scrypt}/scrypt_platform.h +0 -0
- data/ext/{mri → scrypt}/scryptenc_cpuperf.c +1 -1
- data/ext/{mri → scrypt}/scryptenc_cpuperf.h +0 -0
- data/ext/{mri → scrypt}/sha256.c +0 -0
- data/ext/{mri → scrypt}/sha256.h +0 -0
- data/ext/{mri → scrypt}/sysendian.h +0 -0
- data/lib/scrypt.rb +50 -5
- data/lib/scrypt/scrypt_ext.rb +9 -0
- data/lib/scrypt/version.rb +1 -1
- data/scrypt.gemspec +6 -6
- data/spec/scrypt/engine_spec.rb +2 -2
- data/spec/scrypt/password_spec.rb +3 -3
- metadata +61 -69
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.rvmrc +0 -1
- data/.travis.yml +0 -4
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -32
- data/ext/mri/alt-impl/crypto_scrypt-nosse.c +0 -340
- data/ext/mri/alt-impl/crypto_scrypt-ref.c +0 -284
- data/ext/mri/extconf.rb +0 -5
- data/ext/mri/scrypt_ext.c +0 -70
- data/kdf-comparison.png +0 -0
data/ext/mri/extconf.rb
DELETED
data/ext/mri/scrypt_ext.c
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
#include "ruby.h"
|
2
|
-
#include "scrypt_calibrate.h"
|
3
|
-
#include "crypto_scrypt.h"
|
4
|
-
|
5
|
-
|
6
|
-
static VALUE mSCrypt;
|
7
|
-
static VALUE cSCryptEngine;
|
8
|
-
|
9
|
-
|
10
|
-
#ifndef RSTRING_PTR
|
11
|
-
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
12
|
-
#endif
|
13
|
-
|
14
|
-
|
15
|
-
static VALUE sc_calibrate( VALUE self, VALUE maxmem, VALUE maxmemfrac, VALUE maxtime )
|
16
|
-
{
|
17
|
-
uint64_t n = 0;
|
18
|
-
uint32_t r = 0;
|
19
|
-
uint32_t p = 0;
|
20
|
-
|
21
|
-
size_t mm = NUM2UINT( maxmem );
|
22
|
-
double mf = rb_num2dbl( maxmemfrac );
|
23
|
-
double mt = rb_num2dbl( maxtime );
|
24
|
-
|
25
|
-
if (calibrate( mm, mf, mt, & n, & r, & p ) == 0)
|
26
|
-
{
|
27
|
-
return rb_ary_new3( 3, UINT2NUM( n ), UINT2NUM( r ), UINT2NUM( p ));
|
28
|
-
}
|
29
|
-
|
30
|
-
return Qnil;
|
31
|
-
}
|
32
|
-
|
33
|
-
|
34
|
-
static VALUE sc_crypt( VALUE self, VALUE key, VALUE salt, VALUE n, VALUE r, VALUE p, VALUE keylen )
|
35
|
-
{
|
36
|
-
int result;
|
37
|
-
|
38
|
-
const char * safe_key = RSTRING_PTR(key) ? RSTRING_PTR(key) : "";
|
39
|
-
const char * safe_salt = RSTRING_PTR(salt) ? RSTRING_PTR(salt) : "";
|
40
|
-
|
41
|
-
const size_t buffer_size = NUM2UINT( keylen );
|
42
|
-
char buffer[buffer_size];
|
43
|
-
memset( buffer, '\0', buffer_size );
|
44
|
-
|
45
|
-
result = crypto_scrypt(
|
46
|
-
(uint8_t *) safe_key, strlen(safe_key),
|
47
|
-
(uint8_t *) safe_salt, strlen(safe_salt),
|
48
|
-
NUM2UINT( n ), NUM2UINT( r ), NUM2UINT( p ),
|
49
|
-
(uint8_t *) buffer, buffer_size
|
50
|
-
);
|
51
|
-
|
52
|
-
if (result == 0)
|
53
|
-
{
|
54
|
-
return rb_str_new( buffer, buffer_size );
|
55
|
-
}
|
56
|
-
|
57
|
-
printf( "error %d \n", result );
|
58
|
-
|
59
|
-
return Qnil;
|
60
|
-
}
|
61
|
-
|
62
|
-
|
63
|
-
void Init_scrypt_ext()
|
64
|
-
{
|
65
|
-
mSCrypt = rb_define_module( "SCrypt" );
|
66
|
-
cSCryptEngine = rb_define_class_under( mSCrypt, "Engine", rb_cObject );
|
67
|
-
|
68
|
-
rb_define_singleton_method( cSCryptEngine, "__sc_calibrate", sc_calibrate, 3 );
|
69
|
-
rb_define_singleton_method( cSCryptEngine, "__sc_crypt", sc_crypt, 6 );
|
70
|
-
}
|
data/kdf-comparison.png
DELETED
Binary file
|