argon2id 0.5.0-arm-linux → 0.7.0-arm-linux

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.
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "minitest/autorun"
4
- require "argon2id"
5
-
6
- class TestHashEncoded < Minitest::Test
7
- def test_valid_password_and_salt_encodes_successfully
8
- encoded = Argon2id.hash_encoded(2, 256, 1, "password", "somesalt", 32)
9
-
10
- assert_equal "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4", encoded
11
- end
12
-
13
- def test_password_with_parallelism_of_two
14
- encoded = Argon2id.hash_encoded(2, 256, 2, "password", "somesalt", 32)
15
-
16
- assert_equal "$argon2id$v=19$m=256,t=2,p=2$c29tZXNhbHQ$bQk8UB/VmZZF4Oo79iDXuL5/0ttZwg2f/5U52iv1cDc", encoded
17
- end
18
-
19
- def test_valid_password_does_not_include_trailing_null_byte
20
- encoded = Argon2id.hash_encoded(2, 256, 1, "password", "somesalt", 32)
21
-
22
- refute encoded.end_with?("\x00")
23
- end
24
-
25
- def test_raises_with_too_short_output
26
- assert_raises(Argon2id::Error) do
27
- Argon2id.hash_encoded(2, 256, 1, "password", "somesalt", 1)
28
- end
29
- end
30
-
31
- def test_raises_with_too_few_lanes
32
- assert_raises(Argon2id::Error) do
33
- Argon2id.hash_encoded(2, 256, 0, "password", "somesalt", 32)
34
- end
35
- end
36
-
37
- def test_raises_with_too_small_memory_cost
38
- assert_raises(Argon2id::Error) do
39
- Argon2id.hash_encoded(2, 0, 1, "password", "somesalt", 32)
40
- end
41
- end
42
-
43
- def test_raises_with_too_small_time_cost
44
- assert_raises(Argon2id::Error) do
45
- Argon2id.hash_encoded(0, 256, 1, "password", "somesalt", 32)
46
- end
47
- end
48
-
49
- def test_raises_with_too_short_salt
50
- assert_raises(Argon2id::Error) do
51
- Argon2id.hash_encoded(2, 256, 1, "password", "", 32)
52
- end
53
- end
54
- end
@@ -1,172 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "minitest/autorun"
4
- require "argon2id"
5
-
6
- class TestPassword < Minitest::Test
7
- def test_create_returns_encoded_password_with_defaults
8
- password = Argon2id::Password.create("opensesame")
9
-
10
- assert password.to_s.start_with?("$argon2id$")
11
- assert password.to_s.include?("t=2")
12
- assert password.to_s.include?("m=19456")
13
- end
14
-
15
- def test_create_options_can_override_parameters
16
- password = Argon2id::Password.create("opensesame", t_cost: 2, m_cost: 256)
17
-
18
- assert password.to_s.include?("t=2")
19
- assert password.to_s.include?("m=256")
20
- end
21
-
22
- def test_create_uses_argon2id_configuration
23
- Argon2id.t_cost = 2
24
- Argon2id.m_cost = 256
25
-
26
- password = Argon2id::Password.create("opensesame")
27
-
28
- assert password.to_s.include?("t=2")
29
- assert password.to_s.include?("m=256")
30
- ensure
31
- Argon2id.t_cost = Argon2id::DEFAULT_T_COST
32
- Argon2id.m_cost = Argon2id::DEFAULT_M_COST
33
- end
34
-
35
- def test_create_coerces_pwd_to_string
36
- password = Argon2id::Password.create(123, t_cost: 2, m_cost: 256)
37
-
38
- assert password.to_s.start_with?("$argon2id$")
39
- end
40
-
41
- def test_create_coerces_costs_to_integer
42
- password = Argon2id::Password.create("opensesame", t_cost: "2", m_cost: "256", parallelism: "1", salt_len: "8", output_len: "32")
43
-
44
- assert password.to_s.start_with?("$argon2id$")
45
- end
46
-
47
- def test_create_raises_if_given_non_integer_costs
48
- assert_raises(ArgumentError) do
49
- Argon2id::Password.create("opensesame", t_cost: "not an integer")
50
- end
51
- end
52
-
53
- def test_equals_correct_password
54
- password = Argon2id::Password.create("opensesame", t_cost: 2, m_cost: 256)
55
-
56
- assert password == "opensesame"
57
- end
58
-
59
- def test_does_not_equal_invalid_password
60
- password = Argon2id::Password.create("opensesame", t_cost: 2, m_cost: 256)
61
-
62
- refute password == "notopensesame"
63
- end
64
-
65
- def test_is_password_returns_true_with_correct_password
66
- password = Argon2id::Password.create("opensesame", t_cost: 2, m_cost: 256)
67
-
68
- assert password.is_password?("opensesame")
69
- end
70
-
71
- def test_is_password_returns_false_with_incorrect_password
72
- password = Argon2id::Password.create("opensesame", t_cost: 2, m_cost: 256)
73
-
74
- refute password.is_password?("notopensesame")
75
- end
76
-
77
- def test_salt_returns_the_original_salt
78
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
79
-
80
- assert_equal "somesalt", password.salt
81
- end
82
-
83
- def test_salt_returns_raw_bytes
84
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$KmIxrXv4lrnSJPO0LN7Gdw$lB3724qLPL9MNi10lkvIb4VxIk3q841CLvq0WTCZ0VQ")
85
-
86
- assert_equal "*b1\xAD{\xF8\x96\xB9\xD2$\xF3\xB4,\xDE\xC6w".b, password.salt
87
- end
88
-
89
- def test_raises_for_invalid_hashes
90
- assert_raises(ArgumentError) do
91
- Argon2id::Password.new("not a valid hash")
92
- end
93
- end
94
-
95
- def test_raises_for_partial_hashes
96
- assert_raises(ArgumentError) do
97
- Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$KmIxrXv4lrnSJPO0LN7Gdw")
98
- end
99
- end
100
-
101
- def test_raises_for_non_argon2id_hashes
102
- assert_raises(ArgumentError) do
103
- Argon2id::Password.new("$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ$iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8")
104
- end
105
- end
106
-
107
- def test_salt_supports_versionless_hashes
108
- password = Argon2id::Password.new("$argon2id$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
109
-
110
- assert_equal "somesalt", password.salt
111
- end
112
-
113
- def test_coerces_given_hash_to_string
114
- password = Argon2id::Password.create("password")
115
-
116
- assert Argon2id::Password.new(password) == "password"
117
- end
118
-
119
- def test_extracting_version_from_hash
120
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
121
-
122
- assert_equal 19, password.version
123
- end
124
-
125
- def test_extracting_version_from_versionless_hash
126
- password = Argon2id::Password.new("$argon2id$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
127
-
128
- assert_equal 16, password.version
129
- end
130
-
131
- def test_extracting_time_cost_from_hash
132
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
133
-
134
- assert_equal 2, password.t_cost
135
- end
136
-
137
- def test_extracting_time_cost_from_versionless_hash
138
- password = Argon2id::Password.new("$argon2id$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
139
-
140
- assert_equal 2, password.t_cost
141
- end
142
-
143
- def test_extracting_memory_cost_from_hash
144
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
145
-
146
- assert_equal 256, password.m_cost
147
- end
148
-
149
- def test_extracting_memory_cost_from_versionless_hash
150
- password = Argon2id::Password.new("$argon2id$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
151
-
152
- assert_equal 256, password.m_cost
153
- end
154
-
155
- def test_extracting_parallelism_from_hash
156
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
157
-
158
- assert_equal 1, password.parallelism
159
- end
160
-
161
- def test_extracting_parallelism_from_versionless_hash
162
- password = Argon2id::Password.new("$argon2id$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
163
-
164
- assert_equal 1, password.parallelism
165
- end
166
-
167
- def test_extracting_output_from_hash
168
- password = Argon2id::Password.new("$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4")
169
-
170
- assert_equal "\x9D\xFE\xB9\x10\xE8\v\xAD\x03\x11\xFE\xE2\x0F\x9C\x0E+\x12\xC1y\x87\xB4\xCA\xC9\f.\xF5M[0!\xC6\x8B\xFE".b, password.output
171
- end
172
- end
data/test/test_verify.rb DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "minitest/autorun"
4
- require "argon2id"
5
-
6
- class TestVerify < Minitest::Test
7
- def test_returns_true_with_correct_password
8
- assert Argon2id.verify(
9
- "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4",
10
- "password"
11
- )
12
- end
13
-
14
- def test_returns_false_with_incorrect_password
15
- refute Argon2id.verify(
16
- "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4",
17
- "not password"
18
- )
19
- end
20
-
21
- def test_raises_if_given_invalid_encoded
22
- assert_raises(ArgumentError) do
23
- Argon2id.verify("", "opensesame")
24
- end
25
- end
26
-
27
- def test_raises_if_given_encoded_with_null_byte
28
- assert_raises(ArgumentError) do
29
- Argon2id.verify(
30
- "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4\x00foo",
31
- "password"
32
- )
33
- end
34
- end
35
- end