bcrypt 3.1.14-java → 3.1.15-java
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 +4 -4
- data/CHANGELOG +3 -0
- data/Gemfile.lock +1 -1
- data/bcrypt.gemspec +1 -1
- data/ext/mri/bcrypt_ext.c +18 -70
- data/lib/bcrypt/password.rb +1 -1
- data/spec/bcrypt/password_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daebd0457608f18460625651148836dac8c525da398e08e75cb97244f6e19003
|
4
|
+
data.tar.gz: bc87d1670e61c2e420e610f3f32ae5159560b6d6171617a35cb78d9efc18a6f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f18e30c92f9b3297e325c6c24f7466ad108f71d0fc1584d886b23d8cdb4408ef94a0c479cb1266e54f91f81ca9090dbd2109378724881a264fc6140c734e4fa7
|
7
|
+
data.tar.gz: 7ca77307a151d8ecedd50b9cba02ed3b3e34ff2a1c80ba05656f007f1eb161064cabdbf0267a6024819397c04c707ed7ab6e27f643b80879c14e1ed4c59479f0
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/bcrypt.gemspec
CHANGED
data/ext/mri/bcrypt_ext.c
CHANGED
@@ -1,50 +1,20 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <ow-crypt.h>
|
3
3
|
|
4
|
-
#ifdef HAVE_RUBY_THREAD_H
|
5
|
-
#include <ruby/thread.h>
|
6
|
-
#endif
|
7
|
-
|
8
4
|
static VALUE mBCrypt;
|
9
5
|
static VALUE cBCryptEngine;
|
10
6
|
|
11
|
-
struct bc_salt_args {
|
12
|
-
const char * prefix;
|
13
|
-
unsigned long count;
|
14
|
-
const char * input;
|
15
|
-
int size;
|
16
|
-
};
|
17
|
-
|
18
|
-
static void * bc_salt_nogvl(void * ptr) {
|
19
|
-
struct bc_salt_args * args = ptr;
|
20
|
-
|
21
|
-
return crypt_gensalt_ra(args->prefix, args->count, args->input, args->size);
|
22
|
-
}
|
23
|
-
|
24
7
|
/* Given a logarithmic cost parameter, generates a salt for use with +bc_crypt+.
|
25
8
|
*/
|
26
9
|
static VALUE bc_salt(VALUE self, VALUE prefix, VALUE count, VALUE input) {
|
27
10
|
char * salt;
|
28
11
|
VALUE str_salt;
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
prefix = rb_str_new_frozen(prefix);
|
36
|
-
input = rb_str_new_frozen(input);
|
37
|
-
|
38
|
-
args.prefix = StringValueCStr(prefix);
|
39
|
-
args.count = NUM2ULONG(count);
|
40
|
-
args.input = NIL_P(input) ? NULL : StringValuePtr(input);
|
41
|
-
args.size = NIL_P(input) ? 0 : RSTRING_LEN(input);
|
42
|
-
|
43
|
-
#ifdef HAVE_RUBY_THREAD_H
|
44
|
-
salt = rb_thread_call_without_gvl(bc_salt_nogvl, &args, NULL, NULL);
|
45
|
-
#else
|
46
|
-
salt = bc_salt_nogvl((void *)&args);
|
47
|
-
#endif
|
12
|
+
|
13
|
+
salt = crypt_gensalt_ra(
|
14
|
+
StringValuePtr(prefix),
|
15
|
+
NUM2ULONG(count),
|
16
|
+
NIL_P(input) ? NULL : StringValuePtr(input),
|
17
|
+
NIL_P(input) ? 0 : RSTRING_LEN(input));
|
48
18
|
|
49
19
|
if(!salt) return Qnil;
|
50
20
|
|
@@ -54,52 +24,30 @@ static VALUE bc_salt(VALUE self, VALUE prefix, VALUE count, VALUE input) {
|
|
54
24
|
return str_salt;
|
55
25
|
}
|
56
26
|
|
57
|
-
struct bc_crypt_args {
|
58
|
-
const char * key;
|
59
|
-
const char * setting;
|
60
|
-
void * data;
|
61
|
-
int size;
|
62
|
-
};
|
63
|
-
|
64
|
-
static void * bc_crypt_nogvl(void * ptr) {
|
65
|
-
struct bc_crypt_args * args = ptr;
|
66
|
-
|
67
|
-
return crypt_ra(args->key, args->setting, &args->data, &args->size);
|
68
|
-
}
|
69
|
-
|
70
27
|
/* Given a secret and a salt, generates a salted hash (which you can then store safely).
|
71
28
|
*/
|
72
29
|
static VALUE bc_crypt(VALUE self, VALUE key, VALUE setting) {
|
73
30
|
char * value;
|
31
|
+
void * data;
|
32
|
+
int size;
|
74
33
|
VALUE out;
|
75
34
|
|
76
|
-
|
35
|
+
data = NULL;
|
36
|
+
size = 0xDEADBEEF;
|
77
37
|
|
78
38
|
if(NIL_P(key) || NIL_P(setting)) return Qnil;
|
79
39
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
setting = rb_str_new_frozen(setting);
|
86
|
-
|
87
|
-
args.data = NULL;
|
88
|
-
args.size = 0xDEADBEEF;
|
89
|
-
args.key = NIL_P(key) ? NULL : StringValueCStr(key);
|
90
|
-
args.setting = NIL_P(setting) ? NULL : StringValueCStr(setting);
|
91
|
-
|
92
|
-
#ifdef HAVE_RUBY_THREAD_H
|
93
|
-
value = rb_thread_call_without_gvl(bc_crypt_nogvl, &args, NULL, NULL);
|
94
|
-
#else
|
95
|
-
value = bc_crypt_nogvl((void *)&args);
|
96
|
-
#endif
|
40
|
+
value = crypt_ra(
|
41
|
+
NIL_P(key) ? NULL : StringValuePtr(key),
|
42
|
+
NIL_P(setting) ? NULL : StringValuePtr(setting),
|
43
|
+
&data,
|
44
|
+
&size);
|
97
45
|
|
98
|
-
if(!value || !
|
46
|
+
if(!value || !data) return Qnil;
|
99
47
|
|
100
|
-
out =
|
48
|
+
out = rb_str_new2(value);
|
101
49
|
|
102
|
-
|
50
|
+
xfree(data);
|
103
51
|
|
104
52
|
return out;
|
105
53
|
}
|
data/lib/bcrypt/password.rb
CHANGED
@@ -116,9 +116,9 @@ end
|
|
116
116
|
|
117
117
|
describe "Validating a password hash" do
|
118
118
|
specify "should not accept an invalid password" do
|
119
|
-
expect(BCrypt::Password.valid_hash?("i_am_so_not_valid")).to
|
119
|
+
expect(BCrypt::Password.valid_hash?("i_am_so_not_valid")).to be(false)
|
120
120
|
end
|
121
121
|
specify "should accept a valid password" do
|
122
|
-
expect(BCrypt::Password.valid_hash?(BCrypt::Password.create "i_am_so_valid")).to
|
122
|
+
expect(BCrypt::Password.valid_hash?(BCrypt::Password.create "i_am_so_valid")).to be(true)
|
123
123
|
end
|
124
124
|
end
|