bcrypt_pbkdf 1.2.0.beta1-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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 816bab3086720b43cba29bca47b1dcb3c999d9361e39c31127b10103c48e64bd
4
+ data.tar.gz: e4ca3184a544e3ea87e4a286f263313db30821464a664f4c539db3299ce60bbd
5
+ SHA512:
6
+ metadata.gz: 97550f0668367f030911cd45a069edc57f9221fe6a7192d28ea1daf4388835cfc1ed02bb1a8c17ce31fe53ebe09d381913c359825846995ef3324469c47ba000
7
+ data.tar.gz: a7131dc172fe4f8be5d153899a74c6c4885a51f18f865e3f9f4e11a4433057d7e1cc4ebeb67d5aa76c57313769096b08aef0ccada6c072edb996e998cde09ee9
@@ -0,0 +1,75 @@
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.4, 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.4, 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
49
+
50
+ jruby:
51
+ name: ubuntu-latest ruby jruby
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@v4
55
+ - uses: ruby/setup-ruby@v1
56
+ with:
57
+ ruby-version: jruby
58
+ bundler-cache: true
59
+ - run: bundle exec rake compile:java
60
+ - run: bundle exec rake test
61
+
62
+ memcheck:
63
+ name: Memory leak check (valgrind)
64
+ runs-on: ubuntu-latest
65
+ env:
66
+ BUNDLE_GEMFILE: Gemfile.memcheck
67
+ steps:
68
+ - uses: actions/checkout@v4
69
+ - uses: ruby/setup-ruby@v1
70
+ with:
71
+ ruby-version: '3.3'
72
+ bundler-cache: true
73
+ - run: sudo apt-get install -y valgrind
74
+ - run: bundle exec rake compile
75
+ - run: bundle exec rake memcheck
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ lib/*.jar
2
+ lib/*.so
3
+ pkg/
4
+ tmp/
5
+ Gemfile.lock
6
+ .bundle/
data/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # 1.2.0.beta1
2
+
3
+ * JRuby support: native Java extension (`-java` gem variant) [#30]
4
+ * Fix: missing salt size cap guard (`saltlen > 1<<20`) in Java implementation to match C behavior [#30]
5
+ * Fix: memory leak on error state in C extension [#34]
6
+ * Sync `bcrypt_pbkdf.c` (v1.13→v1.17) and `blowfish.c` (v1.19→v1.20) from OpenBSD [#36]
7
+ * Sync `blf.h` to OpenBSD v1.8, drop advertising clause [#38]
8
+ * Fix compatibility with minitest 6 [#28]
9
+
10
+ # 1.1.2
11
+
12
+ * Add Ruby 3.4 support [#26]
13
+
14
+ # 1.1.1
15
+
16
+ * Fix cross-compile and native gem publishing [#22]
17
+ * Fix compile on Windows (missing bzero)
18
+ * Replace Travis CI with GitHub Actions
19
+ * Minitest 5.19 compatibility [#21]
20
+
21
+ # 1.1.0
22
+
23
+ * Ruby 3.0 support
24
+ * Support rubies 2.0–2.7 in Windows cross-compile
25
+ * Fix inline static function declarations [#15]
26
+ * Add Linux on Power (ppc64) support [#11]
27
+ * Use size_t for xmalloc [#7]
28
+ * Fix gem summary typo [#9]
29
+
30
+ # 1.0.1
31
+
32
+ * Fix compile on Solarish platforms [#3]
33
+ * Drop rbnacl test dependency, use native OpenSSL instead [#6]
34
+ * Fix spelling in source [#2]
35
+
36
+ # 1.0.0
37
+
38
+ * Initial release
data/COPYING ADDED
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright 2007-2016: Miklós Fazekas <mfazekas@szemafor.com>
4
+ C implementation of bcrypt_pbkdf: OpenBSD: Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.memcheck ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'ruby_memcheck'
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # bcrypt_pbkdf-ruby
2
+
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
+
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
+
7
+ ## Acknowledgements
8
+
9
+ * The gut of the code is based on OpenBSD's bcrypt_pbkdf.c implementation
10
+ * Some ideas/code were taken adopted bcrypt-ruby: https://github.com/codahale/bcrypt-ruby
11
+
12
+ ## Upstream sources
13
+
14
+ The C sources are synced from openssh-portable, which tracks OpenBSD CVS:
15
+
16
+ | File | OpenBSD version |
17
+ |------|----------------|
18
+ | `ext/mri/bcrypt_pbkdf.c` | [v1.17](https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/bcrypt_pbkdf.c?rev=1.17) |
19
+ | `ext/mri/blowfish.c` | [v1.20](https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libcrypto/blowfish.c?rev=1.20) |
20
+ | `ext/mri/blf.h` | [v1.8](https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libcrypto/blf.h?rev=1.8) |
21
+
22
+ ## Links
23
+
24
+ * http://www.tedunangst.com/flak/post/bcrypt-pbkdf
25
+
26
+ ## Building
27
+
28
+ For windows and osx cross build make sure you checked out the gem source under the home directory and have docker installed.
29
+
30
+ ```sh
31
+ gem install rake-compiler-dock
32
+ ```
33
+
34
+ ```sh
35
+ bundle exec rake compile
36
+ bundle exec rake test
37
+ bundle exec rake clean clobber
38
+ bundle exec rake gem:all
39
+ bundle exec rake release
40
+ bundle exec rake gem:release
41
+ ```
data/Rakefile ADDED
@@ -0,0 +1,208 @@
1
+ require 'rake/testtask'
2
+ require 'rubygems/package_task'
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/extensiontask'
5
+ begin
6
+ require 'rake/javaextensiontask'
7
+ rescue LoadError
8
+ end
9
+ require 'rake/clean'
10
+ require 'rdoc/task'
11
+ require 'benchmark'
12
+ require 'rake_compiler_dock'
13
+
14
+ begin
15
+ require 'ruby_memcheck'
16
+ RubyMemcheck::TestTask.new(memcheck: :compile) do |t|
17
+ t.libs << 'test'
18
+ t.test_files = FileList['test/**/*_test.rb']
19
+ end
20
+ rescue LoadError
21
+ end
22
+
23
+ CLEAN.add("{ext,lib}/**/*.{o,so}", "pkg")
24
+ CLEAN.add("{ext,lib}/**/*.{jar,class}")
25
+
26
+ cross_rubies = ["3.4.0", "3.3.0", "3.2.0", "3.1.0", "3.0.0", "2.7.0"]
27
+ cross_platforms = [
28
+ "arm64-darwin",
29
+ "x64-mingw-ucrt",
30
+ "x64-mingw32",
31
+ "x86-mingw32",
32
+ "x86_64-darwin",
33
+ ]
34
+ ENV["RUBY_CC_VERSION"] = cross_rubies.join(":")
35
+
36
+ GEMSPEC = Gem::Specification.load("bcrypt_pbkdf.gemspec")
37
+
38
+ task :default => [:compile, :spec]
39
+
40
+ desc "Run all tests"
41
+ Rake::TestTask.new do |t|
42
+ #t.pattern =
43
+ t.test_files = FileList['test/**/*_test.rb']
44
+ t.ruby_opts = ['-w']
45
+ t.libs << "test"
46
+ t.verbose = true
47
+ end
48
+ task :spec => :test
49
+
50
+ desc 'Generate RDoc'
51
+ RDoc::Task.new do |rdoc|
52
+ rdoc.rdoc_dir = 'doc/rdoc'
53
+ rdoc.options += GEMSPEC.rdoc_options
54
+ rdoc.template = ENV['TEMPLATE'] if ENV['TEMPLATE']
55
+ rdoc.rdoc_files.include(*GEMSPEC.extra_rdoc_files)
56
+ end
57
+
58
+ unless RUBY_PLATFORM == 'java'
59
+ Rake::ExtensionTask.new("bcrypt_pbkdf_ext", GEMSPEC) do |ext|
60
+ ext.ext_dir = 'ext/mri'
61
+ ext.cross_compile = true
62
+ ext.cross_platform = cross_platforms
63
+ ext.cross_config_options << "--enable-cross-build" # so extconf.rb knows we're cross-compiling
64
+ end
65
+ end
66
+
67
+ if defined?(Rake::JavaExtensionTask)
68
+ Rake::JavaExtensionTask.new("bcrypt_pbkdf_ext", GEMSPEC) do |ext|
69
+ ext.ext_dir = 'ext/jruby'
70
+ ext.source_pattern = '**/*.java'
71
+ ext.source_version = '8'
72
+ ext.target_version = '8'
73
+ ext.lint_option = '-options'
74
+ end
75
+ end
76
+
77
+ namespace "gem" do
78
+ cross_platforms.each do |platform|
79
+ desc "build native gem for #{platform}"
80
+ task platform do
81
+ RakeCompilerDock.sh(<<~EOF, platform: platform, verbose: true)
82
+ gem install bundler --no-document &&
83
+ BUNDLE_IGNORE_CONFIG=1 BUNDLE_PATH=.bundle/#{platform} bundle &&
84
+ BUNDLE_IGNORE_CONFIG=1 BUNDLE_PATH=.bundle/#{platform} bundle exec rake gem:#{platform}:buildit
85
+ EOF
86
+ end
87
+
88
+ namespace platform do
89
+ # this runs in the rake-compiler-dock docker container
90
+ task "buildit" do
91
+ # use Task#invoke because the pkg/*gem task is defined at runtime
92
+ Rake::Task["native:#{platform}"].invoke
93
+ Rake::Task["pkg/#{GEMSPEC.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
94
+ end
95
+
96
+ task "release" do
97
+ sh "gem push pkg/#{GEMSPEC.full_name}-#{Gem::Platform.new(platform)}.gem"
98
+ end
99
+ end
100
+ end
101
+
102
+ desc "build java gem for JRuby"
103
+ task "java" do
104
+ Rake::Task["java:#{GEMSPEC.name}"].invoke
105
+ Rake::Task["pkg/#{GEMSPEC.full_name}-java.gem"].invoke
106
+ end
107
+
108
+ namespace "java" do
109
+ task "release" do
110
+ sh "gem push pkg/#{GEMSPEC.full_name}-java.gem"
111
+ end
112
+ end
113
+
114
+ desc "build native gem for all platforms"
115
+ task "all" do
116
+ cross_platforms.each do |platform|
117
+ Rake::Task["gem:#{platform}"].invoke
118
+ end
119
+ Rake::Task["gem:java"].invoke if defined?(Rake::JavaExtensionTask) && ENV['JRUBY_HOME']
120
+ end
121
+
122
+ desc "release native gem for all platforms"
123
+ task "release" do
124
+ cross_platforms.each do |platform|
125
+ Rake::Task["gem:#{platform}:release"].invoke
126
+ end
127
+ Rake::Task["gem:java:release"].invoke if File.exist?("pkg/#{GEMSPEC.full_name}-java.gem")
128
+ end
129
+ end
130
+
131
+ def change_version(&block)
132
+ version = GEMSPEC.version
133
+ version_file = 'bcrypt_pbkdf.gemspec'
134
+ raise "No version found" if version.nil?
135
+ final = version.segments.take_while{ |i| i.is_a?(Integer) }.to_a
136
+ pre = version.segments.drop_while{ |i| i.is_a?(Integer) }.to_a.join("")
137
+ pre = nil if pre.empty?
138
+ tiny = final.last
139
+ result = block[pre: pre, tiny: tiny]
140
+ raise ArgumentError, "Version change logic should always return a pre" unless result.key?(:pre)
141
+
142
+ puts "result: #{result.inspect}"
143
+
144
+ new_pre = result[:pre] || []
145
+ new_tiny = result[:tiny] || tiny
146
+ final[-1] = new_tiny
147
+ new_version = Gem::Version.new([final, *new_pre].join("."))
148
+
149
+ found = false
150
+ File.open("#{version_file}.new", "w") do |f|
151
+ File.readlines(version_file).each do |line|
152
+ match = /^(\s+s\.version\s*=\s*\')[\d[a-z]\.]+(\'\s*)$/.match(line)
153
+ if match
154
+ prefix = match[1]
155
+ postfix = match[2]
156
+ new_line = "#{prefix}#{new_version.to_s}#{postfix}"
157
+ puts "Changing:\n - #{line} + #{new_line}"
158
+ line = new_line
159
+ found = true
160
+ end
161
+ f.write(line)
162
+ end
163
+ raise ArgumentError, "Cound not find version line in #{version_file}" unless found
164
+ end
165
+
166
+ FileUtils.mv version_file, "#{version_file}.old"
167
+ FileUtils.mv "#{version_file}.new", version_file
168
+ FileUtils.rm_f "#{version_file}.old"
169
+ end
170
+
171
+ namespace :vbump do
172
+ desc "Final release"
173
+ task :final do
174
+ change_version do |pre:, tiny:|
175
+ _ = tiny
176
+ if pre.nil?
177
+ { tiny: tiny + 1, pre: nil }
178
+ else
179
+ raise ArgumentError, "Unexpected pre: #{pre}" if pre.nil?
180
+
181
+ { pre: nil }
182
+ end
183
+ end
184
+ end
185
+
186
+ desc "Increment prerelease"
187
+ task :pre, [:type] do |_t, args|
188
+ change_version do |pre:, tiny:|
189
+ puts " PRE => #{pre.inspect}"
190
+ match = /^([a-z]+)(\d+)/.match(pre)
191
+ raise ArgumentError, "Unexpected pre: #{pre}" if match.nil? && args[:type].nil?
192
+
193
+ if match.nil? || (!args[:type].nil? && args[:type] != match[1])
194
+ if pre.nil?
195
+ { pre: "#{args[:type]}1", tiny: tiny + 1 }
196
+ else
197
+ { pre: "#{args[:type]}1" }
198
+ end
199
+ else
200
+ { pre: "#{match[1]}#{match[2].to_i + 1}" }
201
+ end
202
+ end
203
+ end
204
+ end
205
+
206
+ task "package" => cross_platforms.map { |p| "gem:#{p}" } # "package" task for all the native platforms
207
+
208
+ Rake::Task["package"].prerequisites.prepend("compile")
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'bcrypt_pbkdf'
3
+ s.version = '1.2.0.beta1'
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
+ s.add_development_dependency 'benchmark', '~> 0.4.0'
19
+
20
+ s.rdoc_options += ['--title', 'bcrypt_pbkdf', '--line-numbers', '--inline-source', '--main', 'README.md']
21
+ s.extra_rdoc_files += ['README.md', 'COPYING', 'CHANGELOG.md', *Dir['lib/**/*.rb']]
22
+
23
+ s.extensions = 'ext/mri/extconf.rb'
24
+
25
+ s.authors = ["Miklos Fazekas"]
26
+ s.email = "mfazekas@szemafor.com"
27
+ s.homepage = "https://github.com/net-ssh/bcrypt_pbkdf-ruby"
28
+ s.license = "MIT"
29
+ end