bcrypt_pbkdf 1.0.1.rc1 → 1.1.0
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 +5 -5
- data/.travis.yml +7 -4
- data/README.md +19 -2
- data/Rakefile +18 -2
- data/bcrypt_pbkdf.gemspec +6 -7
- data/ext/mri/bcrypt_pbkdf_ext.c +1 -1
- data/ext/mri/sha2.h +3 -3
- data/test/bcrypt_pnkdf/engine_test.rb +9 -11
- metadata +16 -32
- data/Gemfile.lock +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63ac8948f4ecd73d2450a88ffe9c4cba42c00046ac292841be016965eb5834e4
|
4
|
+
data.tar.gz: 34bf1a1d2025f60d29db8dacb052df7264262cd22f5d0b480d0fdafe01fe8f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37d7691812403f03b69d32fe8ad1539fa94368df4cf94b2dce9821b516727c3252f7e26f62f4f08fd3eb60f09e01b5ff734b6484aa86e85d4d80884498dd209a
|
7
|
+
data.tar.gz: 7f4e906f1f7a1b14008b789f23d2e0e3bab121c405051b41fd472193d1c38bd12e132e51177a0e3c84a45e47ecebc4021d3dc878fadfbc17e56a06883ea75e68
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# bcrypt_pbkdf-ruby
|
2
2
|
|
3
|
-
|
3
|
+
bcrypt_pbkdf is a ruby gem implementing bcrypt_pbkdf from OpenBSD. This is currently used by net-ssh to read password encrypted Ed25519 keys.
|
4
4
|
|
5
5
|
[](https://travis-ci.org/mfazekas/bcrypt_pbkdf-ruby)
|
6
6
|
|
@@ -13,3 +13,20 @@ bcrypt_pdkfd is a ruby gem implementing bcrypt_pdkfd from OpenBSD. This is curre
|
|
13
13
|
|
14
14
|
http://www.tedunangst.com/flak/post/bcrypt-pbkdf
|
15
15
|
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/bcrypt_pbkdf.c?rev=1.13&content-type=text/x-cvsweb-markup
|
16
|
+
|
17
|
+
# Building
|
18
|
+
|
19
|
+
For windows cross build make sure you checked out the gem source under the home directory
|
20
|
+
|
21
|
+
```sh
|
22
|
+
gem install rake-compiler-dock
|
23
|
+
```
|
24
|
+
|
25
|
+
```sh
|
26
|
+
bundle exec rake compile
|
27
|
+
bundle exec rake test
|
28
|
+
bundle exec rake clean clobber
|
29
|
+
bundle exec rake gem:windows
|
30
|
+
bundle exec rake release
|
31
|
+
bundle exec rake gem:windows:release
|
32
|
+
```
|
data/Rakefile
CHANGED
@@ -1,14 +1,23 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
require 'rubygems/package_task'
|
3
|
+
require 'bundler/gem_tasks'
|
3
4
|
require 'rake/extensiontask'
|
4
5
|
require 'rake/clean'
|
5
6
|
require 'rdoc/task'
|
6
7
|
require 'benchmark'
|
7
8
|
|
9
|
+
|
8
10
|
CLEAN.include(
|
9
11
|
"tmp",
|
10
12
|
"lib/2.0",
|
11
13
|
"lib/2.1",
|
14
|
+
"lib/2.2",
|
15
|
+
"lib/2.3",
|
16
|
+
"lib/2.4",
|
17
|
+
"lib/2.5",
|
18
|
+
"lib/2.6",
|
19
|
+
"lib/2.7",
|
20
|
+
"lib/3.0",
|
12
21
|
"lib/bcrypt_pbkdf_ext.so"
|
13
22
|
)
|
14
23
|
CLOBBER.include(
|
@@ -18,7 +27,14 @@ CLOBBER.include(
|
|
18
27
|
|
19
28
|
task 'gem:windows' do
|
20
29
|
require 'rake_compiler_dock'
|
21
|
-
|
30
|
+
sh "bundle package" # Avoid repeated downloads of gems by using gem files from the host.
|
31
|
+
RakeCompilerDock.sh "bundle && rake cross native gem RUBY_CC_VERSION=3.0.0:2.7.0:2.6.0:2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0"
|
32
|
+
end
|
33
|
+
|
34
|
+
task 'gem:windows:release' do
|
35
|
+
version = Gem::Specification::load("bcrypt_pbkdf.gemspec").version
|
36
|
+
sh "gem push pkg/bcrypt_pbkdf-#{version}-x86-mingw32.gem"
|
37
|
+
sh "gem push pkg/bcrypt_pbkdf-#{version}-x64-mingw32.gem"
|
22
38
|
end
|
23
39
|
|
24
40
|
GEMSPEC = Gem::Specification.load("bcrypt_pbkdf.gemspec")
|
@@ -27,7 +43,7 @@ task :default => [:compile, :spec]
|
|
27
43
|
|
28
44
|
desc "Run all tests"
|
29
45
|
Rake::TestTask.new do |t|
|
30
|
-
#t.pattern =
|
46
|
+
#t.pattern =
|
31
47
|
t.test_files = FileList['test/**/*_test.rb']
|
32
48
|
t.ruby_opts = ['-w']
|
33
49
|
t.libs << "test"
|
data/bcrypt_pbkdf.gemspec
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'bcrypt_pbkdf'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.1.0'
|
4
4
|
|
5
|
-
s.summary = "OpenBSD's
|
5
|
+
s.summary = "OpenBSD's bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)"
|
6
6
|
s.description = <<-EOF
|
7
|
-
This gem implements
|
7
|
+
This gem implements bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)
|
8
8
|
EOF
|
9
9
|
|
10
10
|
s.files = `git ls-files`.split("\n")
|
11
11
|
s.require_path = 'lib'
|
12
12
|
|
13
|
-
s.add_development_dependency 'rake-compiler', '~>
|
13
|
+
s.add_development_dependency 'rake-compiler', '~> 1.1.0'
|
14
14
|
s.add_development_dependency 'minitest', '>= 5'
|
15
|
-
s.add_development_dependency '
|
16
|
-
s.add_development_dependency 'rbnacl-libsodium', '~> 1.0.8'
|
15
|
+
s.add_development_dependency 'openssl'
|
17
16
|
s.add_development_dependency 'rdoc', '~> 3.12'
|
18
|
-
s.add_development_dependency 'rake-compiler-dock', '~> 0.
|
17
|
+
s.add_development_dependency 'rake-compiler-dock', '~> 1.0.1'
|
19
18
|
|
20
19
|
s.has_rdoc = true
|
21
20
|
s.rdoc_options += ['--title', 'bcrypt_pbkdf', '--line-numbers', '--inline-source', '--main', 'README.md']
|
data/ext/mri/bcrypt_pbkdf_ext.c
CHANGED
@@ -8,7 +8,7 @@ static VALUE cBCryptPbkdfEngine;
|
|
8
8
|
*/
|
9
9
|
static VALUE bc_crypt_pbkdf(VALUE self, VALUE pass, VALUE salt, VALUE keylen, VALUE rounds) {
|
10
10
|
size_t okeylen = NUM2ULONG(keylen);
|
11
|
-
u_int8_t* okey = xmalloc(
|
11
|
+
u_int8_t* okey = xmalloc(okeylen);
|
12
12
|
VALUE out;
|
13
13
|
|
14
14
|
int ret = bcrypt_pbkdf(
|
data/ext/mri/sha2.h
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
#endif
|
8
8
|
#define SHA512_DIGEST_LENGTH crypto_hash_sha512_BYTES
|
9
9
|
|
10
|
-
inline void SHA512Init(SHA2_CTX* ctx) { crypto_hash_sha512_init(ctx); }
|
11
|
-
inline void SHA512Update(SHA2_CTX* ctx, const void *in, size_t inlen) { crypto_hash_sha512_update(ctx, in, inlen); }
|
12
|
-
inline void SHA512Final(uint8_t* out, SHA2_CTX* ctx) { crypto_hash_sha512_final(ctx, out); }
|
10
|
+
inline static void SHA512Init(SHA2_CTX* ctx) { crypto_hash_sha512_init(ctx); }
|
11
|
+
inline static void SHA512Update(SHA2_CTX* ctx, const void *in, size_t inlen) { crypto_hash_sha512_update(ctx, in, inlen); }
|
12
|
+
inline static void SHA512Final(uint8_t* out, SHA2_CTX* ctx) { crypto_hash_sha512_final(ctx, out); }
|
13
13
|
|
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
|
-
# bcrypt_pbkdf in ruby
|
5
|
-
require '
|
6
|
-
require 'rbnacl'
|
7
|
-
require 'rbnacl/hash'
|
4
|
+
# bcrypt_pbkdf in ruby
|
5
|
+
require 'openssl'
|
8
6
|
|
9
7
|
BCRYPT_BLOCKS = 8
|
10
8
|
BCRYPT_HASHSIZE = BCRYPT_BLOCKS * 4
|
@@ -13,7 +11,7 @@ def bcrypt_pbkdf(password, salt, keylen, rounds)
|
|
13
11
|
stride = (keylen + BCRYPT_HASHSIZE - 1) / BCRYPT_HASHSIZE
|
14
12
|
amt = (keylen + stride - 1) / stride
|
15
13
|
|
16
|
-
sha2pass =
|
14
|
+
sha2pass = OpenSSL::Digest::SHA512.new(password).digest
|
17
15
|
#puts "[RB] sha2pass:#{sha2pass.inspect} #{sha2pass.size}"
|
18
16
|
|
19
17
|
remlen = keylen
|
@@ -32,13 +30,13 @@ def bcrypt_pbkdf(password, salt, keylen, rounds)
|
|
32
30
|
countsalt[saltlen + 3] = (count & 0xff).chr
|
33
31
|
#puts "[RC] countsalt: #{countsalt.inspect} len:#{countsalt.size}"
|
34
32
|
|
35
|
-
sha2salt =
|
33
|
+
sha2salt = OpenSSL::Digest::SHA512.new(countsalt).digest
|
36
34
|
tmpout = BCryptPbkdf::Engine::__bc_crypt_hash(sha2pass, sha2salt)
|
37
35
|
out = tmpout.clone
|
38
36
|
|
39
37
|
#puts "[RB] out: #{out.inspect} keylen:#{remlen} count:#{count}"
|
40
38
|
(1...rounds).each do |i|
|
41
|
-
sha2salt =
|
39
|
+
sha2salt = OpenSSL::Digest::SHA512.new(tmpout).digest
|
42
40
|
tmpout = BCryptPbkdf::Engine::__bc_crypt_hash(sha2pass, sha2salt)
|
43
41
|
out.bytes.each_with_index {|o,j| out.setbyte(j,o ^ tmpout[j].ord) }
|
44
42
|
end
|
@@ -48,7 +46,7 @@ def bcrypt_pbkdf(password, salt, keylen, rounds)
|
|
48
46
|
dest = i * stride + (count -1)
|
49
47
|
key[dest] = out[i] if (dest < keylen)
|
50
48
|
end
|
51
|
-
|
49
|
+
|
52
50
|
remlen -= amt
|
53
51
|
count += 1
|
54
52
|
end
|
@@ -66,13 +64,13 @@ class TestExt < MiniTest::Unit::TestCase
|
|
66
64
|
assert_equal bcrypt_pbkdf(p,s,l,r), BCryptPbkdf::key(p,s,l,r)
|
67
65
|
end
|
68
66
|
end
|
69
|
-
|
67
|
+
|
70
68
|
|
71
69
|
def table
|
72
70
|
[
|
73
|
-
["pass2", "salt2", 12, 2, [214, 14, 48, 162, 131, 206, 121, 176, 50, 104, 231, 252]],
|
71
|
+
["pass2", "salt2", 12, 2, [214, 14, 48, 162, 131, 206, 121, 176, 50, 104, 231, 252]],
|
74
72
|
["\u0000\u0001foo", "\u0001\u0002fooo3", 14, 5, [46, 189, 32, 185, 94, 85, 232, 10, 84, 26, 44, 161, 49, 126]],
|
75
73
|
["doozoasd", "fooo$AS!", 14, 22, [57, 62, 50, 107, 70, 155, 65, 5, 129, 211, 189, 169, 188, 65]]
|
76
74
|
]
|
77
75
|
end
|
78
|
-
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcrypt_pbkdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miklos Fazekas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.1.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,33 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: openssl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.3'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.3'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rbnacl-libsodium
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
47
|
+
version: '0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
54
|
+
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rdoc
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,15 +72,15 @@ dependencies:
|
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
75
|
+
version: 1.0.1
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
97
|
-
description: " This gem implements
|
82
|
+
version: 1.0.1
|
83
|
+
description: " This gem implements bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based
|
98
84
|
PRF)\n"
|
99
85
|
email: mfazekas@szemafor.com
|
100
86
|
executables: []
|
@@ -110,7 +96,6 @@ files:
|
|
110
96
|
- CHANGELOG.md
|
111
97
|
- COPYING
|
112
98
|
- Gemfile
|
113
|
-
- Gemfile.lock
|
114
99
|
- README.md
|
115
100
|
- Rakefile
|
116
101
|
- bcrypt_pbkdf.gemspec
|
@@ -151,13 +136,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
136
|
version: '0'
|
152
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
138
|
requirements:
|
154
|
-
- - "
|
139
|
+
- - ">="
|
155
140
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
141
|
+
version: '0'
|
157
142
|
requirements: []
|
158
|
-
|
159
|
-
rubygems_version: 2.5.2.3
|
143
|
+
rubygems_version: 3.0.3
|
160
144
|
signing_key:
|
161
145
|
specification_version: 4
|
162
|
-
summary: OpenBSD's
|
146
|
+
summary: OpenBSD's bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)
|
163
147
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bcrypt_pbkdf (1.0.1.rc1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ffi (1.9.10)
|
10
|
-
json (1.8.3)
|
11
|
-
minitest (5.8.3)
|
12
|
-
rake (11.1.1)
|
13
|
-
rake-compiler (0.9.7)
|
14
|
-
rake
|
15
|
-
rake-compiler-dock (0.5.3)
|
16
|
-
rbnacl (3.3.0)
|
17
|
-
ffi
|
18
|
-
rbnacl-libsodium (1.0.8)
|
19
|
-
rbnacl (~> 3.0, >= 3.0.1)
|
20
|
-
rdoc (3.12.2)
|
21
|
-
json (~> 1.4)
|
22
|
-
|
23
|
-
PLATFORMS
|
24
|
-
ruby
|
25
|
-
|
26
|
-
DEPENDENCIES
|
27
|
-
bcrypt_pbkdf!
|
28
|
-
minitest (>= 5)
|
29
|
-
rake-compiler (~> 0.9.7)
|
30
|
-
rake-compiler-dock (~> 0.5.3)
|
31
|
-
rbnacl (~> 3.3)
|
32
|
-
rbnacl-libsodium (~> 1.0.8)
|
33
|
-
rdoc (~> 3.12)
|
34
|
-
|
35
|
-
BUNDLED WITH
|
36
|
-
1.17.1
|