argon2 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +6 -5
- data/ext/argon2_wrap/argon_wrap.c +2 -1
- data/ext/argon2_wrap/test.c +5 -5
- data/ext/phc-winner-argon2/.gitattributes +5 -0
- data/ext/phc-winner-argon2/.gitignore +5 -0
- data/ext/phc-winner-argon2/Argon2.sln +98 -0
- data/ext/phc-winner-argon2/CHANGELOG.md +11 -0
- data/ext/phc-winner-argon2/Makefile +7 -2
- data/ext/phc-winner-argon2/README.md +27 -15
- data/ext/phc-winner-argon2/appveyor.yml +25 -0
- data/ext/phc-winner-argon2/export.sh +7 -0
- data/ext/phc-winner-argon2/include/argon2.h +24 -1
- data/ext/phc-winner-argon2/kats/argon2d +3 -1
- data/ext/phc-winner-argon2/kats/argon2d.shasum +1 -1
- data/ext/phc-winner-argon2/kats/argon2d_v16 +12304 -0
- data/ext/phc-winner-argon2/kats/argon2d_v16.shasum +1 -0
- data/ext/phc-winner-argon2/kats/argon2i +3 -1
- data/ext/phc-winner-argon2/kats/argon2i.shasum +1 -1
- data/ext/phc-winner-argon2/kats/argon2i_v16 +12304 -0
- data/ext/phc-winner-argon2/kats/argon2i_v16.shasum +1 -0
- data/ext/phc-winner-argon2/kats/check-sums.ps1 +42 -0
- data/ext/phc-winner-argon2/kats/check-sums.sh +1 -1
- data/ext/phc-winner-argon2/kats/test.ps1 +50 -0
- data/ext/phc-winner-argon2/kats/test.sh +45 -43
- data/ext/phc-winner-argon2/man/argon2.1 +47 -0
- data/ext/phc-winner-argon2/src/argon2.c +29 -15
- data/ext/phc-winner-argon2/src/bench.c +5 -22
- data/ext/phc-winner-argon2/src/core.c +3 -3
- data/ext/phc-winner-argon2/src/core.h +1 -3
- data/ext/phc-winner-argon2/src/encoding.c +22 -3
- data/ext/phc-winner-argon2/src/encoding.h +6 -0
- data/ext/phc-winner-argon2/src/genkat.c +23 -5
- data/ext/phc-winner-argon2/src/opt.c +42 -2
- data/ext/phc-winner-argon2/src/opt.h +10 -0
- data/ext/phc-winner-argon2/src/ref.c +51 -1
- data/ext/phc-winner-argon2/src/ref.h +10 -0
- data/ext/phc-winner-argon2/src/run.c +67 -42
- data/ext/phc-winner-argon2/src/test.c +160 -68
- data/ext/phc-winner-argon2/src/thread.c +1 -1
- data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +158 -0
- data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
- data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +158 -0
- data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
- data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +167 -0
- data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
- data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +159 -0
- data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
- data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +158 -0
- data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
- data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +158 -0
- data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
- data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +159 -0
- data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
- data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +158 -0
- data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
- data/lib/argon2.rb +5 -1
- data/lib/argon2/version.rb +1 -1
- metadata +29 -3
@@ -0,0 +1 @@
|
|
1
|
+
334f03e627afb67b946a530b90d2e11fb2e6abb44df992c0fb3198c7bacf5930 argon2i_v16
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Set-Variable tempfile -option Constant -value "tempfile"
|
2
|
+
|
3
|
+
function hash($path) {
|
4
|
+
$fullPath = Resolve-Path $path
|
5
|
+
$hash = new-object -TypeName System.Security.Cryptography.SHA256CryptoServiceProvider
|
6
|
+
|
7
|
+
$contents = [IO.File]::ReadAllText($fullPath) -replace "`r`n?", "`n"
|
8
|
+
# create UTF-8 encoding without signature
|
9
|
+
$utf8 = New-Object System.Text.UTF8Encoding $false
|
10
|
+
# write the text back
|
11
|
+
[IO.File]::WriteAllText($tempfile, $contents, $utf8)
|
12
|
+
|
13
|
+
$file = [System.IO.File]::Open($tempfile,[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read)
|
14
|
+
$result = [System.BitConverter]::ToString($hash.ComputeHash($file))
|
15
|
+
$file.Dispose()
|
16
|
+
|
17
|
+
if (Test-Path $tempfile) {
|
18
|
+
Remove-Item $tempfile
|
19
|
+
}
|
20
|
+
|
21
|
+
return $result
|
22
|
+
}
|
23
|
+
|
24
|
+
function main() {
|
25
|
+
$files = $(Get-ChildItem * | Where-Object { $_.Name -match '^[a-z2]*(_v)?[0-9]*$' } | select -ExpandProperty name)
|
26
|
+
|
27
|
+
foreach ($file in $files) {
|
28
|
+
$new = $(hash $file).replace("-","")
|
29
|
+
$new = $new.ToLower()
|
30
|
+
|
31
|
+
$old=$(Get-Content $file".shasum")
|
32
|
+
$old = $old.Substring(0, $old.IndexOf(" "))
|
33
|
+
|
34
|
+
if ($new -eq $old) {
|
35
|
+
Write-Host $file "`tOK"
|
36
|
+
} else {
|
37
|
+
Write-Host $file "`tERROR"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
main
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
2
|
+
|
3
|
+
Set-Variable tempfile -option Constant -value "tempfile"
|
4
|
+
|
5
|
+
function CompareFiles($f1, $f2, $i) {
|
6
|
+
$f1_content = $(Get-Content $f1)
|
7
|
+
$f2_content = $(Get-Content $f2)
|
8
|
+
|
9
|
+
if (Compare-Object $f1_content $f2_content) {
|
10
|
+
Write-Host -NoNewline "ERROR"
|
11
|
+
exit $i
|
12
|
+
} else {
|
13
|
+
Write-Host -NoNewline "OK"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
function main() {
|
18
|
+
$i = 0
|
19
|
+
foreach ($opt in @("Ref", "Opt")) {
|
20
|
+
Write-Output "$opt"
|
21
|
+
|
22
|
+
foreach ($version in @(16, 19)) {
|
23
|
+
foreach ($type in @("i", "d")) {
|
24
|
+
$i++
|
25
|
+
|
26
|
+
if ("Ref" -eq $opt) {
|
27
|
+
vs2015\build\Argon2RefGenKAT.exe $type $version > $tempfile
|
28
|
+
} else {
|
29
|
+
vs2015\build\Argon2OptGenKAT.exe $type $version > $tempfile
|
30
|
+
}
|
31
|
+
|
32
|
+
if (19 -eq $version) {
|
33
|
+
$kats = "kats\argon2" + $type
|
34
|
+
} else {
|
35
|
+
$kats = "kats\argon2" + $type + "_v" + $version
|
36
|
+
}
|
37
|
+
|
38
|
+
Write-Host -NoNewline "Argon2$type v=$version : "
|
39
|
+
CompareFiles $tempfile $kats $i
|
40
|
+
Write-Output ""
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
if (Test-Path $tempfile) {
|
46
|
+
Remove-Item $tempfile
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
main
|
@@ -1,47 +1,49 @@
|
|
1
1
|
#!/bin/sh
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
printf "
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
printf "
|
38
|
-
|
39
|
-
printf "
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
3
|
+
for opttest in "" "OPTTEST=1"
|
4
|
+
do
|
5
|
+
if [ "" = "$opttest" ]
|
6
|
+
then
|
7
|
+
printf "Default build\n"
|
8
|
+
else
|
9
|
+
printf "Force OPTTEST=1\n"
|
10
|
+
fi
|
11
|
+
|
12
|
+
make genkat $opttest > /dev/null
|
13
|
+
if [ $? -ne 0 ]
|
14
|
+
then
|
15
|
+
exit $?
|
16
|
+
fi
|
17
|
+
|
18
|
+
i=0
|
19
|
+
for version in 16 19
|
20
|
+
do
|
21
|
+
for type in i d
|
22
|
+
do
|
23
|
+
i=$(($i+1))
|
24
|
+
|
25
|
+
printf "argon2$type v=$version: "
|
26
|
+
|
27
|
+
if [ 19 -eq $version ]
|
28
|
+
then
|
29
|
+
kats="kats/argon2"$type
|
30
|
+
else
|
31
|
+
kats="kats/argon2"$type"_v"$version
|
32
|
+
fi
|
33
|
+
|
34
|
+
./genkat $type $version > tmp
|
35
|
+
if diff tmp $kats
|
36
|
+
then
|
37
|
+
printf "OK"
|
38
|
+
else
|
39
|
+
printf "ERROR"
|
40
|
+
exit $i
|
41
|
+
fi
|
42
|
+
printf "\n"
|
43
|
+
done
|
44
|
+
done
|
45
|
+
done
|
46
46
|
|
47
47
|
rm -f tmp
|
48
|
+
|
49
|
+
exit 0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
.TH ARGON2 "1" "April 2016" "argon2 " "User Commands"
|
2
|
+
|
3
|
+
.SH NAME
|
4
|
+
argon2 \- generate argon2 hashes
|
5
|
+
|
6
|
+
.SH SYNOPSIS
|
7
|
+
.B argon2 salt
|
8
|
+
.RB [ OPTIONS ]
|
9
|
+
|
10
|
+
.SH DESCRIPTION
|
11
|
+
Generate Argon2 hashes from the command line.
|
12
|
+
|
13
|
+
The supplied salt (the first argument to the command) must be at least
|
14
|
+
8 octets in length, and the password is supplied on standard input.
|
15
|
+
|
16
|
+
By default, this uses Argon2i variant (where memory access is
|
17
|
+
independent of secret data) which is the preferred one for password
|
18
|
+
hashing and password-based key derivation.
|
19
|
+
|
20
|
+
.SH OPTIONS
|
21
|
+
.TP
|
22
|
+
.B \-d
|
23
|
+
Use Argon2d instead of Argon2i (Argon2i is the default)
|
24
|
+
.TP
|
25
|
+
.BI \-t " N"
|
26
|
+
Sets the number of iterations to N (default = 3)
|
27
|
+
.TP
|
28
|
+
.BI \-m " N"
|
29
|
+
Sets the memory usage of 2^N KiB (default = 12)
|
30
|
+
.TP
|
31
|
+
.BI \-p " N"
|
32
|
+
Sets parallelism to N threads (default = 1)
|
33
|
+
.TP
|
34
|
+
.BI \-h " N"
|
35
|
+
Sets hash output length to N bytes (default = 32)
|
36
|
+
.TP
|
37
|
+
.B \-e
|
38
|
+
Output only encoded hash
|
39
|
+
.TP
|
40
|
+
.B \-r
|
41
|
+
Output only the raw bytes of the hash
|
42
|
+
|
43
|
+
.SH COPYRIGHT
|
44
|
+
This manpage was written by \fBDaniel Kahn Gillmor\fR for the Debian
|
45
|
+
distribution (but may be used by others). It is released, like the
|
46
|
+
rest of this Argon2 implementation, under the terms of Creative
|
47
|
+
Commons 0 (CC0)
|
@@ -46,6 +46,7 @@ int argon2_ctx(argon2_context *context, argon2_type type) {
|
|
46
46
|
/* Ensure that all segments have equal length */
|
47
47
|
memory_blocks = segment_length * (context->lanes * ARGON2_SYNC_POINTS);
|
48
48
|
|
49
|
+
instance.version = context->version;
|
49
50
|
instance.memory = NULL;
|
50
51
|
instance.passes = context->t_cost;
|
51
52
|
instance.memory_blocks = memory_blocks;
|
@@ -80,24 +81,19 @@ int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
|
80
81
|
const uint32_t parallelism, const void *pwd,
|
81
82
|
const size_t pwdlen, const void *salt, const size_t saltlen,
|
82
83
|
void *hash, const size_t hashlen, char *encoded,
|
83
|
-
const size_t encodedlen, argon2_type type
|
84
|
+
const size_t encodedlen, argon2_type type,
|
85
|
+
const uint32_t version){
|
84
86
|
|
85
87
|
argon2_context context;
|
86
88
|
int result;
|
87
89
|
uint8_t *out;
|
88
90
|
|
89
|
-
/* Detect and reject overflowing sizes */
|
90
|
-
/* TODO: This should probably be fixed in the function signature */
|
91
|
-
if (pwdlen > ARGON2_MAX_PWD_LENGTH) {
|
92
|
-
return ARGON2_PWD_TOO_LONG;
|
93
|
-
}
|
94
|
-
|
95
91
|
if (hashlen > ARGON2_MAX_OUTLEN) {
|
96
92
|
return ARGON2_OUTPUT_TOO_LONG;
|
97
93
|
}
|
98
94
|
|
99
|
-
if (
|
100
|
-
return
|
95
|
+
if (hashlen < ARGON2_MIN_OUTLEN) {
|
96
|
+
return ARGON2_OUTPUT_TOO_SHORT;
|
101
97
|
}
|
102
98
|
|
103
99
|
out = malloc(hashlen);
|
@@ -122,6 +118,7 @@ int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
|
122
118
|
context.allocate_cbk = NULL;
|
123
119
|
context.free_cbk = NULL;
|
124
120
|
context.flags = ARGON2_DEFAULT_FLAGS;
|
121
|
+
context.version = version;
|
125
122
|
|
126
123
|
result = argon2_ctx(&context, type);
|
127
124
|
|
@@ -158,7 +155,8 @@ int argon2i_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
|
|
158
155
|
char *encoded, const size_t encodedlen) {
|
159
156
|
|
160
157
|
return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
|
161
|
-
NULL, hashlen, encoded, encodedlen, Argon2_i
|
158
|
+
NULL, hashlen, encoded, encodedlen, Argon2_i,
|
159
|
+
ARGON2_VERSION_NUMBER);
|
162
160
|
}
|
163
161
|
|
164
162
|
int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
@@ -167,7 +165,7 @@ int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
|
167
165
|
const size_t saltlen, void *hash, const size_t hashlen) {
|
168
166
|
|
169
167
|
return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
|
170
|
-
hash, hashlen, NULL, 0, Argon2_i);
|
168
|
+
hash, hashlen, NULL, 0, Argon2_i, ARGON2_VERSION_NUMBER);
|
171
169
|
}
|
172
170
|
|
173
171
|
int argon2d_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
|
@@ -177,7 +175,8 @@ int argon2d_hash_encoded(const uint32_t t_cost, const uint32_t m_cost,
|
|
177
175
|
char *encoded, const size_t encodedlen) {
|
178
176
|
|
179
177
|
return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
|
180
|
-
NULL, hashlen, encoded, encodedlen, Argon2_d
|
178
|
+
NULL, hashlen, encoded, encodedlen, Argon2_d,
|
179
|
+
ARGON2_VERSION_NUMBER);
|
181
180
|
}
|
182
181
|
|
183
182
|
int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
@@ -186,7 +185,7 @@ int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
|
186
185
|
const size_t saltlen, void *hash, const size_t hashlen) {
|
187
186
|
|
188
187
|
return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen,
|
189
|
-
hash, hashlen, NULL, 0, Argon2_d);
|
188
|
+
hash, hashlen, NULL, 0, Argon2_d, ARGON2_VERSION_NUMBER);
|
190
189
|
}
|
191
190
|
|
192
191
|
static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
|
@@ -206,9 +205,14 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
|
|
206
205
|
uint8_t *out;
|
207
206
|
int ret;
|
208
207
|
int decode_result;
|
208
|
+
uint32_t encoded_len;
|
209
|
+
|
210
|
+
if(encoded == NULL) {
|
211
|
+
return ARGON2_DECODING_FAIL;
|
212
|
+
}
|
209
213
|
|
210
214
|
/* max values, to be updated in decode_string */
|
211
|
-
|
215
|
+
encoded_len = strlen(encoded);
|
212
216
|
ctx.adlen = encoded_len;
|
213
217
|
ctx.saltlen = encoded_len;
|
214
218
|
ctx.outlen = encoded_len;
|
@@ -216,6 +220,8 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
|
|
216
220
|
ctx.free_cbk = NULL;
|
217
221
|
ctx.secret = NULL;
|
218
222
|
ctx.secretlen = 0;
|
223
|
+
ctx.pwdlen = 0;
|
224
|
+
ctx.pwd = NULL;
|
219
225
|
ctx.ad = malloc(ctx.adlen);
|
220
226
|
ctx.salt = malloc(ctx.saltlen);
|
221
227
|
ctx.out = malloc(ctx.outlen);
|
@@ -242,7 +248,8 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
|
|
242
248
|
}
|
243
249
|
|
244
250
|
ret = argon2_hash(ctx.t_cost, ctx.m_cost, ctx.threads, pwd, pwdlen,
|
245
|
-
ctx.salt, ctx.saltlen, out, ctx.outlen, NULL, 0, type
|
251
|
+
ctx.salt, ctx.saltlen, out, ctx.outlen, NULL, 0, type,
|
252
|
+
ctx.version);
|
246
253
|
|
247
254
|
free(ctx.ad);
|
248
255
|
free(ctx.salt);
|
@@ -376,3 +383,10 @@ const char *argon2_error_message(int error_code) {
|
|
376
383
|
return "Unknown error code";
|
377
384
|
}
|
378
385
|
}
|
386
|
+
|
387
|
+
size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism,
|
388
|
+
uint32_t saltlen, uint32_t hashlen) {
|
389
|
+
return strlen("$argon2x$v=$m=,t=,p=$$") + numlen(t_cost) + numlen(m_cost)
|
390
|
+
+ numlen(parallelism) + b64len(saltlen) + b64len(hashlen)
|
391
|
+
+ numlen(ARGON2_VERSION_NUMBER);
|
392
|
+
}
|
@@ -52,7 +52,6 @@ static void benchmark() {
|
|
52
52
|
for (m_cost = (uint32_t)1 << 10; m_cost <= (uint32_t)1 << 22; m_cost *= 2) {
|
53
53
|
unsigned i;
|
54
54
|
for (i = 0; i < 4; ++i) {
|
55
|
-
argon2_context context;
|
56
55
|
uint32_t thread_n = thread_test[i];
|
57
56
|
uint64_t stop_cycles, stop_cycles_i;
|
58
57
|
clock_t stop_time;
|
@@ -61,28 +60,12 @@ static void benchmark() {
|
|
61
60
|
|
62
61
|
clock_t start_time = clock();
|
63
62
|
uint64_t start_cycles = rdtsc();
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
context.pwd = pwd_array;
|
68
|
-
context.pwdlen = inlen;
|
69
|
-
context.salt = salt_array;
|
70
|
-
context.saltlen = inlen;
|
71
|
-
context.secret = NULL;
|
72
|
-
context.secretlen = 0;
|
73
|
-
context.ad = NULL;
|
74
|
-
context.adlen = 0;
|
75
|
-
context.t_cost = t_cost;
|
76
|
-
context.m_cost = m_cost;
|
77
|
-
context.lanes = thread_n;
|
78
|
-
context.threads = thread_n;
|
79
|
-
context.allocate_cbk = NULL;
|
80
|
-
context.free_cbk = NULL;
|
81
|
-
context.flags = 0;
|
82
|
-
|
83
|
-
argon2d_ctx(&context);
|
63
|
+
|
64
|
+
argon2d_hash_raw(t_cost, m_cost, thread_n, pwd_array, inlen,
|
65
|
+
salt_array, inlen, out, outlen);
|
84
66
|
stop_cycles = rdtsc();
|
85
|
-
|
67
|
+
argon2i_hash_raw(t_cost, m_cost, thread_n, pwd_array, inlen,
|
68
|
+
salt_array, inlen, out, outlen);
|
86
69
|
stop_cycles_i = rdtsc();
|
87
70
|
stop_time = clock();
|
88
71
|
|
@@ -88,7 +88,7 @@ int allocate_memory(block **memory, uint32_t m_cost) {
|
|
88
88
|
return ARGON2_MEMORY_ALLOCATION_ERROR;
|
89
89
|
}
|
90
90
|
|
91
|
-
*memory = (block *)
|
91
|
+
*memory = (block *)malloc(memory_size); /*2. Try to allocate*/
|
92
92
|
|
93
93
|
if (!*memory) {
|
94
94
|
return ARGON2_MEMORY_ALLOCATION_ERROR;
|
@@ -103,7 +103,7 @@ void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
|
|
103
103
|
#if defined(_MSC_VER) && VC_GE_2005(_MSC_VER)
|
104
104
|
SecureZeroMemory(v, n);
|
105
105
|
#elif defined memset_s
|
106
|
-
memset_s(v, n);
|
106
|
+
memset_s(v, n, 0, n);
|
107
107
|
#elif defined(__OpenBSD__)
|
108
108
|
explicit_bzero(v, n);
|
109
109
|
#else
|
@@ -508,7 +508,7 @@ void initial_hash(uint8_t *blockhash, argon2_context *context,
|
|
508
508
|
store32(&value, context->t_cost);
|
509
509
|
blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
|
510
510
|
|
511
|
-
store32(&value,
|
511
|
+
store32(&value, context->version);
|
512
512
|
blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));
|
513
513
|
|
514
514
|
store32(&value, (uint32_t)type);
|
@@ -30,9 +30,6 @@
|
|
30
30
|
* constants**************************************************/
|
31
31
|
|
32
32
|
enum argon2_core_constants {
|
33
|
-
/* Version of the algorithm */
|
34
|
-
ARGON2_VERSION_NUMBER = 0x13,
|
35
|
-
|
36
33
|
/* Memory block size in bytes */
|
37
34
|
ARGON2_BLOCK_SIZE = 1024,
|
38
35
|
ARGON2_QWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 8,
|
@@ -77,6 +74,7 @@ void xor_block(block *dst, const block *src);
|
|
77
74
|
*/
|
78
75
|
typedef struct Argon2_instance_t {
|
79
76
|
block *memory; /* Memory pointer */
|
77
|
+
uint32_t version;
|
80
78
|
uint32_t passes; /* Number of passes */
|
81
79
|
uint32_t memory_blocks; /* Number of blocks in memory */
|
82
80
|
uint32_t segment_length;
|