argon2 1.1.2 → 1.1.3
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
- data/ext/argon2_wrap/argon_wrap.c +17 -5
- data/ext/phc-winner-argon2/.gitattributes +5 -0
- data/ext/phc-winner-argon2/argon2-specs.pdf +0 -0
- data/ext/phc-winner-argon2/latex/Makefile +18 -0
- data/ext/phc-winner-argon2/latex/{argon2-spec.tex → argon2-specs.tex} +0 -0
- data/ext/phc-winner-argon2/src/argon2.c +17 -1
- data/ext/phc-winner-argon2/src/encoding.c +17 -4
- data/ext/phc-winner-argon2/src/opt.c +12 -3
- data/ext/phc-winner-argon2/src/ref.c +12 -3
- data/lib/argon2/ffi_engine.rb +1 -1
- data/lib/argon2/version.rb +1 -1
- metadata +4 -6
- data/ext/phc-winner-argon2/src/opt.h +0 -35
- data/ext/phc-winner-argon2/src/ref.h +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94502c59e36f3822c681b2fe0810810618b609ce
|
4
|
+
data.tar.gz: cacc9e8da502df18f4ec2e5f868a8bd49359d6f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd0db288ae3e11d110bc384982520d021b81d63e617bab5b952c4f112f0d6a384a299c358236dce001c05b45629871b1bfab79935c7ad5829c9a4a557cf9764f
|
7
|
+
data.tar.gz: 25ba334f4a68f15b594970416188e6cc52d713aadfa8663b895875ba6ce43720305aa270bf915f53505db0e70f43db1ab2baaa357df4dd361a0d5722b8b02a5c
|
@@ -33,9 +33,9 @@ static int wrap_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
|
|
33
33
|
return (int)((1 & ((d - 1) >> 8)) - 1);
|
34
34
|
}
|
35
35
|
|
36
|
-
|
36
|
+
int argon2_wrap_version(char *out, const char *pwd, size_t pwd_length,
|
37
37
|
uint8_t *salt, uint32_t saltlen, uint32_t t_cost, uint32_t m_cost,
|
38
|
-
uint32_t lanes, uint8_t *secret, size_t secretlen)
|
38
|
+
uint32_t lanes, uint8_t *secret, size_t secretlen, uint32_t version)
|
39
39
|
{
|
40
40
|
uint8_t hash[OUT_LEN];
|
41
41
|
argon2_context context;
|
@@ -65,7 +65,7 @@ unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
|
|
65
65
|
context.allocate_cbk = NULL;
|
66
66
|
context.free_cbk = NULL;
|
67
67
|
context.flags = 0;
|
68
|
-
context.version =
|
68
|
+
context.version = version;
|
69
69
|
|
70
70
|
int result = argon2i_ctx(&context);
|
71
71
|
if (result != ARGON2_OK)
|
@@ -75,6 +75,17 @@ unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
|
|
75
75
|
return ARGON2_OK;
|
76
76
|
}
|
77
77
|
|
78
|
+
/* Since all new hashes will use latest version, this wraps the
|
79
|
+
* function including the version
|
80
|
+
*/
|
81
|
+
int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
|
82
|
+
uint8_t *salt, uint32_t saltlen, uint32_t t_cost, uint32_t m_cost,
|
83
|
+
uint32_t lanes, uint8_t *secret, size_t secretlen)
|
84
|
+
{
|
85
|
+
return argon2_wrap_version(out, pwd, pwd_length, salt, saltlen,
|
86
|
+
t_cost, m_cost, lanes, secret, secretlen, ARGON2_VERSION_13);
|
87
|
+
}
|
88
|
+
|
78
89
|
int wrap_argon2_verify(const char *encoded, const char *pwd,
|
79
90
|
const size_t pwdlen,
|
80
91
|
uint8_t *secret, size_t secretlen)
|
@@ -111,8 +122,9 @@ int wrap_argon2_verify(const char *encoded, const char *pwd,
|
|
111
122
|
return ARGON2_DECODING_FAIL;
|
112
123
|
}
|
113
124
|
|
114
|
-
ret =
|
115
|
-
|
125
|
+
ret = argon2_wrap_version(out, pwd, pwdlen, ctx.salt, ctx.saltlen,
|
126
|
+
ctx.t_cost, ctx.m_cost, ctx.lanes, secret, secretlen,
|
127
|
+
ctx.version);
|
116
128
|
|
117
129
|
free(ctx.salt);
|
118
130
|
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
TEX = pdflatex
|
2
|
+
BIB = bibtex
|
3
|
+
|
4
|
+
PROJECT = argon2-specs
|
5
|
+
|
6
|
+
.PHONY: all clean update
|
7
|
+
|
8
|
+
all:
|
9
|
+
$(TEX) $(PROJECT).tex
|
10
|
+
$(BIB) $(PROJECT).aux
|
11
|
+
$(TEX) $(PROJECT).tex
|
12
|
+
$(TEX) $(PROJECT).tex
|
13
|
+
|
14
|
+
clean:
|
15
|
+
rm -rf *.aux *.bbl *.blg *.log *.out *.pdf *.toc *~
|
16
|
+
|
17
|
+
update:
|
18
|
+
mv $(PROJECT).pdf ./../$(PROJECT).pdf
|
File without changes
|
@@ -72,6 +72,10 @@ int argon2_ctx(argon2_context *context, argon2_type type) {
|
|
72
72
|
instance.threads = context->threads;
|
73
73
|
instance.type = type;
|
74
74
|
|
75
|
+
if (instance.threads > instance.lanes) {
|
76
|
+
instance.threads = instance.lanes;
|
77
|
+
}
|
78
|
+
|
75
79
|
/* 3. Initialization: Hashing inputs, allocating memory, filling first
|
76
80
|
* blocks
|
77
81
|
*/
|
@@ -104,6 +108,14 @@ int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
|
104
108
|
int result;
|
105
109
|
uint8_t *out;
|
106
110
|
|
111
|
+
if (pwdlen > ARGON2_MAX_PWD_LENGTH) {
|
112
|
+
return ARGON2_PWD_TOO_LONG;
|
113
|
+
}
|
114
|
+
|
115
|
+
if (saltlen > ARGON2_MAX_SALT_LENGTH) {
|
116
|
+
return ARGON2_SALT_TOO_LONG;
|
117
|
+
}
|
118
|
+
|
107
119
|
if (hashlen > ARGON2_MAX_OUTLEN) {
|
108
120
|
return ARGON2_OUTPUT_TOO_LONG;
|
109
121
|
}
|
@@ -245,6 +257,10 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
|
|
245
257
|
size_t encoded_len;
|
246
258
|
uint32_t max_field_len;
|
247
259
|
|
260
|
+
if (pwdlen > ARGON2_MAX_PWD_LENGTH) {
|
261
|
+
return ARGON2_PWD_TOO_LONG;
|
262
|
+
}
|
263
|
+
|
248
264
|
if (encoded == NULL) {
|
249
265
|
return ARGON2_DECODING_FAIL;
|
250
266
|
}
|
@@ -268,7 +284,7 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
|
|
268
284
|
}
|
269
285
|
|
270
286
|
ctx.pwd = (uint8_t *)pwd;
|
271
|
-
ctx.pwdlen = pwdlen;
|
287
|
+
ctx.pwdlen = (uint32_t)pwdlen;
|
272
288
|
|
273
289
|
ret = decode_string(&ctx, encoded, type);
|
274
290
|
if (ret != ARGON2_OK) {
|
@@ -288,6 +288,19 @@ int decode_string(argon2_context *ctx, const char *str, argon2_type type) {
|
|
288
288
|
(x) = dec_x; \
|
289
289
|
} while ((void)0, 0)
|
290
290
|
|
291
|
+
|
292
|
+
/* Decoding prefix into uint32_t decimal */
|
293
|
+
#define DECIMAL_U32(x) \
|
294
|
+
do { \
|
295
|
+
unsigned long dec_x; \
|
296
|
+
str = decode_decimal(str, &dec_x); \
|
297
|
+
if (str == NULL || dec_x > UINT32_MAX) { \
|
298
|
+
return ARGON2_DECODING_FAIL; \
|
299
|
+
} \
|
300
|
+
(x) = (uint32_t)dec_x; \
|
301
|
+
} while ((void)0, 0)
|
302
|
+
|
303
|
+
|
291
304
|
/* Decoding base64 into a binary buffer */
|
292
305
|
#define BIN(buf, max_len, len) \
|
293
306
|
do { \
|
@@ -315,14 +328,14 @@ int decode_string(argon2_context *ctx, const char *str, argon2_type type) {
|
|
315
328
|
|
316
329
|
/* Reading the version number if the default is suppressed */
|
317
330
|
ctx->version = ARGON2_VERSION_10;
|
318
|
-
CC_opt("$v=",
|
331
|
+
CC_opt("$v=", DECIMAL_U32(ctx->version));
|
319
332
|
|
320
333
|
CC("$m=");
|
321
|
-
|
334
|
+
DECIMAL_U32(ctx->m_cost);
|
322
335
|
CC(",t=");
|
323
|
-
|
336
|
+
DECIMAL_U32(ctx->t_cost);
|
324
337
|
CC(",p=");
|
325
|
-
|
338
|
+
DECIMAL_U32(ctx->lanes);
|
326
339
|
ctx->threads = ctx->lanes;
|
327
340
|
|
328
341
|
CC("$");
|
@@ -20,13 +20,22 @@
|
|
20
20
|
#include <stdlib.h>
|
21
21
|
|
22
22
|
#include "argon2.h"
|
23
|
-
#include "
|
23
|
+
#include "core.h"
|
24
24
|
|
25
25
|
#include "blake2/blake2.h"
|
26
26
|
#include "blake2/blamka-round-opt.h"
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
/*
|
29
|
+
* Function fills a new memory block and optionally XORs the old block over the new one.
|
30
|
+
* Memory must be initialized.
|
31
|
+
* @param state Pointer to the just produced block. Content will be updated(!)
|
32
|
+
* @param ref_block Pointer to the reference block
|
33
|
+
* @param next_block Pointer to the block to be XORed over. May coincide with @ref_block
|
34
|
+
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
|
35
|
+
* @pre all block pointers must be valid
|
36
|
+
*/
|
37
|
+
static void fill_block(__m128i *state, const block *ref_block,
|
38
|
+
block *next_block, int with_xor) {
|
30
39
|
__m128i block_XY[ARGON2_OWORDS_IN_BLOCK];
|
31
40
|
unsigned int i;
|
32
41
|
|
@@ -20,15 +20,24 @@
|
|
20
20
|
#include <stdlib.h>
|
21
21
|
|
22
22
|
#include "argon2.h"
|
23
|
-
#include "
|
23
|
+
#include "core.h"
|
24
24
|
|
25
25
|
#include "blake2/blamka-round-ref.h"
|
26
26
|
#include "blake2/blake2-impl.h"
|
27
27
|
#include "blake2/blake2.h"
|
28
28
|
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
/*
|
31
|
+
* Function fills a new memory block and optionally XORs the old block over the new one.
|
32
|
+
* @next_block must be initialized.
|
33
|
+
* @param prev_block Pointer to the previous block
|
34
|
+
* @param ref_block Pointer to the reference block
|
35
|
+
* @param next_block Pointer to the block to be constructed
|
36
|
+
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
|
37
|
+
* @pre all block pointers must be valid
|
38
|
+
*/
|
39
|
+
static void fill_block(const block *prev_block, const block *ref_block,
|
40
|
+
block *next_block, int with_xor) {
|
32
41
|
block blockR, block_tmp;
|
33
42
|
unsigned i;
|
34
43
|
|
data/lib/argon2/ffi_engine.rb
CHANGED
@@ -22,7 +22,7 @@ module Argon2
|
|
22
22
|
# uint8_t *secret, uint32_t secretlen)
|
23
23
|
attach_function :argon2_wrap, [
|
24
24
|
:pointer, :pointer, :size_t, :pointer, :uint, :uint,
|
25
|
-
:uint, :uint, :pointer, :size_t], :
|
25
|
+
:uint, :uint, :pointer, :size_t], :int, :blocking => true
|
26
26
|
|
27
27
|
# int argon2i_verify(const char *encoded, const void *pwd,
|
28
28
|
# const size_t pwdlen);
|
data/lib/argon2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argon2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Technion
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -144,7 +144,6 @@ files:
|
|
144
144
|
- ext/argon2_wrap/Makefile
|
145
145
|
- ext/argon2_wrap/argon_wrap.c
|
146
146
|
- ext/argon2_wrap/extconf.rb
|
147
|
-
- ext/argon2_wrap/libargon2_wrap.so
|
148
147
|
- ext/argon2_wrap/test.c
|
149
148
|
- ext/argon2_wrap/tests
|
150
149
|
- ext/phc-winner-argon2/.git
|
@@ -177,7 +176,8 @@ files:
|
|
177
176
|
- ext/phc-winner-argon2/kats/test.ps1
|
178
177
|
- ext/phc-winner-argon2/kats/test.sh
|
179
178
|
- ext/phc-winner-argon2/latex/IEEEtran.cls
|
180
|
-
- ext/phc-winner-argon2/latex/
|
179
|
+
- ext/phc-winner-argon2/latex/Makefile
|
180
|
+
- ext/phc-winner-argon2/latex/argon2-specs.tex
|
181
181
|
- ext/phc-winner-argon2/latex/pics/argon2-par.pdf
|
182
182
|
- ext/phc-winner-argon2/latex/pics/compression.pdf
|
183
183
|
- ext/phc-winner-argon2/latex/pics/generic.pdf
|
@@ -200,9 +200,7 @@ files:
|
|
200
200
|
- ext/phc-winner-argon2/src/genkat.c
|
201
201
|
- ext/phc-winner-argon2/src/genkat.h
|
202
202
|
- ext/phc-winner-argon2/src/opt.c
|
203
|
-
- ext/phc-winner-argon2/src/opt.h
|
204
203
|
- ext/phc-winner-argon2/src/ref.c
|
205
|
-
- ext/phc-winner-argon2/src/ref.h
|
206
204
|
- ext/phc-winner-argon2/src/run.c
|
207
205
|
- ext/phc-winner-argon2/src/test.c
|
208
206
|
- ext/phc-winner-argon2/src/thread.c
|
@@ -1,35 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Argon2 reference source code package - reference C implementations
|
3
|
-
*
|
4
|
-
* Copyright 2015
|
5
|
-
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
6
|
-
*
|
7
|
-
* You may use this work under the terms of a Creative Commons CC0 1.0
|
8
|
-
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
9
|
-
* these licenses can be found at:
|
10
|
-
*
|
11
|
-
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
12
|
-
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
*
|
14
|
-
* You should have received a copy of both of these licenses along with this
|
15
|
-
* software. If not, they may be obtained at the above URLs.
|
16
|
-
*/
|
17
|
-
|
18
|
-
#ifndef ARGON2_OPT_H
|
19
|
-
#define ARGON2_OPT_H
|
20
|
-
|
21
|
-
#include "core.h"
|
22
|
-
#include <emmintrin.h>
|
23
|
-
|
24
|
-
/*
|
25
|
-
* Function fills a new memory block and optionally XORs the old block over the new one.
|
26
|
-
* Memory must be initialized.
|
27
|
-
* @param state Pointer to the just produced block. Content will be updated(!)
|
28
|
-
* @param ref_block Pointer to the reference block
|
29
|
-
* @param next_block Pointer to the block to be XORed over. May coincide with @ref_block
|
30
|
-
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
|
31
|
-
* @pre all block pointers must be valid
|
32
|
-
*/
|
33
|
-
void fill_block(__m128i *s, const block *ref_block, block *next_block, int with_xor);
|
34
|
-
|
35
|
-
#endif /* ARGON2_OPT_H */
|
@@ -1,35 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Argon2 reference source code package - reference C implementations
|
3
|
-
*
|
4
|
-
* Copyright 2015
|
5
|
-
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
6
|
-
*
|
7
|
-
* You may use this work under the terms of a Creative Commons CC0 1.0
|
8
|
-
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
9
|
-
* these licenses can be found at:
|
10
|
-
*
|
11
|
-
* - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
12
|
-
* - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
*
|
14
|
-
* You should have received a copy of both of these licenses along with this
|
15
|
-
* software. If not, they may be obtained at the above URLs.
|
16
|
-
*/
|
17
|
-
|
18
|
-
#ifndef ARGON2_REF_H
|
19
|
-
#define ARGON2_REF_H
|
20
|
-
|
21
|
-
#include "core.h"
|
22
|
-
|
23
|
-
/*
|
24
|
-
* Function fills a new memory block and optionally XORs the old block over the new one.
|
25
|
-
* @next_block must be initialized.
|
26
|
-
* @param prev_block Pointer to the previous block
|
27
|
-
* @param ref_block Pointer to the reference block
|
28
|
-
* @param next_block Pointer to the block to be constructed
|
29
|
-
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
|
30
|
-
* @pre all block pointers must be valid
|
31
|
-
*/
|
32
|
-
void fill_block(const block *prev_block, const block *ref_block,
|
33
|
-
block *next_block, int with_xor);
|
34
|
-
|
35
|
-
#endif /* ARGON2_REF_H */
|