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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9581d38b9f8ace7c8c0ef1a7a9e4a73dd1c4326392de7147dfe2a51e42c5b9a0
4
- data.tar.gz: 2aedddb181acd0cdf6d3506f78c20148057968e8c53d89a90778673aa825e271
3
+ metadata.gz: daebd0457608f18460625651148836dac8c525da398e08e75cb97244f6e19003
4
+ data.tar.gz: bc87d1670e61c2e420e610f3f32ae5159560b6d6171617a35cb78d9efc18a6f8
5
5
  SHA512:
6
- metadata.gz: 60a8e9c4381fc55f5323204391d0f2c5c17bb0e2b0660d43db58c124c1aaceb29cd03b3e565ad48796d71da94aa1d049ad5ab24eb61bbc30a429a22b74a94961
7
- data.tar.gz: 7a8c99a0ac391f11cb55d7e8ce12125f6892aaea701c4c26ffbdc486a8cd87b3215e5f7a903ef063c36d4954fa262c13ab40f086b0f5a8d8f8d60f87b0daeb13
6
+ metadata.gz: f18e30c92f9b3297e325c6c24f7466ad108f71d0fc1584d886b23d8cdb4408ef94a0c479cb1266e54f91f81ca9090dbd2109378724881a264fc6140c734e4fa7
7
+ data.tar.gz: 7ca77307a151d8ecedd50b9cba02ed3b3e34ff2a1c80ba05656f007f1eb161064cabdbf0267a6024819397c04c707ed7ab6e27f643b80879c14e1ed4c59479f0
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 3.1.15 July 21 2020
2
+ - Remove GVL optimization. Apparently it breaks things [GH #230]
3
+
1
4
  3.1.14 July 21 2020
2
5
  - Start calibration from the minimum cost supported by the algorithm [GH #206 by @sergey-alekseev]
3
6
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bcrypt (3.1.14)
4
+ bcrypt (3.1.15)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bcrypt'
3
- s.version = '3.1.14'
3
+ s.version = '3.1.15'
4
4
 
5
5
  s.summary = "OpenBSD's bcrypt() password hashing algorithm."
6
6
  s.description = <<-EOF
@@ -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
- struct bc_salt_args args;
30
-
31
- /* duplicate the parameters for thread safety. If another thread has a
32
- * reference to the parameters and mutates them while we are working,
33
- * that would be very bad. Duping the strings means that the reference
34
- * isn't shared. */
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
- struct bc_crypt_args args;
35
+ data = NULL;
36
+ size = 0xDEADBEEF;
77
37
 
78
38
  if(NIL_P(key) || NIL_P(setting)) return Qnil;
79
39
 
80
- /* duplicate the parameters for thread safety. If another thread has a
81
- * reference to the parameters and mutates them while we are working,
82
- * that would be very bad. Duping the strings means that the reference
83
- * isn't shared. */
84
- key = rb_str_new_frozen(key);
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 || !args.data) return Qnil;
46
+ if(!value || !data) return Qnil;
99
47
 
100
- out = rb_str_new(args.data, args.size - 1);
48
+ out = rb_str_new2(value);
101
49
 
102
- free(args.data);
50
+ xfree(data);
103
51
 
104
52
  return out;
105
53
  }
@@ -47,7 +47,7 @@ module BCrypt
47
47
  end
48
48
 
49
49
  def valid_hash?(h)
50
- h =~ /^\$[0-9a-z]{2}\$[0-9]{2}\$[A-Za-z0-9\.\/]{53}$/
50
+ /^\$[0-9a-z]{2}\$[0-9]{2}\$[A-Za-z0-9\.\/]{53}$/ === h
51
51
  end
52
52
  end
53
53
 
@@ -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 be_falsey
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 be_truthy
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.14
4
+ version: 3.1.15
5
5
  platform: java
6
6
  authors:
7
7
  - Coda Hale