bcrypt_pbkdf 1.1.0 → 1.1.1.rc1

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: 63ac8948f4ecd73d2450a88ffe9c4cba42c00046ac292841be016965eb5834e4
4
- data.tar.gz: 34bf1a1d2025f60d29db8dacb052df7264262cd22f5d0b480d0fdafe01fe8f8c
3
+ metadata.gz: 4ec6b50cfebe275e49c1b0f875a16ad148dcb1a15fdcee360165a9d10f523f85
4
+ data.tar.gz: a0a846cc4e184bb37472c69adfa3166e1e8ff990abcd0d5acabcb0670b56e73f
5
5
  SHA512:
6
- metadata.gz: 37d7691812403f03b69d32fe8ad1539fa94368df4cf94b2dce9821b516727c3252f7e26f62f4f08fd3eb60f09e01b5ff734b6484aa86e85d4d80884498dd209a
7
- data.tar.gz: 7f4e906f1f7a1b14008b789f23d2e0e3bab121c405051b41fd472193d1c38bd12e132e51177a0e3c84a45e47ecebc4021d3dc878fadfbc17e56a06883ea75e68
6
+ metadata.gz: 7df599d579f73f242f55431839a963885941f719d4c57b5fc23e0dbe50ae5ba73950337eb8c5b4b8a0858edba21fe48e1d64511f31f6ee44e2a5aa681b2e30de
7
+ data.tar.gz: ae682efebfc496e05c33efd975fa463c21b4904101f28f59260cf90e7d1460e2776ae7fc4650c784418d2b967cae9a565abe589a26709160fd3090ea88edca4c
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: ci
3
+
4
+ on:
5
+ pull_request:
6
+ branches: [ main ]
7
+ push:
8
+ branches: [ main ]
9
+ workflow_dispatch:
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ windows:
17
+ name: ${{ matrix.os }} ruby ${{ matrix.ruby }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [2.7, 3.3, head, mingw, mswin, ucrt]
22
+ os: [windows-latest]
23
+ runs-on: ${{ matrix.os }}
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+ - run: bundle exec rake compile
31
+ - run: bundle exec rake test
32
+
33
+ unix:
34
+ name: ${{ matrix.os }} ruby ${{ matrix.ruby }}
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ ruby: [2.7, 3.3, head]
39
+ os: [ubuntu-latest, macos-latest]
40
+ runs-on: ${{ matrix.os }}
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ - uses: ruby/setup-ruby@v1
44
+ with:
45
+ ruby-version: ${{ matrix.ruby }}
46
+ bundler-cache: true
47
+ - run: bundle exec rake compile
48
+ - run: bundle exec rake test
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ lib/
2
+ pkg/
3
+ tmp/
4
+ Gemfile.lock
5
+ .bundle/
data/README.md CHANGED
@@ -2,21 +2,21 @@
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
- [![Build Status](https://travis-ci.org/mfazekas/bcrypt_pbkdf-ruby.png?branch=master)](https://travis-ci.org/mfazekas/bcrypt_pbkdf-ruby)
5
+ [![Build Status](https://github.com/net-ssh/bcrypt_pbkdf-ruby/actions/workflows/ci.yml/badge.svg?branch=master&event=push)](https://github.com/net-ssh/bcrypt_pbkdf-ruby/actions/workflows/ci.yml)
6
6
 
7
- # Acknowledgements
7
+ ## Acknowledgements
8
8
 
9
9
  * The gut of the code is based on OpenBSD's bcrypt_pbkdf.c implementation
10
10
  * Some ideas/code were taken adopted bcrypt-ruby: https://github.com/codahale/bcrypt-ruby
11
11
 
12
- # Links:
12
+ ## Links
13
13
 
14
- http://www.tedunangst.com/flak/post/bcrypt-pbkdf
15
- http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/bcrypt_pbkdf.c?rev=1.13&content-type=text/x-cvsweb-markup
14
+ * http://www.tedunangst.com/flak/post/bcrypt-pbkdf
15
+ * http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/bcrypt_pbkdf.c?rev=1.13&content-type=text/x-cvsweb-markup
16
16
 
17
- # Building
17
+ ## Building
18
18
 
19
- For windows cross build make sure you checked out the gem source under the home directory
19
+ For windows and osx cross build make sure you checked out the gem source under the home directory and have docker installed.
20
20
 
21
21
  ```sh
22
22
  gem install rake-compiler-dock
@@ -26,7 +26,7 @@ gem install rake-compiler-dock
26
26
  bundle exec rake compile
27
27
  bundle exec rake test
28
28
  bundle exec rake clean clobber
29
- bundle exec rake gem:windows
29
+ bundle exec rake gem:all
30
30
  bundle exec rake release
31
- bundle exec rake gem:windows:release
31
+ bundle exec rake gem:release
32
32
  ```
data/Rakefile CHANGED
@@ -5,37 +5,19 @@ require 'rake/extensiontask'
5
5
  require 'rake/clean'
6
6
  require 'rdoc/task'
7
7
  require 'benchmark'
8
+ require 'rake_compiler_dock'
8
9
 
10
+ CLEAN.add("{ext,lib}/**/*.{o,so}", "pkg")
9
11
 
10
- CLEAN.include(
11
- "tmp",
12
- "lib/2.0",
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",
21
- "lib/bcrypt_pbkdf_ext.so"
22
- )
23
- CLOBBER.include(
24
- "doc",
25
- "pkg"
26
- )
27
-
28
- task 'gem:windows' do
29
- require 'rake_compiler_dock'
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"
38
- end
12
+ cross_rubies = ["3.3.0", "3.2.0", "3.1.0", "3.0.0", "2.7.0"]
13
+ cross_platforms = [
14
+ "arm64-darwin",
15
+ "x64-mingw-ucrt",
16
+ "x64-mingw32",
17
+ "x86-mingw32",
18
+ "x86_64-darwin",
19
+ ]
20
+ ENV["RUBY_CC_VERSION"] = cross_rubies.join(":")
39
21
 
40
22
  GEMSPEC = Gem::Specification.load("bcrypt_pbkdf.gemspec")
41
23
 
@@ -59,13 +41,128 @@ RDoc::Task.new do |rdoc|
59
41
  rdoc.rdoc_files.include(*GEMSPEC.extra_rdoc_files)
60
42
  end
61
43
 
62
- Gem::PackageTask.new(GEMSPEC) do |pkg|
63
- pkg.need_zip = true
64
- pkg.need_tar = true
65
- end
66
-
67
44
  Rake::ExtensionTask.new("bcrypt_pbkdf_ext", GEMSPEC) do |ext|
68
45
  ext.ext_dir = 'ext/mri'
69
46
  ext.cross_compile = true
70
- ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
47
+ ext.cross_platform = cross_platforms
48
+ ext.cross_config_options << "--enable-cross-build" # so extconf.rb knows we're cross-compiling
49
+ end
50
+
51
+ namespace "gem" do
52
+ cross_platforms.each do |platform|
53
+ desc "build native gem for #{platform}"
54
+ task platform do
55
+ RakeCompilerDock.sh(<<~EOF, platform: platform, verbose: true)
56
+ gem install bundler --no-document &&
57
+ BUNDLE_IGNORE_CONFIG=1 BUNDLE_PATH=.bundle/#{platform} bundle &&
58
+ BUNDLE_IGNORE_CONFIG=1 BUNDLE_PATH=.bundle/#{platform} bundle exec rake gem:#{platform}:buildit
59
+ EOF
60
+ end
61
+
62
+ namespace platform do
63
+ # this runs in the rake-compiler-dock docker container
64
+ task "buildit" do
65
+ # use Task#invoke because the pkg/*gem task is defined at runtime
66
+ Rake::Task["native:#{platform}"].invoke
67
+ Rake::Task["pkg/#{GEMSPEC.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
68
+ end
69
+
70
+ task "release" do
71
+ sh "gem push pkg/#{GEMSPEC.full_name}-#{Gem::Platform.new(platform)}.gem"
72
+ end
73
+ end
74
+ end
75
+
76
+ desc "build native gem for all platforms"
77
+ task "all" do
78
+ cross_platforms.each do |platform|
79
+ Rake::Task["gem:#{platform}"].invoke
80
+ end
81
+ end
82
+
83
+ desc "release native gem for all platforms"
84
+ task "release" do
85
+ cross_platforms.each do |platform|
86
+ Rake::Task["gem:#{platform}:release"].invoke
87
+ end
88
+ end
89
+ end
90
+
91
+ def change_version(&block)
92
+ version = GEMSPEC.version
93
+ version_file = 'bcrypt_pbkdf.gemspec'
94
+ raise "No version found" if version.nil?
95
+ final = version.segments.take_while{ |i| i.is_a?(Integer) }.to_a
96
+ pre = version.segments.drop_while{ |i| i.is_a?(Integer) }.to_a.join("")
97
+ pre = nil if pre.empty?
98
+ tiny = final.last
99
+ result = block[pre: pre, tiny: tiny]
100
+ raise ArgumentError, "Version change logic should always return a pre" unless result.key?(:pre)
101
+
102
+ puts "result: #{result.inspect}"
103
+
104
+ new_pre = result[:pre] || []
105
+ new_tiny = result[:tiny] || tiny
106
+ final[-1] = new_tiny
107
+ new_version = Gem::Version.new([final, *new_pre].join("."))
108
+
109
+ found = false
110
+ File.open("#{version_file}.new", "w") do |f|
111
+ File.readlines(version_file).each do |line|
112
+ match = /^(\s+s\.version\s*=\s*\')[\d[a-z]\.]+(\'\s*)$/.match(line)
113
+ if match
114
+ prefix = match[1]
115
+ postfix = match[2]
116
+ new_line = "#{prefix}#{new_version.to_s}#{postfix}"
117
+ puts "Changing:\n - #{line} + #{new_line}"
118
+ line = new_line
119
+ found = true
120
+ end
121
+ f.write(line)
122
+ end
123
+ raise ArgumentError, "Cound not find version line in #{version_file}" unless found
124
+ end
125
+
126
+ FileUtils.mv version_file, "#{version_file}.old"
127
+ FileUtils.mv "#{version_file}.new", version_file
128
+ FileUtils.rm_f "#{version_file}.old"
129
+ end
130
+
131
+ namespace :vbump do
132
+ desc "Final release"
133
+ task :final do
134
+ change_version do |pre:, tiny:|
135
+ _ = tiny
136
+ if pre.nil?
137
+ { tiny: tiny + 1, pre: nil }
138
+ else
139
+ raise ArgumentError, "Unexpected pre: #{pre}" if pre.nil?
140
+
141
+ { pre: nil }
142
+ end
143
+ end
144
+ end
145
+
146
+ desc "Increment prerelease"
147
+ task :pre, [:type] do |_t, args|
148
+ change_version do |pre:, tiny:|
149
+ puts " PRE => #{pre.inspect}"
150
+ match = /^([a-z]+)(\d+)/.match(pre)
151
+ raise ArgumentError, "Unexpected pre: #{pre}" if match.nil? && args[:type].nil?
152
+
153
+ if match.nil? || (!args[:type].nil? && args[:type] != match[1])
154
+ if pre.nil?
155
+ { pre: "#{args[:type]}1", tiny: tiny + 1 }
156
+ else
157
+ { pre: "#{args[:type]}1" }
158
+ end
159
+ else
160
+ { pre: "#{match[1]}#{match[2].to_i + 1}" }
161
+ end
162
+ end
163
+ end
71
164
  end
165
+
166
+ task "package" => cross_platforms.map { |p| "gem:#{p}" } # "package" task for all the native platforms
167
+
168
+ Rake::Task["package"].prerequisites.prepend("compile")
data/bcrypt_pbkdf.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bcrypt_pbkdf'
3
- s.version = '1.1.0'
3
+ s.version = '1.1.1.rc1'
4
4
 
5
5
  s.summary = "OpenBSD's bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)"
6
6
  s.description = <<-EOF
@@ -10,13 +10,12 @@ Gem::Specification.new do |s|
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.require_path = 'lib'
12
12
 
13
- s.add_development_dependency 'rake-compiler', '~> 1.1.0'
14
- s.add_development_dependency 'minitest', '>= 5'
15
- s.add_development_dependency 'openssl'
16
- s.add_development_dependency 'rdoc', '~> 3.12'
17
- s.add_development_dependency 'rake-compiler-dock', '~> 1.0.1'
13
+ s.add_development_dependency 'rake-compiler', '~> 1.2.5'
14
+ s.add_development_dependency 'minitest', '~> 5'
15
+ s.add_development_dependency 'openssl', '~> 3'
16
+ s.add_development_dependency 'rdoc', '~> 6'
17
+ s.add_development_dependency 'rake-compiler-dock', '~> 1.5.0'
18
18
 
19
- s.has_rdoc = true
20
19
  s.rdoc_options += ['--title', 'bcrypt_pbkdf', '--line-numbers', '--inline-source', '--main', 'README.md']
21
20
  s.extra_rdoc_files += ['README.md', 'COPYING', 'CHANGELOG.md', *Dir['lib/**/*.rb']]
22
21
 
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'bcrypt_pbkdf'
3
+ s.version = '1.1.0'
4
+
5
+ s.summary = "OpenBSD's bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)"
6
+ s.description = <<-EOF
7
+ This gem implements bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)
8
+ EOF
9
+
10
+ s.files = `git ls-files`.split("\n")
11
+ s.require_path = 'lib'
12
+
13
+ s.add_development_dependency 'rake-compiler', '~> 1.2.5'
14
+ s.add_development_dependency 'minitest', '~> 5'
15
+ s.add_development_dependency 'openssl', '~> 3'
16
+ s.add_development_dependency 'rdoc', '~> 6'
17
+ s.add_development_dependency 'rake-compiler-dock', '~> 1.5.0'
18
+
19
+ s.rdoc_options += ['--title', 'bcrypt_pbkdf', '--line-numbers', '--inline-source', '--main', 'README.md']
20
+ s.extra_rdoc_files += ['README.md', 'COPYING', 'CHANGELOG.md', *Dir['lib/**/*.rb']]
21
+
22
+ s.extensions = 'ext/mri/extconf.rb'
23
+
24
+ s.authors = ["Miklos Fazekas"]
25
+ s.email = "mfazekas@szemafor.com"
26
+ s.homepage = "https://github.com/net-ssh/bcrypt_pbkdf-ruby"
27
+ s.license = "MIT"
28
+ end
@@ -15,6 +15,6 @@
15
15
  void
16
16
  explicit_bzero(void *p, size_t n)
17
17
  {
18
- bzero(p, n);
18
+ memset(p, 0, n);
19
19
  }
20
20
  #endif
data/ext/mri/includes.h CHANGED
@@ -4,7 +4,7 @@
4
4
  #include <stdint.h>
5
5
  #include <sys/types.h>
6
6
  #include <stdlib.h>
7
- #include <strings.h>
7
+ #include <string.h>
8
8
 
9
9
  #if defined(_WIN32) || (defined(__sun) && defined(__SVR4))
10
10
 
@@ -1,4 +1,5 @@
1
1
  require 'minitest/autorun'
2
+ require 'minitest/unit'
2
3
  require 'test_helper'
3
4
 
4
5
  # bcrypt_pbkdf in ruby
@@ -43,7 +44,7 @@ def bcrypt_pbkdf(password, salt, keylen, rounds)
43
44
 
44
45
  amt = [amt, remlen].min
45
46
  (0...amt).each do |i|
46
- dest = i * stride + (count -1)
47
+ dest = i * stride + (count - 1)
47
48
  key[dest] = out[i] if (dest < keylen)
48
49
  end
49
50
 
@@ -54,7 +55,7 @@ def bcrypt_pbkdf(password, salt, keylen, rounds)
54
55
  end
55
56
 
56
57
 
57
- class TestExt < MiniTest::Unit::TestCase
58
+ class TestExt < Minitest::Unit::TestCase
58
59
  def test_table
59
60
  assert_equal table, table.map{ |p,s,l,r| [p,s,l,r,BCryptPbkdf::Engine::__bc_crypt_pbkdf(p,s,l,r).bytes] }
60
61
  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.1.0
4
+ version: 1.1.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miklos Fazekas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-31 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -16,70 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 1.2.5
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: 1.1.0
26
+ version: 1.2.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: openssl
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.12'
61
+ version: '6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.12'
68
+ version: '6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake-compiler-dock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.1
75
+ version: 1.5.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.1
82
+ version: 1.5.0
83
83
  description: " This gem implements bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based
84
84
  PRF)\n"
85
85
  email: mfazekas@szemafor.com
@@ -92,13 +92,15 @@ extra_rdoc_files:
92
92
  - CHANGELOG.md
93
93
  - lib/bcrypt_pbkdf.rb
94
94
  files:
95
- - ".travis.yml"
95
+ - ".github/workflows/ci.yml"
96
+ - ".gitignore"
96
97
  - CHANGELOG.md
97
98
  - COPYING
98
99
  - Gemfile
99
100
  - README.md
100
101
  - Rakefile
101
102
  - bcrypt_pbkdf.gemspec
103
+ - bcrypt_pbkdf.gemspec.old
102
104
  - ext/mri/bcrypt_pbkdf.c
103
105
  - ext/mri/bcrypt_pbkdf_ext.c
104
106
  - ext/mri/blf.h
@@ -136,11 +138,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
138
  version: '0'
137
139
  required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  requirements:
139
- - - ">="
141
+ - - ">"
140
142
  - !ruby/object:Gem::Version
141
- version: '0'
143
+ version: 1.3.1
142
144
  requirements: []
143
- rubygems_version: 3.0.3
145
+ rubygems_version: 3.3.3
144
146
  signing_key:
145
147
  specification_version: 4
146
148
  summary: OpenBSD's bcrypt_pbkdf (a variant of PBKDF2 with bcrypt-based PRF)
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- arch:
3
- - amd64
4
- - ppc64le
5
- rvm:
6
- - 2.3.0
7
- - 2.4.0
8
- - 2.5.0
9
- - 2.6.0
10
- - 2.7.0
11
- script: bundle exec rake