Skip to content

Commit

Permalink
Merge pull request P-H-C#119 from P-H-C/decode
Browse files Browse the repository at this point in the history
Decode
  • Loading branch information
veorq committed Mar 22, 2016
2 parents 0349d51 + 3aa6b14 commit ccd37c8
Show file tree
Hide file tree
Showing 26 changed files with 25,045 additions and 189 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ CFLAGS += -std=c89 -pthread -O3 -Wall -g -Iinclude -Isrc
CI_CFLAGS := $(CFLAGS) -Werror=declaration-after-statement -D_FORTIFY_SOURCE=2 \
-Wextra -Wno-type-limits -Werror -coverage

OPTTEST := $(shell $(CC) -Iinclude -Isrc -march=native src/opt.c -c 2>/dev/null; echo $$?)
OPTTEST := $(shell $(CC) -Iinclude -Isrc -march=native src/opt.c -c \
-o /dev/null 2>/dev/null; echo $$?)
# Detect compatible platform
ifneq ($(OPTTEST), 0)
SRC += src/ref.c
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ results.
on your system. To show usage instructions, run
`./argon2` without arguments as
```
Usage: ./argon2 salt [-d] [-t iterations] [-m memory] [-p parallelism]
Usage: ./argon2 salt [-d] [-t iterations] [-m memory] [-p parallelism] [-h hash length]
Password is read from stdin
Parameters:
salt The salt to use, at least 8 characters
Expand All @@ -68,8 +68,8 @@ Type: Argon2i
Iterations: 2
Memory: 65536 KiB
Parallelism: 4
Hash: 5a028f1a99c9eae671ee448ab80057b78510430865abe57f
Encoded: $argon2i$m=65536,t=2,p=4$c29tZXNhbHQ$WgKPGpnJ6uZx7kSKuABXt4UQQwhlq+V/
Hash: 45d7ac72e76f242b20b77b9bf9bf9d5915894e669a24e6c6
Encoded: $argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG
0.188 seconds
Verification ok
```
Expand Down
25 changes: 24 additions & 1 deletion include/argon2.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ typedef struct Argon2_Context {
uint32_t lanes; /* number of lanes */
uint32_t threads; /* maximum number of threads */

uint32_t version; /* version number */

allocate_fptr allocate_cbk; /* pointer to memory allocator */
deallocate_fptr free_cbk; /* pointer to memory deallocator */

Expand All @@ -204,6 +206,13 @@ typedef struct Argon2_Context {
/* Argon2 primitive type */
typedef enum Argon2_type { Argon2_d = 0, Argon2_i = 1 } argon2_type;

/* Version of the algorithm */
typedef enum Argon2_version {
ARGON2_VERSION_10 = 0x10,
ARGON2_VERSION_13 = 0x13,
ARGON2_VERSION_NUMBER = ARGON2_VERSION_13
} argon2_version;

/*
* Function that performs memory-hard hashing with certain degree of parallelism
* @param context Pointer to the Argon2 internal structure
Expand Down Expand Up @@ -275,7 +284,8 @@ ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
const size_t pwdlen, const void *salt,
const size_t saltlen, void *hash,
const size_t hashlen, char *encoded,
const size_t encodedlen, argon2_type type);
const size_t encodedlen, argon2_type type,
const uint32_t version);

/**
* Verifies a password against an encoded string
Expand Down Expand Up @@ -342,6 +352,19 @@ ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash,
*/
ARGON2_PUBLIC const char *argon2_error_message(int error_code);

/**
* Returns the encoded hash length for the given input parameters
* @param t_cost Number of iterations
* @param m_cost Memory usage in kibibytes
* @param parallelism Number of threads; used to compute lanes
* @param saltlen Salt size in bytes
* @param hashlen Hash size in bytes
* @return The encoded hash length in bytes
*/
ARGON2_PUBLIC size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost,
uint32_t parallelism, uint32_t saltlen,
uint32_t hashlen);

#if defined(__cplusplus)
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion kats/argon2d
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
=======================================Argon2d
=======================================
Argon2d version number 19
=======================================
Memory: 32 KiB, Iterations: 3, Parallelism: 4 lanes, Tag length: 32 bytes
Password[32]: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
Salt[16]: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
Expand Down
2 changes: 1 addition & 1 deletion kats/argon2d.shasum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7752468e1484f1947b056fa03144a84063cd7933d9e101058c87f61c3cb638e5 argon2d
73619cfe0f35e52fdd1ca2595ffaa359879467407f98b61f4969c2861cc329ce argon2d
Loading

0 comments on commit ccd37c8

Please sign in to comment.