scrypt 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/mri/extconf.rb DELETED
@@ -1,5 +0,0 @@
1
- require "mkmf"
2
- dir_config("scrypt_ext")
3
- CONFIG['CC'] << " -Wall -msse -msse2 "
4
- CONFIG['CC'] << " -D_GNU_SOURCE=1 " if CONFIG["target_os"]["mingw"]
5
- create_makefile("scrypt_ext")
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