fastpbkdf2 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -1
- data/ext/fastpbkdf2_native/binding.c +46 -43
- data/lib/fastpbkdf2.rb +1 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16883f21fbcfd33359a5aefb025f342b98a2c6da
|
4
|
+
data.tar.gz: 9b5f6000d448b714c4d4eb2866e773edc6c9e6fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8390afdeded31598004738bbcd9455c2622c66a7cbb7fd811f6e1fb74ae95ede7be34138d11bce37adf928793c7a83187636abe012e1a9e76ad95a61a042af31
|
7
|
+
data.tar.gz: 1b3e26a44bb4aaf41f8bd88ddd618ba7dcea518363de3fe9b7abebbc35f3a82a933583461cb2aac0750e1325ec5b3a0dc322e1c832e7725be210a9d7f781cab5
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rake/extensiontask'
|
2
2
|
|
3
|
-
spec = Gem::Specification.load('
|
3
|
+
spec = Gem::Specification.load('.gemspec')
|
4
4
|
Rake::ExtensionTask.new('fastpbkdf2_native', spec)
|
5
5
|
|
6
6
|
require 'rake/testtask'
|
@@ -9,3 +9,5 @@ Rake::TestTask.new do |t|
|
|
9
9
|
t.test_files = FileList['test/ruby/test*.rb']
|
10
10
|
t.verbose = true
|
11
11
|
end
|
12
|
+
|
13
|
+
task :default => :compile
|
@@ -3,52 +3,55 @@
|
|
3
3
|
|
4
4
|
static VALUE fastpbkdf2;
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
unsigned
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Check_Type(_salt, T_STRING)
|
22
|
-
salt = (
|
23
|
-
nsalt = RSTRING_LEN(_salt)
|
24
|
-
if (nsalt > 1024) {
|
25
|
-
rb_raise(rb_eRangeError, "salt length must be between 0 and 1024")
|
26
|
-
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
iterations
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
result = rb_str_new(out, keylen);
|
46
|
-
|
47
|
-
return result;
|
6
|
+
#define DECL(ALGORITHM) \
|
7
|
+
static VALUE ALGORITHM(VALUE self, VALUE _pw, VALUE _salt, VALUE _iterations, VALUE _keylen) {\
|
8
|
+
uint8_t *pw = NULL, *salt = NULL;\
|
9
|
+
size_t npw, nsalt;\
|
10
|
+
unsigned int iterations, keylen;\
|
11
|
+
unsigned char out[2048];\
|
12
|
+
VALUE result;\
|
13
|
+
\
|
14
|
+
Check_Type(_pw, T_STRING);\
|
15
|
+
pw = (uint8_t*) RSTRING_PTR(_pw);\
|
16
|
+
npw = RSTRING_LEN(_pw);\
|
17
|
+
if (npw > 1024) {\
|
18
|
+
rb_raise(rb_eRangeError, "password length must be between 0 and 1024");\
|
19
|
+
}\
|
20
|
+
\
|
21
|
+
Check_Type(_salt, T_STRING);\
|
22
|
+
salt = (uint8_t*) RSTRING_PTR(_salt);\
|
23
|
+
nsalt = RSTRING_LEN(_salt);\
|
24
|
+
if (nsalt > 1024) {\
|
25
|
+
rb_raise(rb_eRangeError, "salt length must be between 0 and 1024");\
|
26
|
+
}\
|
27
|
+
\
|
28
|
+
Check_Type(_iterations, T_FIXNUM);\
|
29
|
+
iterations = NUM2ULL(_iterations);\
|
30
|
+
if (iterations <= 0) {\
|
31
|
+
rb_raise(rb_eRangeError, "iterations must be greater than 0");\
|
32
|
+
}\
|
33
|
+
\
|
34
|
+
Check_Type(_keylen, T_FIXNUM);\
|
35
|
+
keylen = NUM2ULL(_keylen);\
|
36
|
+
if (keylen <= 0 || keylen > 1024) {\
|
37
|
+
rb_raise(rb_eRangeError, "keylen must be between 1 and 1024");\
|
38
|
+
}\
|
39
|
+
\
|
40
|
+
fastpbkdf2_hmac_##ALGORITHM(pw, npw, salt, nsalt, iterations, out, keylen);\
|
41
|
+
\
|
42
|
+
result = rb_str_new((char *)out, keylen);\
|
43
|
+
\
|
44
|
+
return result;\
|
48
45
|
}
|
49
46
|
|
47
|
+
DECL(sha1)
|
48
|
+
DECL(sha256)
|
49
|
+
DECL(sha512)
|
50
|
+
|
50
51
|
void Init_fastpbkdf2_native(void) {
|
51
52
|
fastpbkdf2 = rb_define_module("Fastpbkdf2");
|
52
53
|
|
53
|
-
rb_define_module_function(fastpbkdf2, "sha1",
|
54
|
+
rb_define_module_function(fastpbkdf2, "sha1", sha1, 4);
|
55
|
+
rb_define_module_function(fastpbkdf2, "sha256", sha256, 4);
|
56
|
+
rb_define_module_function(fastpbkdf2, "sha512", sha512, 4);
|
54
57
|
}
|
data/lib/fastpbkdf2.rb
CHANGED
@@ -1,14 +1 @@
|
|
1
|
-
require 'fastpbkdf2_native'
|
2
|
-
|
3
|
-
#"\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6"
|
4
|
-
|
5
|
-
|
6
|
-
# class LZ4
|
7
|
-
# def self.compress(source)
|
8
|
-
# return LZ4Native::compress(source)
|
9
|
-
# end
|
10
|
-
|
11
|
-
# def self.uncompress(source)
|
12
|
-
# return LZ4Native::uncompress(source)
|
13
|
-
# end
|
14
|
-
# end
|
1
|
+
require 'fastpbkdf2_native'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastpbkdf2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- S-YOU
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|