putty-key 1.0.1 → 1.1.1
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 +4 -4
- checksums.yaml.gz.sig +2 -1
- data/CHANGES.md +23 -0
- data/Gemfile +10 -5
- data/LICENSE +1 -1
- data/README.md +32 -6
- data/Rakefile +24 -0
- data/lib/putty/key/argon2_params.rb +101 -0
- data/lib/putty/key/error.rb +17 -0
- data/lib/putty/key/libargon2.rb +54 -0
- data/lib/putty/key/openssl.rb +279 -48
- data/lib/putty/key/ppk.rb +482 -104
- data/lib/putty/key/util.rb +10 -10
- data/lib/putty/key/version.rb +1 -1
- data/lib/putty/key.rb +6 -6
- data/putty-key.gemspec +11 -2
- data/test/argon2_params_test.rb +144 -0
- data/test/fixtures/{dss-1024-encrypted.ppk → dss-1024-encrypted-format-2.ppk} +17 -17
- data/test/fixtures/dss-1024-encrypted-format-3.ppk +22 -0
- data/test/fixtures/{dss-1024.ppk → dss-1024-format-2.ppk} +17 -17
- data/test/fixtures/dss-1024-format-3.ppk +17 -0
- data/test/fixtures/{ecdsa-sha2-nistp256-encrypted.ppk → ecdsa-sha2-nistp256-encrypted-format-2.ppk} +10 -10
- data/test/fixtures/ecdsa-sha2-nistp256-encrypted-format-3.ppk +15 -0
- data/test/fixtures/{ecdsa-sha2-nistp256.ppk → ecdsa-sha2-nistp256-format-2.ppk} +10 -10
- data/test/fixtures/ecdsa-sha2-nistp256-format-3.ppk +10 -0
- data/test/fixtures/{ecdsa-sha2-nistp384-encrypted.ppk → ecdsa-sha2-nistp384-encrypted-format-2.ppk} +11 -11
- data/test/fixtures/ecdsa-sha2-nistp384-encrypted-format-3.ppk +16 -0
- data/test/fixtures/{ecdsa-sha2-nistp384.ppk → ecdsa-sha2-nistp384-format-2.ppk} +11 -11
- data/test/fixtures/ecdsa-sha2-nistp384-format-3.ppk +11 -0
- data/test/fixtures/{ecdsa-sha2-nistp521-encrypted.ppk → ecdsa-sha2-nistp521-encrypted-format-2.ppk} +12 -12
- data/test/fixtures/ecdsa-sha2-nistp521-encrypted-format-3.ppk +17 -0
- data/test/fixtures/{ecdsa-sha2-nistp521.ppk → ecdsa-sha2-nistp521-format-2.ppk} +12 -12
- data/test/fixtures/ecdsa-sha2-nistp521-format-3.ppk +12 -0
- data/test/fixtures/{rsa-2048-encrypted.ppk → rsa-2048-encrypted-format-2.ppk} +26 -26
- data/test/fixtures/rsa-2048-encrypted-format-3.ppk +31 -0
- data/test/fixtures/{rsa-2048.ppk → rsa-2048-format-2.ppk} +26 -26
- data/test/fixtures/rsa-2048-format-3.ppk +26 -0
- data/test/fixtures/test-blank-comment.ppk +11 -11
- data/test/fixtures/test-empty-blobs-encrypted.ppk +6 -0
- data/test/fixtures/test-empty-blobs.ppk +6 -0
- data/test/fixtures/{test-encrypted.ppk → test-encrypted-format-2.ppk} +11 -11
- data/test/fixtures/test-encrypted-format-3.ppk +16 -0
- data/test/fixtures/test-encrypted-type-d-format-3.ppk +16 -0
- data/test/fixtures/test-encrypted-type-i-format-3.ppk +16 -0
- data/test/fixtures/{test-unix-line-endings.ppk → test-format-2.ppk} +0 -0
- data/test/fixtures/test-format-3.ppk +11 -0
- data/test/fixtures/test-invalid-argon2-memory-for-libargon2.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-memory-maximum.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-memory.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-parallelism-maximum.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-parallelism.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-passes-maximum.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-passes.ppk +16 -0
- data/test/fixtures/test-invalid-argon2-salt.ppk +16 -0
- data/test/fixtures/test-invalid-blob-lines.ppk +11 -11
- data/test/fixtures/test-invalid-encryption-type.ppk +11 -11
- data/test/fixtures/test-invalid-format-1.ppk +11 -11
- data/test/fixtures/{test-invalid-format-3.ppk → test-invalid-format-4.ppk} +11 -11
- data/test/fixtures/test-invalid-key-derivation.ppk +16 -0
- data/test/fixtures/test-invalid-private-mac.ppk +11 -11
- data/test/fixtures/test-legacy-mac-line-endings.ppk +1 -0
- data/test/fixtures/test-missing-final-line-ending.ppk +11 -0
- data/test/fixtures/test-truncated.ppk +10 -10
- data/test/fixtures/{test.ppk → test-windows-line-endings.ppk} +0 -0
- data/test/openssl_test.rb +243 -53
- data/test/ppk_test.rb +325 -44
- data/test/test_helper.rb +10 -3
- data.tar.gz.sig +0 -0
- metadata +73 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7206dacd7197ee9c1344a8cbf607c72614ab3031241bb72a32648bbe62cd784a
|
4
|
+
data.tar.gz: d2835eaa489968b975a93c7cb89e8d7b1dde7e52dc597cc48b54c2b3d9c59c5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc6d6331bd8e27ebb082a3bee81b71953cc75e7eea0c80cb6aa3577b4f47a22b379683188a800321848aecffd6e5e6ead37fc1691593c717f9a5b189a03f671
|
7
|
+
data.tar.gz: 5e9b7f92503ba1d3ee96089d42fc20f0ab59203c80c6eca9c2e284df67dacf877356ef6a8bbadca8ac569250f9b965b290f5904bfd6885f9f1648e76c0a39dfc
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
����\�5��dk0���i52����¸����ʍj%��aH!j��v���{��{��|8D���#�}���fjYTr����/b�p����7������ě��t�^*ЅDŸ��)� U�*:�́�G���ԥ̔U��"ᖿ���sZ�)�5XsΞ/�#iQ[�K��,��˃���Xt���ڇeE3�����ە
|
2
|
+
�v�1+A����`o��XhȒf6�XQ�����R��� Iҙ�J��&�!á*S
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changes #
|
2
2
|
|
3
|
+
## Version 1.1.1 - 23-Oct-2022 ##
|
4
|
+
|
5
|
+
* Add support for Ruby 3.2.
|
6
|
+
* Add support for OpenSSL 3 (requires either Ruby 3.1+, or version 3.0.0+ of the
|
7
|
+
openssl gem).
|
8
|
+
|
9
|
+
|
10
|
+
## Version 1.1.0 - 24-May-2021 ##
|
11
|
+
|
12
|
+
* Add support for [format 3 .ppk files](https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/ppk3.html)
|
13
|
+
introduced in PuTTY version 0.75. `PuTTY::Key::PPK#save` defaults to saving
|
14
|
+
format 2 files. [libargon2](https://github.com/P-H-C/phc-winner-argon2) is
|
15
|
+
required to load and save encrypted format 3 files.
|
16
|
+
* Write files using LF line endings (Unix) instead of CRLF (Windows) to match
|
17
|
+
PuTTYgen version 0.75 (versions up to 0.74 used CRLF, but are compatible with
|
18
|
+
CRLF and LF).
|
19
|
+
* Support reading files with CR line endings (Classic Mac OS).
|
20
|
+
* Support reading from and writing to `IO`-like streams.
|
21
|
+
* Allow loading and saving files with empty private or public keys.
|
22
|
+
* Fix adding unnecessary padding to the private key on saving when it is an
|
23
|
+
exact multiple of the block size.
|
24
|
+
|
25
|
+
|
3
26
|
## Version 1.0.1 - 26-Dec-2019 ##
|
4
27
|
|
5
28
|
* Fix errors converting DSA and RSA PPK keys to OpenSSL in
|
data/Gemfile
CHANGED
@@ -12,12 +12,17 @@ group :test do
|
|
12
12
|
|
13
13
|
# coveralls is no longer maintained, but supports Ruby < 2.3.
|
14
14
|
# coveralls_reborn is maintained, but requires Ruby >= 2.3.
|
15
|
-
gem 'coveralls', '
|
15
|
+
gem 'coveralls', git: 'https://github.com/philr/coveralls-ruby.git', require: false if RUBY_VERSION < '2.3'
|
16
16
|
gem 'coveralls_reborn', '~> 0.13', require: false if RUBY_VERSION >= '2.3'
|
17
17
|
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# The source version of ffi 1.15.5 is declared as compatible with Ruby >= 2.3.
|
19
|
+
# The binary version of 1.15.5 is declared as compatible with Ruby >= 2.4, so
|
20
|
+
# doesn't get used. The using the source version results in a segmentation
|
21
|
+
# fault during libffi initialization.
|
20
22
|
#
|
21
|
-
#
|
22
|
-
|
23
|
+
# Binaries of 15.5.0 to 15.5.4 are declared as compatible with Ruby >= 2.3,
|
24
|
+
# but don't get used with Bundler 2.3.23 and Ruby 2.3 on Windows.
|
25
|
+
#
|
26
|
+
# Limit to earlier compatible versions.
|
27
|
+
gem 'ffi', '< 1.15.0' if RUBY_VERSION < '2.4' && RUBY_PLATFORM =~ /mingw/
|
23
28
|
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# PuTTY::Key #
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/putty-key) [](https://github.com/philr/putty-key/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush) [](https://coveralls.io/github/philr/putty-key?branch=master)
|
4
4
|
|
5
|
-
PuTTY::Key is a
|
6
|
-
handling reading and writing .ppk files. It includes a
|
7
|
-
OpenSSL library to add support for converting DSA, EC and
|
8
|
-
and from PuTTY private key files. This allows OpenSSH ecdsa,
|
9
|
-
private keys to be converted to and from PuTTY's private key
|
5
|
+
PuTTY::Key is a Ruby implementation of the PuTTY private key (ppk) format
|
6
|
+
(versions 2 and 3), handling reading and writing .ppk files. It includes a
|
7
|
+
refinement to Ruby's OpenSSL library to add support for converting DSA, EC and
|
8
|
+
RSA private keys to and from PuTTY private key files. This allows OpenSSH ecdsa,
|
9
|
+
ssh-dss and ssh-rsa private keys to be converted to and from PuTTY's private key
|
10
|
+
format.
|
10
11
|
|
11
12
|
|
12
13
|
## Installation ##
|
@@ -29,6 +30,22 @@ gem 'putty-key'
|
|
29
30
|
PuTTY::Key is compatible with Ruby MRI 2.1.0+ and JRuby 9.1.0.0+.
|
30
31
|
|
31
32
|
|
33
|
+
## Formats ##
|
34
|
+
|
35
|
+
Format 2 and 3 .ppk files are supported. Format 1 (not supported) was only used
|
36
|
+
briefly early on in the development of the .ppk format and was never included in
|
37
|
+
a PuTTY release. Format 2 is supported by PuTTY version 0.52 onwards. Format 3
|
38
|
+
is supported by PuTTY version 0.75 onwards. By default, `PuTTY::Key::PPK` saves
|
39
|
+
files using format 2. Format 3 can be selected with the `format` parameter.
|
40
|
+
|
41
|
+
[libargon2](https://github.com/P-H-C/phc-winner-argon2) is required to load and
|
42
|
+
save encrypted format 3 files. Binaries are typically available with your OS
|
43
|
+
distribution. For Windows, binaries are available from the
|
44
|
+
[argon2-windows](https://github.com/philr/argon2-windows/releases) repository.
|
45
|
+
Use either Argon2OptDll.dll for CPUs supporting AVX or Argon2RefDll.dll
|
46
|
+
otherwise.
|
47
|
+
|
48
|
+
|
32
49
|
## Usage ##
|
33
50
|
|
34
51
|
To use PuTTY::Key, it must first be loaded with:
|
@@ -68,6 +85,9 @@ ppk.comment = 'Optional comment'
|
|
68
85
|
ppk.save('key.ppk')
|
69
86
|
```
|
70
87
|
|
88
|
+
Use `ppk.save('key.ppk', format: 3)` to save a format 3 file instead of
|
89
|
+
format 2.
|
90
|
+
|
71
91
|
|
72
92
|
### Generating a new RSA key and saving it as an encrypted .ppk file ###
|
73
93
|
|
@@ -82,6 +102,9 @@ ppk.comment = 'RSA 2048'
|
|
82
102
|
ppk.save('rsa.ppk', 'Passphrase for encryption')
|
83
103
|
```
|
84
104
|
|
105
|
+
Use `ppk.save('rsa.ppk', 'Passphrase for encryption', format: 3)` to save a
|
106
|
+
format 3 file instead of format 2.
|
107
|
+
|
85
108
|
|
86
109
|
### Converting an unencrypted .ppk file to .pem format ###
|
87
110
|
|
@@ -106,6 +129,9 @@ ppk = PuTTY::Key::PPK.new('rsa.ppk', 'Passphrase for encryption')
|
|
106
129
|
ppk.save('rsa-plain.ppk')
|
107
130
|
```
|
108
131
|
|
132
|
+
Use `ppk.save('rsa-plain.ppk', format: 3)` to save a format 3 file instead of
|
133
|
+
format 2.
|
134
|
+
|
109
135
|
|
110
136
|
## API Documentation ##
|
111
137
|
|
data/Rakefile
CHANGED
@@ -105,3 +105,27 @@ end
|
|
105
105
|
desc 'Run tests using the refinement, then with the global install'
|
106
106
|
task :test => [:clean_coverage, 'test:refinement', 'test:global'] + (TEST_COVERAGE ? ['coveralls:push'] : []) do
|
107
107
|
end
|
108
|
+
|
109
|
+
# Coveralls expects an sh compatible shell when running git commands with Kernel#`
|
110
|
+
# On Windows, the results end up wrapped in single quotes.
|
111
|
+
# Patch Coveralls::Configuration to remove the quotes.
|
112
|
+
if RUBY_PLATFORM =~ /mingw/
|
113
|
+
module CoverallsFixConfigurationOnWindows
|
114
|
+
def self.included(base)
|
115
|
+
base.instance_eval do
|
116
|
+
class << self
|
117
|
+
alias_method :git_without_windows_fix, :git
|
118
|
+
|
119
|
+
def git
|
120
|
+
git_without_windows_fix.tap do |hash|
|
121
|
+
hash[:head] = hash[:head].map {|k, v| [k, v =~ /\A'(.*)'\z/ ? $1 : v] }.to_h
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
require 'coveralls'
|
130
|
+
Coveralls::Configuration.send(:include, CoverallsFixConfigurationOnWindows)
|
131
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuTTY
|
4
|
+
module Key
|
5
|
+
# Argon2 key derivation parameters for use with format 3.
|
6
|
+
class Argon2Params
|
7
|
+
# Returns the variant of Argon2 to use. `:d` for Argon2d, `:i` for Argon2i
|
8
|
+
# or `:id` for Argon2id.
|
9
|
+
#
|
10
|
+
# @return [Symbol] The variant of Argon2 to use (`:d`, `:i` or `:id`).
|
11
|
+
attr_reader :type
|
12
|
+
|
13
|
+
# @return [Integer] The amount of memory to use (memory cost) in
|
14
|
+
# kibibytes.
|
15
|
+
attr_reader :memory
|
16
|
+
|
17
|
+
# @return [Integer] The number of parallel threads to use (parallelism
|
18
|
+
# degree / lanes).
|
19
|
+
attr_reader :parallelism
|
20
|
+
|
21
|
+
# @return [Integer] The number of passes or iterations to run (time cost),
|
22
|
+
# or `nil` to determine the time cost based on {#desired_time}.
|
23
|
+
attr_reader :passes
|
24
|
+
|
25
|
+
# @return [String] The salt to use, or `nil` if a random salt should be
|
26
|
+
# selected.
|
27
|
+
attr_reader :salt
|
28
|
+
|
29
|
+
# The minimum time that should be taken to derive keys in milliseconds.
|
30
|
+
# Only used if {#passes} is `nil`.
|
31
|
+
#
|
32
|
+
# A number of passes will be chosen that take at least {#desired_time} to
|
33
|
+
# compute a hash.
|
34
|
+
#
|
35
|
+
# @return [Numeric] The minimum time that should be taken to derive keys
|
36
|
+
# in milliseconds.
|
37
|
+
attr_reader :desired_time
|
38
|
+
|
39
|
+
# Initalizes a new {Argon2Params} instance with the specified parameters.
|
40
|
+
#
|
41
|
+
# @param type [Symbol] The variant of Argon2 to use (`:d`, `:i` or `:id`).
|
42
|
+
# @param memory [Integer] The amount of memory to use (memory cost) in
|
43
|
+
# kibibytes.
|
44
|
+
# @param parallelism [Integer] The number of parallel threads to use
|
45
|
+
# (parallelism degree / lanes).
|
46
|
+
# @param passes [Integer] The number of passes or iterations to run (time
|
47
|
+
# cost), or `nil` to determine the time cost based on {#desired_time}.
|
48
|
+
# @param salt [String] The salt to use, or `nil` if a random salt should
|
49
|
+
# be selected.
|
50
|
+
# @param desired_time [Numeric] The minimum time that should be taken to
|
51
|
+
# derive keys in milliseconds.
|
52
|
+
#
|
53
|
+
# @raise [ArgumentError] If `type` is not either `:d`, `:i` or `:id`.
|
54
|
+
# @raise [ArgumentError] If `memory` is not an `Integer`, is negative or
|
55
|
+
# greater than 2³².
|
56
|
+
# @raise [ArgumentError] If `parallelism` is not an `Integer`, is negative
|
57
|
+
# or greater than 2³².
|
58
|
+
# @raise [ArgumentError] If `passes` is specified, but is not an
|
59
|
+
# `Integer`, is negative or greater than 2³².
|
60
|
+
# @raise [ArgumentError] If `salt` is specified, but is not a `String`.
|
61
|
+
# @raise [ArgumentError] If `desired_time` is not `Numeric` or is
|
62
|
+
# negative.
|
63
|
+
def initialize(type: :id, memory: 8192, parallelism: 1, passes: nil, salt: nil, desired_time: 100)
|
64
|
+
raise ArgumentError, 'type must be :d, :i or :id' unless type == :id || type == :i || type == :d
|
65
|
+
raise ArgumentError, 'memory must be a non-negative Integer' unless memory.kind_of?(Integer) && memory >= 0 && memory <= 2**32
|
66
|
+
raise ArgumentError, 'parallelism must be a non-negative Integer' unless parallelism.kind_of?(Integer) && parallelism >= 0 && parallelism <= 2**32
|
67
|
+
raise ArgumentError, 'passes must be nil or a non-negative Integer' if passes && !(passes.kind_of?(Integer) && passes >= 0 && passes <= 2**32)
|
68
|
+
raise ArgumentError, 'salt must be nil or a String' if salt && !salt.kind_of?(String)
|
69
|
+
raise ArgumentError, 'desired_time must be a non-negative Numeric' unless desired_time.kind_of?(Numeric) && desired_time >= 0 && desired_time <= 2**32
|
70
|
+
|
71
|
+
@type = type
|
72
|
+
@memory = memory
|
73
|
+
@parallelism = parallelism
|
74
|
+
@passes = passes
|
75
|
+
@salt = salt
|
76
|
+
@desired_time = desired_time
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns an instance of {Argon2Params} with the actual number of passes
|
80
|
+
# and salt used.
|
81
|
+
#
|
82
|
+
# @param actual_passes [Integer] The number of passes or iterations used.
|
83
|
+
# @param actual_salt [String] The actual salt used.
|
84
|
+
#
|
85
|
+
# @return [Argon2Params] An instance of {Argon2Params} with the given
|
86
|
+
# passes and salt.
|
87
|
+
#
|
88
|
+
# @raise [ArgumentError] If `actual_passes` is not a positive `Integer`.
|
89
|
+
# @raise [ArgumentError] If `actual_salt` is not a `String`.
|
90
|
+
def complete(passes, salt)
|
91
|
+
raise ArgumentError, 'passes must not be nil' unless passes
|
92
|
+
raise ArgumentError, 'salt must not be nil' unless salt
|
93
|
+
if @passes == passes && @salt == salt
|
94
|
+
self
|
95
|
+
else
|
96
|
+
Argon2Params.new(type: @type, memory: @memory, parallelism: @parallelism, passes: passes, salt: salt, desired_time: @desired_time)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/putty/key/error.rb
CHANGED
@@ -18,6 +18,23 @@ module PuTTY
|
|
18
18
|
class UnsupportedCurveError < Error
|
19
19
|
end
|
20
20
|
|
21
|
+
# Indicates that libargon2 encountered an error hashing the passphrase to
|
22
|
+
# derive the keys for a format 3 .ppk file.
|
23
|
+
class Argon2Error < Error
|
24
|
+
# The error code returned by the `argon2_hash` function.
|
25
|
+
attr_reader :error_code
|
26
|
+
|
27
|
+
# Initializes a new {Argon2Error}.
|
28
|
+
#
|
29
|
+
# @param error_code [Integer] The error code returned by the `argon2_hash`
|
30
|
+
# function.
|
31
|
+
# @param message [String] A description of the error.
|
32
|
+
def initialize(error_code, message)
|
33
|
+
super(message)
|
34
|
+
@error_code = error_code
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
21
38
|
# Indicates that a nil value has been encountered.
|
22
39
|
class NilValueError < Error
|
23
40
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
module PuTTY
|
6
|
+
module Key
|
7
|
+
# A wrapper for the required functions from libargon2.
|
8
|
+
module Libargon2
|
9
|
+
extend ::FFI::Library
|
10
|
+
|
11
|
+
ffi_lib ['argon2', 'libargon2.so.1', 'libargon2.dll', 'Argon2OptDll.dll', 'Argon2RefDll.dll']
|
12
|
+
|
13
|
+
# Returned by `argon2_hash` if successful.
|
14
|
+
ARGON2_OK = 0
|
15
|
+
|
16
|
+
# The type of hash to perform.
|
17
|
+
enum :argon2_type, [:d, 0, :i, 1, :id, 2]
|
18
|
+
|
19
|
+
# The version of the algorithm to use.
|
20
|
+
enum FFI::Type::UINT32, :argon2_version, [:version_10, 0x10, :version_13, 0x13]
|
21
|
+
|
22
|
+
# Hashes a password with Argon2, producing a raw hash at hash.
|
23
|
+
#
|
24
|
+
# t_cost Number of iterations.
|
25
|
+
# m_cost Sets memory usage to m_cost kibibytes.
|
26
|
+
# parallelism Number of threads and compute lanes.
|
27
|
+
# pwd Pointer to password.
|
28
|
+
# pwdlen Password size in bytes.
|
29
|
+
# salt Pointer to salt.
|
30
|
+
# saltlen Salt size in bytes.
|
31
|
+
# hash Buffer where to write the raw hash - updated by the function.
|
32
|
+
# hashlen Desired length of the hash in bytes.
|
33
|
+
#
|
34
|
+
# Different parallelism levels will give different results.
|
35
|
+
#
|
36
|
+
# Returns ARGON2_OK if successful.
|
37
|
+
#
|
38
|
+
# ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
39
|
+
# const uint32_t parallelism, const void *pwd,
|
40
|
+
# const size_t pwdlen, const void *salt,
|
41
|
+
# const size_t saltlen, void *hash,
|
42
|
+
# const size_t hashlen, char *encoded,
|
43
|
+
# const size_t encodedlen, argon2_type type,
|
44
|
+
# const uint32_t version);
|
45
|
+
attach_function 'argon2_hash', [:uint32, :uint32, :uint32, :pointer, :size_t, :pointer, :size_t, :pointer, :size_t, :pointer, :size_t, :argon2_type, :argon2_version], :int
|
46
|
+
|
47
|
+
# Returns an error message corresponding to the given error code.
|
48
|
+
#
|
49
|
+
# ARGON2_PUBLIC const char *argon2_error_message(int error_code);
|
50
|
+
attach_function :argon2_error_message, [:int], :string
|
51
|
+
end
|
52
|
+
private_constant :Libargon2
|
53
|
+
end
|
54
|
+
end
|