Skip to content

Commit 3282118

Browse files
committed
Rewrite all signatures.
Fixes #59, which is some new version of steep or something.
1 parent b46b65b commit 3282118

6 files changed

Lines changed: 81 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ steep check
8181
```
8282
These tools will need to be installed manually at this time and will be added to Gemfiles after much further testing.
8383

84+
## Version 2.2.0
85+
This version changed the way the build system works to deal with a new version of Rubygems. See https://github.com/technion/ruby-argon2/issues/56.
86+
8487
## Version 2.0 - Argon 2id
8588
Version 2.x upwards will now default to the Argon2id hash format. This is consistent with current recommendations regarding Argon2 usage. It remains capable of verifying existing hashes.
8689

sig/argon2.rbs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
1-
# Classes
21
module Argon2
2+
# Front-end API for the Argon2 module.
33
class Password
44
@t_cost: Integer
55
@m_cost: Integer
66
@p_cost: Integer
77
@salt: nil | String
88
@secret: nil | String
9+
@salt_do_not_supply: nil | String
10+
11+
# Expose constants for the options supported and default used for passwords.
12+
DEFAULT_T_COST: 2
13+
14+
DEFAULT_M_COST: 16
15+
16+
DEFAULT_P_COST: 1
17+
18+
MIN_T_COST: 1
19+
20+
MAX_T_COST: 750
21+
22+
MIN_M_COST: 1
23+
24+
MAX_M_COST: 31
25+
26+
MIN_P_COST: 1
27+
28+
MAX_P_COST: 8
929

1030
def initialize: (?::Hash[untyped, untyped] options) -> void
31+
1132
def create: (String pass) -> untyped
12-
def self.create: (String pass) -> untyped
13-
def self.valid_hash?: (string hash) -> Integer?
14-
def self.verify_password: (untyped pass, untyped hash, ?nil secret) -> untyped
15-
end
16-
class Engine
17-
def self.saltgen: () -> String
18-
end
19-
class ArgonHashFail < StandardError
33+
34+
# Helper class, just creates defaults and calls hash()
35+
def self.create: (String pass, ?::Hash[untyped, untyped] options) -> String
36+
37+
def self.valid_hash?: (String hash) -> bool
38+
39+
def self.verify_password: (String pass, String hash, ?String|nil secret) -> bool
2040
end
2141
end

sig/engine.rbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Argon2
2+
# SecureRandom is a Ruby module. I have no idea why steep now thinks it's an unknown constant, nor why rbs
3+
# prototype has no interest in outputting this.
4+
SecureRandom: untyped
5+
# Generates a random, binary string for use as a salt.
6+
class Engine
7+
def self.saltgen: () -> untyped
8+
end
9+
end

sig/errors.rbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Argon2
2+
class ArgonHashFail < StandardError
3+
end
4+
5+
ERRORS: ::Array["ARGON2_OK" | "ARGON2_OUTPUT_PTR_NULL" | "ARGON2_OUTPUT_TOO_SHORT" | "ARGON2_OUTPUT_TOO_LONG" | "ARGON2_PWD_TOO_SHORT" | "ARGON2_PWD_TOO_LONG" | "ARGON2_SALT_TOO_SHORT" | "ARGON2_SALT_TOO_LONG" | "ARGON2_AD_TOO_SHORT" | "ARGON2_AD_TOO_LONG" | "ARGON2_SECRET_TOO_SHORT" | "ARGON2_SECRET_TOO_LONG" | "ARGON2_TIME_TOO_SMALL" | "ARGON2_TIME_TOO_LARGE" | "ARGON2_MEMORY_TOO_LITTLE" | "ARGON2_MEMORY_TOO_MUCH" | "ARGON2_LANES_TOO_FEW" | "ARGON2_LANES_TOO_MANY" | "ARGON2_PWD_PTR_MISMATCH" | "ARGON2_SALT_PTR_MISMATCH" | "ARGON2_SECRET_PTR_MISMATCH" | "ARGON2_AD_PTR_MISMATCH" | "ARGON2_MEMORY_ALLOCATION_ERROR" | "ARGON2_FREE_MEMORY_CBK_NULL" | "ARGON2_ALLOCATE_MEMORY_CBK_NULL" | "ARGON2_INCORRECT_PARAMETER" | "ARGON2_INCORRECT_TYPE" | "ARGON2_OUT_PTR_MISMATCH" | "ARGON2_THREADS_TOO_FEW" | "ARGON2_THREADS_TOO_MANY" | "ARGON2_MISSING_ARGS" | "ARGON2_ENCODING_FAIL" | "ARGON2_DECODING_FAIL" | "ARGON2_THREAD_FAIL"]
6+
end

sig/ffi.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Argon2
22
# Direct external bindings. Call these methods via the Engine class to ensure points are dealt with
3-
module Ext
4-
extend FFI::Library
5-
end
3+
# module Ext
4+
# extend FFI::Library
5+
# end
66

77
# The engine class shields users from the FFI interface.
88
# It is generally not advised to directly use this class.

sig/hash_format.rbs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module Argon2
2+
#
3+
# Get the values from an Argon2 compatible string.
4+
#
5+
class HashFormat
6+
attr_reader variant: untyped
7+
8+
attr_reader version: untyped
9+
10+
attr_reader t_cost: untyped
11+
12+
attr_reader m_cost: untyped
13+
14+
attr_reader p_cost: untyped
15+
16+
attr_reader salt: untyped
17+
18+
attr_reader checksum: untyped
19+
20+
# FIXME: Reduce complexity/AbcSize
21+
# rubocop:disable Metrics/AbcSize
22+
def initialize: (untyped digest) -> void
23+
24+
#
25+
# Checks whether a given digest is a valid Argon2 hash.
26+
#
27+
# Supports 1 and argon2id formats.
28+
#
29+
def self.valid_hash?: (untyped digest) -> untyped
30+
end
31+
end

0 commit comments

Comments
 (0)