bcrypt 3.1.14 → 3.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/Gemfile.lock +2 -1
- data/Rakefile +2 -0
- 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 +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e986523481abb84081e888f1c3ddb5e5c17bcb77e3ea5648887915e4ec9f3c7b
|
4
|
+
data.tar.gz: 5f6d4a36f834a25e5a04629056579e8d3dbd5a1cdaab4179ac3d194d18993992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d47691e7ca1112931fbd91102cc856838106c5795a166ad0254e74b6cb1b4649c16c5397a18b1fbd07c7f681581467f4b38c2e0f3fffb0983d4ba318cced06d9
|
7
|
+
data.tar.gz: 2ffd846b1b354469b35d4ba3a7bf2d1e9a0bf1b6bf6bba5577bd0520d94a6453cae70c15701f801cadb1bc87f6835696d39b93243c3a45374d49572aed39492b
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coda Hale
|
@@ -11,12 +11,12 @@ cert_chain: []
|
|
11
11
|
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake-compiler
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: 0.9.2
|
19
|
+
name: rake-compiler
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -25,12 +25,12 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - ">="
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '3'
|
33
|
+
name: rspec
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,10 +50,10 @@ extra_rdoc_files:
|
|
50
50
|
- README.md
|
51
51
|
- COPYING
|
52
52
|
- CHANGELOG
|
53
|
+
- lib/bcrypt.rb
|
54
|
+
- lib/bcrypt/password.rb
|
53
55
|
- lib/bcrypt/engine.rb
|
54
56
|
- lib/bcrypt/error.rb
|
55
|
-
- lib/bcrypt/password.rb
|
56
|
-
- lib/bcrypt.rb
|
57
57
|
files:
|
58
58
|
- ".gitignore"
|
59
59
|
- ".rspec"
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.0.6
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: OpenBSD's bcrypt() password hashing algorithm.
|