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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91feef6cbd30f7651c84a8b01e8c89e0072314bef8d3d980df592c74646945fe
4
- data.tar.gz: 612ec7a098b11202dcee1e2a1d24dbe5c0d00c07938e69d4bf2c26c6f4767edc
3
+ metadata.gz: e986523481abb84081e888f1c3ddb5e5c17bcb77e3ea5648887915e4ec9f3c7b
4
+ data.tar.gz: 5f6d4a36f834a25e5a04629056579e8d3dbd5a1cdaab4179ac3d194d18993992
5
5
  SHA512:
6
- metadata.gz: '08e1645f62b5b0bf9211a74d47f7660d6491ae218c073e11f135177476d33d36b267994e2ada56c10cd66e45157d3237fd3ed275f369f105e345b6e17b1cccc7'
7
- data.tar.gz: 59d0d18110c202e8fddb58c97f3c6e33cafe767e6a567e02b8b0aff7ce6e9af345d723df8d59d4f7aa557a8dcc9ac22863b298e9cb37c990f5bf1514cbc32526
6
+ metadata.gz: d47691e7ca1112931fbd91102cc856838106c5795a166ad0254e74b6cb1b4649c16c5397a18b1fbd07c7f681581467f4b38c2e0f3fffb0983d4ba318cced06d9
7
+ data.tar.gz: 2ffd846b1b354469b35d4ba3a7bf2d1e9a0bf1b6bf6bba5577bd0520d94a6453cae70c15701f801cadb1bc87f6835696d39b93243c3a45374d49572aed39492b
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/
@@ -25,6 +25,7 @@ GEM
25
25
  rspec-support (3.9.3)
26
26
 
27
27
  PLATFORMS
28
+ java
28
29
  ruby
29
30
 
30
31
  DEPENDENCIES
data/Rakefile CHANGED
@@ -50,6 +50,8 @@ end
50
50
  if RUBY_PLATFORM =~ /java/
51
51
  Rake::JavaExtensionTask.new('bcrypt_ext', GEMSPEC) do |ext|
52
52
  ext.ext_dir = 'ext/jruby'
53
+ ext.source_version = "1.7"
54
+ ext.target_version = "1.7"
53
55
  end
54
56
  else
55
57
  Rake::ExtensionTask.new("bcrypt_ext", GEMSPEC) do |ext|
@@ -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: 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.2.0.pre1
115
+ rubygems_version: 3.0.6
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: OpenBSD's bcrypt() password hashing algorithm.