Vystem 0.2
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[Defines]
|
||||
DSC_SPECIFICATION = 0x0001001C
|
||||
PLATFORM_GUID = 040262ee-aebc-11f0-ba2c-10ffe08423a6
|
||||
PLATFORM_VERSION = 0.1
|
||||
PLATFORM_VERSION = 0.2
|
||||
PLATFORM_NAME = BlastproofEnv
|
||||
SKUID_IDENTIFIER = DEFAULT
|
||||
SUPPORTED_ARCHITECTURES = X64
|
||||
@@ -29,3 +29,6 @@
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
[BuildOptions]
|
||||
GCC:*_*_*_CC_FLAGS = -I$(WORKSPACE)/../
|
||||
|
||||
73
Blastproof/blastproof.json
Normal file
73
Blastproof/blastproof.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Blastproof build",
|
||||
"actions":[
|
||||
{
|
||||
"action":"ensure_folder_reset",
|
||||
"args":{
|
||||
"path_variables":true,
|
||||
"path":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"copy_folder",
|
||||
"args":{
|
||||
"source_folder_variables":true,
|
||||
"source_folder":"%rootcallerfolder%/Blastproof",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_submodule",
|
||||
"args":{
|
||||
"file_variables":true,
|
||||
"file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/common_crypto/common_crypto.json",
|
||||
"wait":true,
|
||||
"block_if_fail":true
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_submodule_parallel",
|
||||
"args":{
|
||||
"submodules_variables":true,
|
||||
"submodules":[
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/bootanim/bootanim.json",
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/fontgen/fontgen.json",
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen/initfsgen.json",
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/config/config.json",
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/keygen/keygen.json"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_submodule",
|
||||
"args":{
|
||||
"file_variables":true,
|
||||
"file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/keygen/keygen-run.json",
|
||||
"wait":true,
|
||||
"block_if_fail":true
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait_dir",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"bash",
|
||||
"-c",
|
||||
". edksetup.sh; build --platform=Blastproof/blastproof.dsc --module=Blastproof/src/main.inf --arch=X64 --buildtarget=RELEASE --tagname=GCC"
|
||||
],
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"show_output":"on_failure",
|
||||
"working_dir_variables":true,
|
||||
"working_dir":"%rootcallerfolder%/$EDK2_DIR$"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -90,6 +90,10 @@ uint16_t clamp(long double v,uint16_t max) {
|
||||
return (uint16_t)v;
|
||||
}
|
||||
int main (int argc,char **argv) {
|
||||
if (fs::exists("bootanim.bin")) {
|
||||
cout<<"[Bootanim] Stopping here because bootanim.bin already exists."<<endl;
|
||||
return 0;
|
||||
}
|
||||
if (argc!=5) {
|
||||
cout<<"[Bootanim] Error: invalid argument."<<endl;
|
||||
return -1;
|
||||
|
||||
94
Blastproof/bootanim/bootanim.json
Normal file
94
Blastproof/bootanim/bootanim.json
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Bootanim build",
|
||||
"actions":[
|
||||
{
|
||||
"action":"compile_one_cpp",
|
||||
"args":{
|
||||
"source_variables":false,
|
||||
"source":"bootanim.cpp",
|
||||
"compiler_variables":true,
|
||||
"compiler":"$CPP_COMPILER$",
|
||||
"pre_arguments_variables":true,
|
||||
"pre_arguments":[
|
||||
],
|
||||
"post_arguments_variables":true,
|
||||
"post_arguments":[
|
||||
"-o",
|
||||
"$BOOTANIM_BINARY_NAME$",
|
||||
"-Ofast",
|
||||
"-march=native"
|
||||
],
|
||||
"output_file_variables":true,
|
||||
"output_file":"$BOOTANIM_BINARY_NAME$",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":true,
|
||||
"cache_authorized":true,
|
||||
"headers_command_variables":true,
|
||||
"headers_command":"gcc -MMD -MF %dfile% -E %sourcefile% -o /dev/null"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_actions_if",
|
||||
"args":{
|
||||
"condition":{
|
||||
"condition_variables":false,
|
||||
"condition":"cache_contains",
|
||||
"condition_args_variables":false,
|
||||
"condition_args":[
|
||||
"bootanim.bin"
|
||||
]
|
||||
},
|
||||
"actions":[
|
||||
{
|
||||
"action":"extract_from_cache",
|
||||
"args":{
|
||||
"target_variables":false,
|
||||
"target":"bootanim.bin",
|
||||
"output_file_variables":true,
|
||||
"output_file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/bootanim/bootanim.bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"exit_current_module",
|
||||
"args":{
|
||||
"is_fail":false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"./bootanim",
|
||||
"logo.png",
|
||||
"file",
|
||||
"$BOOTANIM_WIDTH$",
|
||||
"$BOOTANIM_HEIGH$"
|
||||
],
|
||||
"show_output":"on_failure",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"store_in_cache",
|
||||
"args":{
|
||||
"key_variables":false,
|
||||
"key":"bootanim.bin",
|
||||
"file_variables":true,
|
||||
"file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/bootanim/bootanim.bin",
|
||||
"overwrite_allowed":false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
43
Blastproof/bootloader.json
Normal file
43
Blastproof/bootloader.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Bootloader build",
|
||||
"actions":[
|
||||
{
|
||||
"action":"run_submodule",
|
||||
"args":{
|
||||
"file_variables":false,
|
||||
"file":"src/keycard.json",
|
||||
"wait":true,
|
||||
"block_if_fail":true
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_submodule_if",
|
||||
"args":{
|
||||
"condition":{
|
||||
"condition_variables":false,
|
||||
"condition":"folder_not_exists",
|
||||
"condition_args_variables":true,
|
||||
"condition_args":[
|
||||
"%rootcallerfolder%/$EDK2_DIR$"
|
||||
]
|
||||
},
|
||||
"file_variables":false,
|
||||
"file":"edk2.json",
|
||||
"wait":true,
|
||||
"block_if_fail":true
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_submodule",
|
||||
"args":{
|
||||
"file_variables":false,
|
||||
"file":"blastproof.json",
|
||||
"wait":true,
|
||||
"block_if_fail":true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -62,7 +62,7 @@ void set_keypair_addr(uint32_t addr[8], uint32_t keypair)
|
||||
void copy_keypair_addr(uint32_t out[8], const uint32_t in[8])
|
||||
{
|
||||
memcpy( out, in, SPX_OFFSET_TREE+8 );
|
||||
memcpy( (unsigned char *)out + SPX_OFFSET_KP_ADDR, (unsigned char *)in + SPX_OFFSET_KP_ADDR, 4);
|
||||
memcpy( (unsigned char *)out + SPX_OFFSET_KP_ADDR, (unsigned char *)in + SPX_OFFSET_KP_ADDR, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
51
Blastproof/common_crypto/address.h
Normal file
51
Blastproof/common_crypto/address.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef SPX_ADDRESS_H
|
||||
#define SPX_ADDRESS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "params.h"
|
||||
|
||||
/* The hash types that are passed to set_type */
|
||||
#define SPX_ADDR_TYPE_WOTS 0
|
||||
#define SPX_ADDR_TYPE_WOTSPK 1
|
||||
#define SPX_ADDR_TYPE_HASHTREE 2
|
||||
#define SPX_ADDR_TYPE_FORSTREE 3
|
||||
#define SPX_ADDR_TYPE_FORSPK 4
|
||||
#define SPX_ADDR_TYPE_WOTSPRF 5
|
||||
#define SPX_ADDR_TYPE_FORSPRF 6
|
||||
|
||||
#define set_layer_addr SPX_NAMESPACE(set_layer_addr)
|
||||
void set_layer_addr(uint32_t addr[8], uint32_t layer);
|
||||
|
||||
#define set_tree_addr SPX_NAMESPACE(set_tree_addr)
|
||||
void set_tree_addr(uint32_t addr[8], uint64_t tree);
|
||||
|
||||
#define set_type SPX_NAMESPACE(set_type)
|
||||
void set_type(uint32_t addr[8], uint32_t type);
|
||||
|
||||
/* Copies the layer and tree part of one address into the other */
|
||||
#define copy_subtree_addr SPX_NAMESPACE(copy_subtree_addr)
|
||||
void copy_subtree_addr(uint32_t out[8], const uint32_t in[8]);
|
||||
|
||||
/* These functions are used for WOTS and FORS addresses. */
|
||||
|
||||
#define set_keypair_addr SPX_NAMESPACE(set_keypair_addr)
|
||||
void set_keypair_addr(uint32_t addr[8], uint32_t keypair);
|
||||
|
||||
#define set_chain_addr SPX_NAMESPACE(set_chain_addr)
|
||||
void set_chain_addr(uint32_t addr[8], uint32_t chain);
|
||||
|
||||
#define set_hash_addr SPX_NAMESPACE(set_hash_addr)
|
||||
void set_hash_addr(uint32_t addr[8], uint32_t hash);
|
||||
|
||||
#define copy_keypair_addr SPX_NAMESPACE(copy_keypair_addr)
|
||||
void copy_keypair_addr(uint32_t out[8], const uint32_t in[8]);
|
||||
|
||||
/* These functions are used for all hash tree addresses (including FORS). */
|
||||
|
||||
#define set_tree_height SPX_NAMESPACE(set_tree_height)
|
||||
void set_tree_height(uint32_t addr[8], uint32_t tree_height);
|
||||
|
||||
#define set_tree_index SPX_NAMESPACE(set_tree_index)
|
||||
void set_tree_index(uint32_t addr[8], uint32_t tree_index);
|
||||
|
||||
#endif
|
||||
77
Blastproof/common_crypto/api.h
Normal file
77
Blastproof/common_crypto/api.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef SPX_API_H
|
||||
#define SPX_API_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "params.h"
|
||||
|
||||
#define CRYPTO_ALGNAME "SPHINCS+"
|
||||
|
||||
#define CRYPTO_SECRETKEYBYTES SPX_SK_BYTES
|
||||
#define CRYPTO_PUBLICKEYBYTES SPX_PK_BYTES
|
||||
#define CRYPTO_BYTES SPX_BYTES
|
||||
#define CRYPTO_SEEDBYTES 3*SPX_N
|
||||
|
||||
/*
|
||||
* Returns the length of a secret key, in bytes
|
||||
*/
|
||||
unsigned long long crypto_sign_secretkeybytes(void);
|
||||
|
||||
/*
|
||||
* Returns the length of a public key, in bytes
|
||||
*/
|
||||
unsigned long long crypto_sign_publickeybytes(void);
|
||||
|
||||
/*
|
||||
* Returns the length of a signature, in bytes
|
||||
*/
|
||||
unsigned long long crypto_sign_bytes(void);
|
||||
|
||||
/*
|
||||
* Returns the length of the seed required to generate a key pair, in bytes
|
||||
*/
|
||||
unsigned long long crypto_sign_seedbytes(void);
|
||||
|
||||
/*
|
||||
* Generates a SPHINCS+ key pair given a seed.
|
||||
* Format sk: [SK_SEED || SK_PRF || PUB_SEED || root]
|
||||
* Format pk: [root || PUB_SEED]
|
||||
*/
|
||||
int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk,
|
||||
const unsigned char *seed);
|
||||
|
||||
/*
|
||||
* Generates a SPHINCS+ key pair.
|
||||
* Format sk: [SK_SEED || SK_PRF || PUB_SEED || root]
|
||||
* Format pk: [root || PUB_SEED]
|
||||
*/
|
||||
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk);
|
||||
|
||||
/**
|
||||
* Returns an array containing a detached signature.
|
||||
*/
|
||||
int crypto_sign_signature(uint8_t *sig, size_t *siglen,
|
||||
const uint8_t *m, size_t mlen, const uint8_t *sk);
|
||||
|
||||
/**
|
||||
* Verifies a detached signature and message under a given public key.
|
||||
*/
|
||||
int crypto_sign_verify(const uint8_t *sig, size_t siglen,
|
||||
const uint8_t *m, size_t mlen, const uint8_t *pk);
|
||||
|
||||
/**
|
||||
* Returns an array containing the signature followed by the message.
|
||||
*/
|
||||
int crypto_sign(unsigned char *sm, unsigned long long *smlen,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const unsigned char *sk);
|
||||
|
||||
/**
|
||||
* Verifies a given signature-message pair under a given public key.
|
||||
*/
|
||||
int crypto_sign_open(unsigned char *m, unsigned long long *mlen,
|
||||
const unsigned char *sm, unsigned long long smlen,
|
||||
const unsigned char *pk);
|
||||
|
||||
#endif
|
||||
437
Blastproof/common_crypto/argon2.h
Normal file
437
Blastproof/common_crypto/argon2.h
Normal file
@@ -0,0 +1,437 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#ifndef ARGON2_H
|
||||
#define ARGON2_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Symbols visibility control */
|
||||
#ifdef A2_VISCTL
|
||||
#define ARGON2_PUBLIC __attribute__((visibility("default")))
|
||||
#define ARGON2_LOCAL __attribute__ ((visibility ("hidden")))
|
||||
#elif defined(_MSC_VER)
|
||||
#define ARGON2_PUBLIC __declspec(dllexport)
|
||||
#define ARGON2_LOCAL
|
||||
#else
|
||||
#define ARGON2_PUBLIC
|
||||
#define ARGON2_LOCAL
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Argon2 input parameter restrictions
|
||||
*/
|
||||
|
||||
/* Minimum and maximum number of lanes (degree of parallelism) */
|
||||
#define ARGON2_MIN_LANES UINT32_C(1)
|
||||
#define ARGON2_MAX_LANES UINT32_C(0xFFFFFF)
|
||||
|
||||
/* Minimum and maximum number of threads */
|
||||
#define ARGON2_MIN_THREADS UINT32_C(1)
|
||||
#define ARGON2_MAX_THREADS UINT32_C(0xFFFFFF)
|
||||
|
||||
/* Number of synchronization points between lanes per pass */
|
||||
#define ARGON2_SYNC_POINTS UINT32_C(4)
|
||||
|
||||
/* Minimum and maximum digest size in bytes */
|
||||
#define ARGON2_MIN_OUTLEN UINT32_C(4)
|
||||
#define ARGON2_MAX_OUTLEN UINT32_C(0xFFFFFFFF)
|
||||
|
||||
/* Minimum and maximum number of memory blocks (each of BLOCK_SIZE bytes) */
|
||||
#define ARGON2_MIN_MEMORY (2 * ARGON2_SYNC_POINTS) /* 2 blocks per slice */
|
||||
|
||||
#define ARGON2_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
/* Max memory size is addressing-space/2, topping at 2^32 blocks (4 TB) */
|
||||
#define ARGON2_MAX_MEMORY_BITS \
|
||||
ARGON2_MIN(UINT32_C(32), (sizeof(void *) * CHAR_BIT - 10 - 1))
|
||||
#define ARGON2_MAX_MEMORY \
|
||||
ARGON2_MIN(UINT32_C(0xFFFFFFFF), UINT64_C(1) << ARGON2_MAX_MEMORY_BITS)
|
||||
|
||||
/* Minimum and maximum number of passes */
|
||||
#define ARGON2_MIN_TIME UINT32_C(1)
|
||||
#define ARGON2_MAX_TIME UINT32_C(0xFFFFFFFF)
|
||||
|
||||
/* Minimum and maximum password length in bytes */
|
||||
#define ARGON2_MIN_PWD_LENGTH UINT32_C(0)
|
||||
#define ARGON2_MAX_PWD_LENGTH UINT32_C(0xFFFFFFFF)
|
||||
|
||||
/* Minimum and maximum associated data length in bytes */
|
||||
#define ARGON2_MIN_AD_LENGTH UINT32_C(0)
|
||||
#define ARGON2_MAX_AD_LENGTH UINT32_C(0xFFFFFFFF)
|
||||
|
||||
/* Minimum and maximum salt length in bytes */
|
||||
#define ARGON2_MIN_SALT_LENGTH UINT32_C(8)
|
||||
#define ARGON2_MAX_SALT_LENGTH UINT32_C(0xFFFFFFFF)
|
||||
|
||||
/* Minimum and maximum key length in bytes */
|
||||
#define ARGON2_MIN_SECRET UINT32_C(0)
|
||||
#define ARGON2_MAX_SECRET UINT32_C(0xFFFFFFFF)
|
||||
|
||||
/* Flags to determine which fields are securely wiped (default = no wipe). */
|
||||
#define ARGON2_DEFAULT_FLAGS UINT32_C(0)
|
||||
#define ARGON2_FLAG_CLEAR_PASSWORD (UINT32_C(1) << 0)
|
||||
#define ARGON2_FLAG_CLEAR_SECRET (UINT32_C(1) << 1)
|
||||
|
||||
/* Global flag to determine if we are wiping internal memory buffers. This flag
|
||||
* is defined in core.c and defaults to 1 (wipe internal memory). */
|
||||
extern int FLAG_clear_internal_memory;
|
||||
|
||||
/* Error codes */
|
||||
typedef enum Argon2_ErrorCodes {
|
||||
ARGON2_OK = 0,
|
||||
|
||||
ARGON2_OUTPUT_PTR_NULL = -1,
|
||||
|
||||
ARGON2_OUTPUT_TOO_SHORT = -2,
|
||||
ARGON2_OUTPUT_TOO_LONG = -3,
|
||||
|
||||
ARGON2_PWD_TOO_SHORT = -4,
|
||||
ARGON2_PWD_TOO_LONG = -5,
|
||||
|
||||
ARGON2_SALT_TOO_SHORT = -6,
|
||||
ARGON2_SALT_TOO_LONG = -7,
|
||||
|
||||
ARGON2_AD_TOO_SHORT = -8,
|
||||
ARGON2_AD_TOO_LONG = -9,
|
||||
|
||||
ARGON2_SECRET_TOO_SHORT = -10,
|
||||
ARGON2_SECRET_TOO_LONG = -11,
|
||||
|
||||
ARGON2_TIME_TOO_SMALL = -12,
|
||||
ARGON2_TIME_TOO_LARGE = -13,
|
||||
|
||||
ARGON2_MEMORY_TOO_LITTLE = -14,
|
||||
ARGON2_MEMORY_TOO_MUCH = -15,
|
||||
|
||||
ARGON2_LANES_TOO_FEW = -16,
|
||||
ARGON2_LANES_TOO_MANY = -17,
|
||||
|
||||
ARGON2_PWD_PTR_MISMATCH = -18, /* NULL ptr with non-zero length */
|
||||
ARGON2_SALT_PTR_MISMATCH = -19, /* NULL ptr with non-zero length */
|
||||
ARGON2_SECRET_PTR_MISMATCH = -20, /* NULL ptr with non-zero length */
|
||||
ARGON2_AD_PTR_MISMATCH = -21, /* NULL ptr with non-zero length */
|
||||
|
||||
ARGON2_MEMORY_ALLOCATION_ERROR = -22,
|
||||
|
||||
ARGON2_FREE_MEMORY_CBK_NULL = -23,
|
||||
ARGON2_ALLOCATE_MEMORY_CBK_NULL = -24,
|
||||
|
||||
ARGON2_INCORRECT_PARAMETER = -25,
|
||||
ARGON2_INCORRECT_TYPE = -26,
|
||||
|
||||
ARGON2_OUT_PTR_MISMATCH = -27,
|
||||
|
||||
ARGON2_THREADS_TOO_FEW = -28,
|
||||
ARGON2_THREADS_TOO_MANY = -29,
|
||||
|
||||
ARGON2_MISSING_ARGS = -30,
|
||||
|
||||
ARGON2_ENCODING_FAIL = -31,
|
||||
|
||||
ARGON2_DECODING_FAIL = -32,
|
||||
|
||||
ARGON2_THREAD_FAIL = -33,
|
||||
|
||||
ARGON2_DECODING_LENGTH_FAIL = -34,
|
||||
|
||||
ARGON2_VERIFY_MISMATCH = -35
|
||||
} argon2_error_codes;
|
||||
|
||||
/* Memory allocator types --- for external allocation */
|
||||
typedef int (*allocate_fptr)(uint8_t **memory, size_t bytes_to_allocate);
|
||||
typedef void (*deallocate_fptr)(uint8_t *memory, size_t bytes_to_allocate);
|
||||
|
||||
/* Argon2 external data structures */
|
||||
|
||||
/*
|
||||
*****
|
||||
* Context: structure to hold Argon2 inputs:
|
||||
* output array and its length,
|
||||
* password and its length,
|
||||
* salt and its length,
|
||||
* secret and its length,
|
||||
* associated data and its length,
|
||||
* number of passes, amount of used memory (in KBytes, can be rounded up a bit)
|
||||
* number of parallel threads that will be run.
|
||||
* All the parameters above affect the output hash value.
|
||||
* Additionally, two function pointers can be provided to allocate and
|
||||
* deallocate the memory (if NULL, memory will be allocated internally).
|
||||
* Also, three flags indicate whether to erase password, secret as soon as they
|
||||
* are pre-hashed (and thus not needed anymore), and the entire memory
|
||||
*****
|
||||
* Simplest situation: you have output array out[8], password is stored in
|
||||
* pwd[32], salt is stored in salt[16], you do not have keys nor associated
|
||||
* data. You need to spend 1 GB of RAM and you run 5 passes of Argon2d with
|
||||
* 4 parallel lanes.
|
||||
* You want to erase the password, but you're OK with last pass not being
|
||||
* erased. You want to use the default memory allocator.
|
||||
* Then you initialize:
|
||||
Argon2_Context(out,8,pwd,32,salt,16,NULL,0,NULL,0,5,1<<20,4,4,NULL,NULL,true,false,false,false)
|
||||
*/
|
||||
typedef struct Argon2_Context {
|
||||
uint8_t *out; /* output array */
|
||||
uint32_t outlen; /* digest length */
|
||||
|
||||
uint8_t *pwd; /* password array */
|
||||
uint32_t pwdlen; /* password length */
|
||||
|
||||
uint8_t *salt; /* salt array */
|
||||
uint32_t saltlen; /* salt length */
|
||||
|
||||
uint8_t *secret; /* key array */
|
||||
uint32_t secretlen; /* key length */
|
||||
|
||||
uint8_t *ad; /* associated data array */
|
||||
uint32_t adlen; /* associated data length */
|
||||
|
||||
uint32_t t_cost; /* number of passes */
|
||||
uint32_t m_cost; /* amount of memory requested (KB) */
|
||||
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 */
|
||||
|
||||
uint32_t flags; /* array of bool options */
|
||||
} argon2_context;
|
||||
|
||||
/* Argon2 primitive type */
|
||||
typedef enum Argon2_type {
|
||||
Argon2_d = 0,
|
||||
Argon2_i = 1,
|
||||
Argon2_id = 2
|
||||
} 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 gives the string representation of an argon2_type.
|
||||
* @param type The argon2_type that we want the string for
|
||||
* @param uppercase Whether the string should have the first letter uppercase
|
||||
* @return NULL if invalid type, otherwise the string representation.
|
||||
*/
|
||||
ARGON2_PUBLIC const char *argon2_type2string(argon2_type type, int uppercase);
|
||||
|
||||
/*
|
||||
* Function that performs memory-hard hashing with certain degree of parallelism
|
||||
* @param context Pointer to the Argon2 internal structure
|
||||
* @return Error code if smth is wrong, ARGON2_OK otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2_ctx(argon2_context *context, argon2_type type);
|
||||
|
||||
/**
|
||||
* Hashes a password with Argon2i, producing an encoded hash
|
||||
* @param t_cost Number of iterations
|
||||
* @param m_cost Sets memory usage to m_cost kibibytes
|
||||
* @param parallelism Number of threads and compute lanes
|
||||
* @param pwd Pointer to password
|
||||
* @param pwdlen Password size in bytes
|
||||
* @param salt Pointer to salt
|
||||
* @param saltlen Salt size in bytes
|
||||
* @param hashlen Desired length of the hash in bytes
|
||||
* @param encoded Buffer where to write the encoded hash
|
||||
* @param encodedlen Size of the buffer (thus max size of the encoded hash)
|
||||
* @pre Different parallelism levels will give different results
|
||||
* @pre Returns ARGON2_OK if successful
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2i_hash_encoded(const uint32_t t_cost,
|
||||
const uint32_t m_cost,
|
||||
const uint32_t parallelism,
|
||||
const void *pwd, const size_t pwdlen,
|
||||
const void *salt, const size_t saltlen,
|
||||
const size_t hashlen, char *encoded,
|
||||
const size_t encodedlen);
|
||||
|
||||
/**
|
||||
* Hashes a password with Argon2i, producing a raw hash at @hash
|
||||
* @param t_cost Number of iterations
|
||||
* @param m_cost Sets memory usage to m_cost kibibytes
|
||||
* @param parallelism Number of threads and compute lanes
|
||||
* @param pwd Pointer to password
|
||||
* @param pwdlen Password size in bytes
|
||||
* @param salt Pointer to salt
|
||||
* @param saltlen Salt size in bytes
|
||||
* @param hash Buffer where to write the raw hash - updated by the function
|
||||
* @param hashlen Desired length of the hash in bytes
|
||||
* @pre Different parallelism levels will give different results
|
||||
* @pre Returns ARGON2_OK if successful
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
||||
const uint32_t parallelism, const void *pwd,
|
||||
const size_t pwdlen, const void *salt,
|
||||
const size_t saltlen, void *hash,
|
||||
const size_t hashlen);
|
||||
|
||||
ARGON2_PUBLIC int argon2d_hash_encoded(const uint32_t t_cost,
|
||||
const uint32_t m_cost,
|
||||
const uint32_t parallelism,
|
||||
const void *pwd, const size_t pwdlen,
|
||||
const void *salt, const size_t saltlen,
|
||||
const size_t hashlen, char *encoded,
|
||||
const size_t encodedlen);
|
||||
|
||||
ARGON2_PUBLIC int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
||||
const uint32_t parallelism, const void *pwd,
|
||||
const size_t pwdlen, const void *salt,
|
||||
const size_t saltlen, void *hash,
|
||||
const size_t hashlen);
|
||||
|
||||
ARGON2_PUBLIC int argon2id_hash_encoded(const uint32_t t_cost,
|
||||
const uint32_t m_cost,
|
||||
const uint32_t parallelism,
|
||||
const void *pwd, const size_t pwdlen,
|
||||
const void *salt, const size_t saltlen,
|
||||
const size_t hashlen, char *encoded,
|
||||
const size_t encodedlen);
|
||||
|
||||
ARGON2_PUBLIC int argon2id_hash_raw(const uint32_t t_cost,
|
||||
const uint32_t m_cost,
|
||||
const uint32_t parallelism, const void *pwd,
|
||||
const size_t pwdlen, const void *salt,
|
||||
const size_t saltlen, void *hash,
|
||||
const size_t hashlen);
|
||||
|
||||
/* generic function underlying the above ones */
|
||||
ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
|
||||
const uint32_t parallelism, const void *pwd,
|
||||
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 uint32_t version);
|
||||
|
||||
/**
|
||||
* Verifies a password against an encoded string
|
||||
* Encoded string is restricted as in validate_inputs()
|
||||
* @param encoded String encoding parameters, salt, hash
|
||||
* @param pwd Pointer to password
|
||||
* @pre Returns ARGON2_OK if successful
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd,
|
||||
const size_t pwdlen);
|
||||
|
||||
ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd,
|
||||
const size_t pwdlen);
|
||||
|
||||
ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd,
|
||||
const size_t pwdlen);
|
||||
|
||||
/* generic function underlying the above ones */
|
||||
ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd,
|
||||
const size_t pwdlen, argon2_type type);
|
||||
|
||||
/**
|
||||
* Argon2d: Version of Argon2 that picks memory blocks depending
|
||||
* on the password and salt. Only for side-channel-free
|
||||
* environment!!
|
||||
*****
|
||||
* @param context Pointer to current Argon2 context
|
||||
* @return Zero if successful, a non zero error code otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2d_ctx(argon2_context *context);
|
||||
|
||||
/**
|
||||
* Argon2i: Version of Argon2 that picks memory blocks
|
||||
* independent on the password and salt. Good for side-channels,
|
||||
* but worse w.r.t. tradeoff attacks if only one pass is used.
|
||||
*****
|
||||
* @param context Pointer to current Argon2 context
|
||||
* @return Zero if successful, a non zero error code otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2i_ctx(argon2_context *context);
|
||||
|
||||
/**
|
||||
* Argon2id: Version of Argon2 where the first half-pass over memory is
|
||||
* password-independent, the rest are password-dependent (on the password and
|
||||
* salt). OK against side channels (they reduce to 1/2-pass Argon2i), and
|
||||
* better with w.r.t. tradeoff attacks (similar to Argon2d).
|
||||
*****
|
||||
* @param context Pointer to current Argon2 context
|
||||
* @return Zero if successful, a non zero error code otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2id_ctx(argon2_context *context);
|
||||
|
||||
/**
|
||||
* Verify if a given password is correct for Argon2d hashing
|
||||
* @param context Pointer to current Argon2 context
|
||||
* @param hash The password hash to verify. The length of the hash is
|
||||
* specified by the context outlen member
|
||||
* @return Zero if successful, a non zero error code otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2d_verify_ctx(argon2_context *context, const char *hash);
|
||||
|
||||
/**
|
||||
* Verify if a given password is correct for Argon2i hashing
|
||||
* @param context Pointer to current Argon2 context
|
||||
* @param hash The password hash to verify. The length of the hash is
|
||||
* specified by the context outlen member
|
||||
* @return Zero if successful, a non zero error code otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2i_verify_ctx(argon2_context *context, const char *hash);
|
||||
|
||||
/**
|
||||
* Verify if a given password is correct for Argon2id hashing
|
||||
* @param context Pointer to current Argon2 context
|
||||
* @param hash The password hash to verify. The length of the hash is
|
||||
* specified by the context outlen member
|
||||
* @return Zero if successful, a non zero error code otherwise
|
||||
*/
|
||||
ARGON2_PUBLIC int argon2id_verify_ctx(argon2_context *context,
|
||||
const char *hash);
|
||||
|
||||
/* generic function underlying the above ones */
|
||||
ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash,
|
||||
argon2_type type);
|
||||
|
||||
/**
|
||||
* Get the associated error message for given error code
|
||||
* @return The error message associated with the given error code
|
||||
*/
|
||||
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
|
||||
* @param type The argon2_type that we want the encoded length for
|
||||
* @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, argon2_type type);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef PORTABLE_BLAKE2_H
|
||||
#define PORTABLE_BLAKE2_H
|
||||
|
||||
#include <argon2.h>
|
||||
#include "../argon2.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
140
Blastproof/common_crypto/common_crypto.json
Normal file
140
Blastproof/common_crypto/common_crypto.json
Normal file
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Common Crypto build",
|
||||
"actions":[
|
||||
{
|
||||
"action":"compile_multiple_cpp",
|
||||
"args":{
|
||||
"source_files_path_completion":true,
|
||||
"path_completion_source_ext":".c",
|
||||
"path_completion_output_ext":".o",
|
||||
"source_files_variables":true,
|
||||
"source_files":[
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/common_crypto/**"
|
||||
],
|
||||
"compiler_variables":true,
|
||||
"compiler":"$C_COMPILER$",
|
||||
"pre_arguments_variables":true,
|
||||
"pre_arguments":[
|
||||
"-c"
|
||||
],
|
||||
"post_arguments_variables":true,
|
||||
"post_arguments":[
|
||||
"-o",
|
||||
"%outputfile%",
|
||||
"-Ofast",
|
||||
"-march=native",
|
||||
"-fPIC"
|
||||
],
|
||||
"output_files_variables":false,
|
||||
"output_files":[
|
||||
],
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"cache_authorized":true,
|
||||
"headers_command_variables":true,
|
||||
"headers_command":"gcc -MMD -MF %dfile% -E %sourcefile% -o /dev/null"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":false,
|
||||
"command":[
|
||||
"ar",
|
||||
"rcs",
|
||||
"libcommoncrypto.a",
|
||||
"address.o",
|
||||
"fors.o",
|
||||
"hash_sha2.o",
|
||||
"merkle.o",
|
||||
"randombytes.o",
|
||||
"sha2.o",
|
||||
"sha3.o",
|
||||
"sign.o",
|
||||
"utils.o",
|
||||
"utilsx1.o",
|
||||
"wots.o",
|
||||
"wotsx1.o",
|
||||
"thash_sha2_robust.o",
|
||||
"argon2.o",
|
||||
"blake2/blake2b.o",
|
||||
"core.o",
|
||||
"encoding.o",
|
||||
"opt.o",
|
||||
"thread.o"
|
||||
],
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"show_output":"on_failure"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"$C_COMPILER$",
|
||||
"--shared",
|
||||
"-o",
|
||||
"libcommoncrypto.so",
|
||||
"address.o",
|
||||
"fors.o",
|
||||
"hash_sha2.o",
|
||||
"merkle.o",
|
||||
"randombytes.o",
|
||||
"sha2.o",
|
||||
"sha3.o",
|
||||
"sign.o",
|
||||
"utils.o",
|
||||
"utilsx1.o",
|
||||
"wots.o",
|
||||
"wotsx1.o",
|
||||
"thash_sha2_robust.o",
|
||||
"argon2.o",
|
||||
"blake2/blake2b.o",
|
||||
"core.o",
|
||||
"encoding.o",
|
||||
"opt.o",
|
||||
"thread.o"
|
||||
],
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"show_output":"on_failure"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"vftm_load_crypto_lib",
|
||||
"args":{
|
||||
"lib_path_variables":true,
|
||||
"lib_path":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/common_crypto/libcommoncrypto.so"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"copy_file",
|
||||
"args":{
|
||||
"source_file_variables":true,
|
||||
"source_file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/common_crypto/libcommoncrypto.a",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/keygen/libcommoncrypto.a"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"copy_file",
|
||||
"args":{
|
||||
"source_file_variables":true,
|
||||
"source_file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/common_crypto/libcommoncrypto.a",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen/libcommoncrypto.a"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
28
Blastproof/common_crypto/context.h
Normal file
28
Blastproof/common_crypto/context.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef SPX_CONTEXT_H
|
||||
#define SPX_CONTEXT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "params.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t pub_seed[SPX_N];
|
||||
uint8_t sk_seed[SPX_N];
|
||||
|
||||
#ifdef SPX_SHA2
|
||||
// sha256 state that absorbed pub_seed
|
||||
uint8_t state_seeded[40];
|
||||
|
||||
# if SPX_SHA512
|
||||
// sha512 state that absorbed pub_seed
|
||||
uint8_t state_seeded_512[72];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef SPX_HARAKA
|
||||
uint64_t tweaked512_rc64[10][8];
|
||||
uint32_t tweaked256_rc32[10][8];
|
||||
#endif
|
||||
} spx_ctx;
|
||||
|
||||
#endif
|
||||
32
Blastproof/common_crypto/fors.h
Normal file
32
Blastproof/common_crypto/fors.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef SPX_FORS_H
|
||||
#define SPX_FORS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "params.h"
|
||||
#include "context.h"
|
||||
|
||||
/**
|
||||
* Signs a message m, deriving the secret key from sk_seed and the FTS address.
|
||||
* Assumes m contains at least SPX_FORS_HEIGHT * SPX_FORS_TREES bits.
|
||||
*/
|
||||
#define fors_sign SPX_NAMESPACE(fors_sign)
|
||||
void fors_sign(unsigned char *sig, unsigned char *pk,
|
||||
const unsigned char *m,
|
||||
const spx_ctx* ctx,
|
||||
const uint32_t fors_addr[8]);
|
||||
|
||||
/**
|
||||
* Derives the FORS public key from a signature.
|
||||
* This can be used for verification by comparing to a known public key, or to
|
||||
* subsequently verify a signature on the derived public key. The latter is the
|
||||
* typical use-case when used as an FTS below an OTS in a hypertree.
|
||||
* Assumes m contains at least SPX_FORS_HEIGHT * SPX_FORS_TREES bits.
|
||||
*/
|
||||
#define fors_pk_from_sig SPX_NAMESPACE(fors_pk_from_sig)
|
||||
void fors_pk_from_sig(unsigned char *pk,
|
||||
const unsigned char *sig, const unsigned char *m,
|
||||
const spx_ctx* ctx,
|
||||
const uint32_t fors_addr[8]);
|
||||
|
||||
#endif
|
||||
27
Blastproof/common_crypto/hash.h
Normal file
27
Blastproof/common_crypto/hash.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef SPX_HASH_H
|
||||
#define SPX_HASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "context.h"
|
||||
#include "params.h"
|
||||
|
||||
#define initialize_hash_function SPX_NAMESPACE(initialize_hash_function)
|
||||
void initialize_hash_function(spx_ctx *ctx);
|
||||
|
||||
#define prf_addr SPX_NAMESPACE(prf_addr)
|
||||
void prf_addr(unsigned char *out, const spx_ctx *ctx,
|
||||
const uint32_t addr[8]);
|
||||
|
||||
#define gen_message_random SPX_NAMESPACE(gen_message_random)
|
||||
void gen_message_random(unsigned char *R, const unsigned char *sk_prf,
|
||||
const unsigned char *optrand,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const spx_ctx *ctx);
|
||||
|
||||
#define hash_message SPX_NAMESPACE(hash_message)
|
||||
void hash_message(unsigned char *digest, uint64_t *tree, uint32_t *leaf_idx,
|
||||
const unsigned char *R, const unsigned char *pk,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
const spx_ctx *ctx);
|
||||
|
||||
#endif
|
||||
18
Blastproof/common_crypto/merkle.h
Normal file
18
Blastproof/common_crypto/merkle.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#if !defined( MERKLE_H_ )
|
||||
#define MERKLE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Generate a Merkle signature (WOTS signature followed by the Merkle */
|
||||
/* authentication path) */
|
||||
#define merkle_sign SPX_NAMESPACE(merkle_sign)
|
||||
void merkle_sign(uint8_t *sig, unsigned char *root,
|
||||
const spx_ctx* ctx,
|
||||
uint32_t wots_addr[8], uint32_t tree_addr[8],
|
||||
uint32_t idx_leaf);
|
||||
|
||||
/* Compute the root node of the top-most subtree. */
|
||||
#define merkle_gen_root SPX_NAMESPACE(merkle_gen_root)
|
||||
void merkle_gen_root(unsigned char *root, const spx_ctx* ctx);
|
||||
|
||||
#endif /* MERKLE_H_ */
|
||||
3
Blastproof/common_crypto/params.h
Normal file
3
Blastproof/common_crypto/params.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#define str(s) #s
|
||||
#define xstr(s) str(s)
|
||||
#include "params/params-sphincs-sha2-256f.h"
|
||||
85
Blastproof/common_crypto/params/params-sphincs-sha2-256f.h
Normal file
85
Blastproof/common_crypto/params/params-sphincs-sha2-256f.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef SPX_PARAMS_H
|
||||
#define SPX_PARAMS_H
|
||||
|
||||
#define SPX_NAMESPACE(s) SPX_##s
|
||||
|
||||
/* Hash output length in bytes. */
|
||||
#define SPX_N 32
|
||||
/* Height of the hypertree. */
|
||||
#define SPX_FULL_HEIGHT 68
|
||||
/* Number of subtree layer. */
|
||||
#define SPX_D 17
|
||||
/* FORS tree dimensions. */
|
||||
#define SPX_FORS_HEIGHT 9
|
||||
#define SPX_FORS_TREES 35
|
||||
/* Winternitz parameter, */
|
||||
#define SPX_WOTS_W 16
|
||||
|
||||
/* The hash function is defined by linking a different hash.c file, as opposed
|
||||
to setting a #define constant. */
|
||||
|
||||
/* This is a SHA2-based parameter set, hence whether we use SHA-256
|
||||
* exclusively or we use both SHA-256 and SHA-512 is controlled by
|
||||
* the following #define */
|
||||
#define SPX_SHA512 1 /* Use SHA-512 for H and T_l, l >= 2 */
|
||||
|
||||
/* For clarity */
|
||||
#define SPX_ADDR_BYTES 32
|
||||
|
||||
/* WOTS parameters. */
|
||||
#if SPX_WOTS_W == 256
|
||||
#define SPX_WOTS_LOGW 8
|
||||
#elif SPX_WOTS_W == 16
|
||||
#define SPX_WOTS_LOGW 4
|
||||
#else
|
||||
#error SPX_WOTS_W assumed 16 or 256
|
||||
#endif
|
||||
|
||||
#define SPX_WOTS_LEN1 (8 * SPX_N / SPX_WOTS_LOGW)
|
||||
|
||||
/* SPX_WOTS_LEN2 is floor(log(len_1 * (w - 1)) / log(w)) + 1; we precompute */
|
||||
#if SPX_WOTS_W == 256
|
||||
#if SPX_N <= 1
|
||||
#define SPX_WOTS_LEN2 1
|
||||
#elif SPX_N <= 256
|
||||
#define SPX_WOTS_LEN2 2
|
||||
#else
|
||||
#error Did not precompute SPX_WOTS_LEN2 for n outside {2, .., 256}
|
||||
#endif
|
||||
#elif SPX_WOTS_W == 16
|
||||
#if SPX_N <= 8
|
||||
#define SPX_WOTS_LEN2 2
|
||||
#elif SPX_N <= 136
|
||||
#define SPX_WOTS_LEN2 3
|
||||
#elif SPX_N <= 256
|
||||
#define SPX_WOTS_LEN2 4
|
||||
#else
|
||||
#error Did not precompute SPX_WOTS_LEN2 for n outside {2, .., 256}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SPX_WOTS_LEN (SPX_WOTS_LEN1 + SPX_WOTS_LEN2)
|
||||
#define SPX_WOTS_BYTES (SPX_WOTS_LEN * SPX_N)
|
||||
#define SPX_WOTS_PK_BYTES SPX_WOTS_BYTES
|
||||
|
||||
/* Subtree size. */
|
||||
#define SPX_TREE_HEIGHT (SPX_FULL_HEIGHT / SPX_D)
|
||||
|
||||
#if SPX_TREE_HEIGHT * SPX_D != SPX_FULL_HEIGHT
|
||||
#error SPX_D should always divide SPX_FULL_HEIGHT
|
||||
#endif
|
||||
|
||||
/* FORS parameters. */
|
||||
#define SPX_FORS_MSG_BYTES ((SPX_FORS_HEIGHT * SPX_FORS_TREES + 7) / 8)
|
||||
#define SPX_FORS_BYTES ((SPX_FORS_HEIGHT + 1) * SPX_FORS_TREES * SPX_N)
|
||||
#define SPX_FORS_PK_BYTES SPX_N
|
||||
|
||||
/* Resulting SPX sizes. */
|
||||
#define SPX_BYTES (SPX_N + SPX_FORS_BYTES + SPX_D * SPX_WOTS_BYTES +\
|
||||
SPX_FULL_HEIGHT * SPX_N)
|
||||
#define SPX_PK_BYTES (2 * SPX_N)
|
||||
#define SPX_SK_BYTES (2 * SPX_N + SPX_PK_BYTES)
|
||||
|
||||
#include "../sha2_offsets.h"
|
||||
|
||||
#endif
|
||||
6
Blastproof/common_crypto/randombytes.h
Normal file
6
Blastproof/common_crypto/randombytes.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef SPX_RANDOMBYTES_H
|
||||
#define SPX_RANDOMBYTES_H
|
||||
|
||||
extern void randombytes(unsigned char * x,unsigned long long xlen);
|
||||
|
||||
#endif
|
||||
43
Blastproof/common_crypto/sha2.h
Normal file
43
Blastproof/common_crypto/sha2.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef SPX_SHA2_H
|
||||
#define SPX_SHA2_H
|
||||
|
||||
#include "params.h"
|
||||
|
||||
#define SPX_SHA256_BLOCK_BYTES 64
|
||||
#define SPX_SHA256_OUTPUT_BYTES 32 /* This does not necessarily equal SPX_N */
|
||||
|
||||
#define SPX_SHA512_BLOCK_BYTES 128
|
||||
#define SPX_SHA512_OUTPUT_BYTES 64
|
||||
|
||||
#if SPX_SHA256_OUTPUT_BYTES < SPX_N
|
||||
#error Linking against SHA-256 with N larger than 32 bytes is not supported
|
||||
#endif
|
||||
|
||||
#define SPX_SHA256_ADDR_BYTES 22
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void sha256_inc_init(uint8_t *state);
|
||||
void sha256_inc_blocks(uint8_t *state, const uint8_t *in, size_t inblocks);
|
||||
void sha256_inc_finalize(uint8_t *out, uint8_t *state, const uint8_t *in, size_t inlen);
|
||||
void sha256(uint8_t *out, const uint8_t *in, size_t inlen);
|
||||
|
||||
void sha512_inc_init(uint8_t *state);
|
||||
void sha512_inc_blocks(uint8_t *state, const uint8_t *in, size_t inblocks);
|
||||
void sha512_inc_finalize(uint8_t *out, uint8_t *state, const uint8_t *in, size_t inlen);
|
||||
void sha512(uint8_t *out, const uint8_t *in, size_t inlen);
|
||||
|
||||
#define mgf1_256 SPX_NAMESPACE(mgf1_256)
|
||||
void mgf1_256(unsigned char *out, unsigned long outlen,
|
||||
const unsigned char *in, unsigned long inlen);
|
||||
|
||||
#define mgf1_512 SPX_NAMESPACE(mgf1_512)
|
||||
void mgf1_512(unsigned char *out, unsigned long outlen,
|
||||
const unsigned char *in, unsigned long inlen);
|
||||
|
||||
#define seed_state SPX_NAMESPACE(seed_state)
|
||||
void seed_state(spx_ctx *ctx);
|
||||
|
||||
|
||||
#endif
|
||||
20
Blastproof/common_crypto/sha2_offsets.h
Normal file
20
Blastproof/common_crypto/sha2_offsets.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef SHA2_OFFSETS_H_
|
||||
#define SHA2_OFFSETS_H_
|
||||
|
||||
/*
|
||||
* Offsets of various fields in the address structure when we use SHA2 as
|
||||
* the Sphincs+ hash function
|
||||
*/
|
||||
|
||||
#define SPX_OFFSET_LAYER 0 /* The byte used to specify the Merkle tree layer */
|
||||
#define SPX_OFFSET_TREE 1 /* The start of the 8 byte field used to specify the tree */
|
||||
#define SPX_OFFSET_TYPE 9 /* The byte used to specify the hash type (reason) */
|
||||
#define SPX_OFFSET_KP_ADDR 10 /* The start of the 4 byte field used to specify the key pair address */
|
||||
#define SPX_OFFSET_CHAIN_ADDR 17 /* The byte used to specify the chain address (which Winternitz chain) */
|
||||
#define SPX_OFFSET_HASH_ADDR 21 /* The byte used to specify the hash address (where in the Winternitz chain) */
|
||||
#define SPX_OFFSET_TREE_HGT 17 /* The byte used to specify the height of this node in the FORS or Merkle tree */
|
||||
#define SPX_OFFSET_TREE_INDEX 18 /* The start of the 4 byte field used to specify the node in the FORS or Merkle tree */
|
||||
|
||||
#define SPX_SHA2 1
|
||||
|
||||
#endif /* SHA2_OFFSETS_H_ */
|
||||
46
Blastproof/common_crypto/sha3.h
Normal file
46
Blastproof/common_crypto/sha3.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// sha3.h
|
||||
// 19-Nov-11 Markku-Juhani O. Saarinen <mjos@iki.fi>
|
||||
|
||||
#ifndef SHA3_H
|
||||
#define SHA3_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef KECCAKF_ROUNDS
|
||||
#define KECCAKF_ROUNDS 24
|
||||
#endif
|
||||
|
||||
#ifndef ROTL64
|
||||
#define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y))))
|
||||
#endif
|
||||
|
||||
// state context
|
||||
typedef struct {
|
||||
union { // state:
|
||||
uint8_t b[200]; // 8-bit bytes
|
||||
uint64_t q[25]; // 64-bit words
|
||||
} st;
|
||||
int pt, rsiz, mdlen; // these don't overflow
|
||||
} sha3_ctx_t;
|
||||
|
||||
// Compression function.
|
||||
void sha3_keccakf(uint64_t st[25]);
|
||||
|
||||
// OpenSSL - like interfece
|
||||
int sha3_init(sha3_ctx_t *c, int mdlen); // mdlen = hash output in bytes
|
||||
int sha3_update(sha3_ctx_t *c, const void *data, size_t len);
|
||||
int sha3_final(void *md, sha3_ctx_t *c); // digest goes to md
|
||||
|
||||
// compute a sha3 hash (md) of given byte length from "in"
|
||||
void *sha3(const void *in, size_t inlen, void *md, int mdlen);
|
||||
|
||||
// SHAKE128 and SHAKE256 extensible-output functions
|
||||
#define shake128_init(c) sha3_init(c, 16)
|
||||
#define shake256_init(c) sha3_init(c, 32)
|
||||
#define shake_update sha3_update
|
||||
|
||||
void shake_xof(sha3_ctx_t *c);
|
||||
void shake_out(sha3_ctx_t *c, void *out, size_t len);
|
||||
|
||||
#endif
|
||||
13
Blastproof/common_crypto/thash.h
Normal file
13
Blastproof/common_crypto/thash.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SPX_THASH_H
|
||||
#define SPX_THASH_H
|
||||
|
||||
#include "context.h"
|
||||
#include "params.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define thash SPX_NAMESPACE(thash)
|
||||
void thash(unsigned char *out, const unsigned char *in, unsigned int inblocks,
|
||||
const spx_ctx *ctx, uint32_t addr[8]);
|
||||
|
||||
#endif
|
||||
64
Blastproof/common_crypto/utils.h
Normal file
64
Blastproof/common_crypto/utils.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef SPX_UTILS_H
|
||||
#define SPX_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "params.h"
|
||||
#include "context.h"
|
||||
|
||||
|
||||
/* To support MSVC use alloca() instead of VLAs. See #20. */
|
||||
#ifdef _MSC_VER
|
||||
/* MSVC defines _alloca in malloc.h */
|
||||
# include <malloc.h>
|
||||
/* Note: _malloca(), which is recommended over deprecated _alloca,
|
||||
requires that you call _freea(). So we stick with _alloca */
|
||||
# define SPX_VLA(__t,__x,__s) __t *__x = (__t*)_alloca((__s)*sizeof(__t))
|
||||
#else
|
||||
# define SPX_VLA(__t,__x,__s) __t __x[__s]
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Converts the value of 'in' to 'outlen' bytes in big-endian byte order.
|
||||
*/
|
||||
#define ull_to_bytes SPX_NAMESPACE(ull_to_bytes)
|
||||
void ull_to_bytes(unsigned char *out, unsigned int outlen,
|
||||
unsigned long long in);
|
||||
#define u32_to_bytes SPX_NAMESPACE(u32_to_bytes)
|
||||
void u32_to_bytes(unsigned char *out, uint32_t in);
|
||||
|
||||
/**
|
||||
* Converts the inlen bytes in 'in' from big-endian byte order to an integer.
|
||||
*/
|
||||
#define bytes_to_ull SPX_NAMESPACE(bytes_to_ull)
|
||||
unsigned long long bytes_to_ull(const unsigned char *in, unsigned int inlen);
|
||||
|
||||
/**
|
||||
* Computes a root node given a leaf and an auth path.
|
||||
* Expects address to be complete other than the tree_height and tree_index.
|
||||
*/
|
||||
#define compute_root SPX_NAMESPACE(compute_root)
|
||||
void compute_root(unsigned char *root, const unsigned char *leaf,
|
||||
uint32_t leaf_idx, uint32_t idx_offset,
|
||||
const unsigned char *auth_path, uint32_t tree_height,
|
||||
const spx_ctx *ctx, uint32_t addr[8]);
|
||||
|
||||
/**
|
||||
* For a given leaf index, computes the authentication path and the resulting
|
||||
* root node using Merkle's TreeHash algorithm.
|
||||
* Expects the layer and tree parts of the tree_addr to be set, as well as the
|
||||
* tree type (i.e. SPX_ADDR_TYPE_HASHTREE or SPX_ADDR_TYPE_FORSTREE).
|
||||
* Applies the offset idx_offset to indices before building addresses, so that
|
||||
* it is possible to continue counting indices across trees.
|
||||
*/
|
||||
#define treehash SPX_NAMESPACE(treehash)
|
||||
void treehash(unsigned char *root, unsigned char *auth_path,
|
||||
const spx_ctx* ctx,
|
||||
uint32_t leaf_idx, uint32_t idx_offset, uint32_t tree_height,
|
||||
void (*gen_leaf)(
|
||||
unsigned char* /* leaf */,
|
||||
const spx_ctx* ctx /* ctx */,
|
||||
uint32_t /* addr_idx */, const uint32_t[8] /* tree_addr */),
|
||||
uint32_t tree_addr[8]);
|
||||
|
||||
|
||||
#endif
|
||||
26
Blastproof/common_crypto/utilsx1.h
Normal file
26
Blastproof/common_crypto/utilsx1.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef SPX_UTILSX4_H
|
||||
#define SPX_UTILSX4_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "params.h"
|
||||
#include "context.h"
|
||||
|
||||
/**
|
||||
* For a given leaf index, computes the authentication path and the resulting
|
||||
* root node using Merkle's TreeHash algorithm.
|
||||
* Expects the layer and tree parts of the tree_addr to be set, as well as the
|
||||
* tree type (i.e. SPX_ADDR_TYPE_HASHTREE or SPX_ADDR_TYPE_FORSTREE).
|
||||
* Applies the offset idx_offset to indices before building addresses, so that
|
||||
* it is possible to continue counting indices across trees.
|
||||
*/
|
||||
#define treehashx1 SPX_NAMESPACE(treehashx1)
|
||||
void treehashx1(unsigned char *root, unsigned char *auth_path,
|
||||
const spx_ctx* ctx,
|
||||
uint32_t leaf_idx, uint32_t idx_offset, uint32_t tree_height,
|
||||
void (*gen_leaf)(
|
||||
unsigned char* /* Where to write the leaf */,
|
||||
const spx_ctx* /* ctx */,
|
||||
uint32_t addr_idx, void *info),
|
||||
uint32_t tree_addrx4[8], void *info);
|
||||
|
||||
#endif
|
||||
25
Blastproof/common_crypto/wots.h
Normal file
25
Blastproof/common_crypto/wots.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef SPX_WOTS_H
|
||||
#define SPX_WOTS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "params.h"
|
||||
#include "context.h"
|
||||
|
||||
/**
|
||||
* Takes a WOTS signature and an n-byte message, computes a WOTS public key.
|
||||
*
|
||||
* Writes the computed public key to 'pk'.
|
||||
*/
|
||||
#define wots_pk_from_sig SPX_NAMESPACE(wots_pk_from_sig)
|
||||
void wots_pk_from_sig(unsigned char *pk,
|
||||
const unsigned char *sig, const unsigned char *msg,
|
||||
const spx_ctx *ctx, uint32_t addr[8]);
|
||||
|
||||
/*
|
||||
* Compute the chain lengths needed for a given message hash
|
||||
*/
|
||||
#define chain_lengths SPX_NAMESPACE(chain_lengths)
|
||||
void chain_lengths(unsigned int *lengths, const unsigned char *msg);
|
||||
|
||||
#endif
|
||||
36
Blastproof/common_crypto/wotsx1.h
Normal file
36
Blastproof/common_crypto/wotsx1.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#if !defined( WOTSX1_H_ )
|
||||
#define WOTSX1_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* This is here to provide an interface to the internal wots_gen_leafx1
|
||||
* routine. While this routine is not referenced in the package outside of
|
||||
* wots.c, it is called from the stand-alone benchmark code to characterize
|
||||
* the performance
|
||||
*/
|
||||
struct leaf_info_x1 {
|
||||
unsigned char *wots_sig;
|
||||
uint32_t wots_sign_leaf; /* The index of the WOTS we're using to sign */
|
||||
uint32_t *wots_steps;
|
||||
uint32_t leaf_addr[8];
|
||||
uint32_t pk_addr[8];
|
||||
};
|
||||
|
||||
/* Macro to set the leaf_info to something 'benign', that is, it would */
|
||||
/* run with the same time as it does during the real signing process */
|
||||
/* Used only by the benchmark code */
|
||||
#define INITIALIZE_LEAF_INFO_X1(info, addr, step_buffer) { \
|
||||
info.wots_sig = 0; \
|
||||
info.wots_sign_leaf = ~0u; \
|
||||
info.wots_steps = step_buffer; \
|
||||
memcpy( &info.leaf_addr[0], addr, 32 ); \
|
||||
memcpy( &info.pk_addr[0], addr, 32 ); \
|
||||
}
|
||||
|
||||
#define wots_gen_leafx1 SPX_NAMESPACE(wots_gen_leafx1)
|
||||
void wots_gen_leafx1(unsigned char *dest,
|
||||
const spx_ctx *ctx,
|
||||
uint32_t leaf_idx, void *v_info);
|
||||
|
||||
#endif /* WOTSX1_H_ */
|
||||
@@ -1,3 +1,4 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
# Blastproof config
|
||||
# WARNING : DO NOT PUT ANY NON-ASCII CHAR IN THIS FILE
|
||||
|
||||
@@ -11,7 +12,7 @@ serial_port_erroring=true
|
||||
|
||||
# Graphics
|
||||
# Define the font to use
|
||||
font=bitra-ascii-medium.fbm
|
||||
font=FONT.FBM
|
||||
# Define whether or not the boot animation should be played
|
||||
disable_boot_animation=true
|
||||
# Set the following both to 0 use highest resolution available
|
||||
@@ -46,3 +47,5 @@ kernel_log_disable_serial_port=false
|
||||
kernel_disable_serial_port=false
|
||||
# Define the size of the ring buffer for logging information. Value is in 4KB pages, ranging from 0 (ring logging disabled) to 65535
|
||||
kernel_log_ring_size=2048
|
||||
# Define the amount of keyboards events each keyboard events queue can hold (ranging from 64 to 65535)
|
||||
kernel_kbd_events_queue_capacity=256
|
||||
24
Blastproof/config/config.json
Normal file
24
Blastproof/config/config.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Blastproof configuration patching",
|
||||
"actions":[
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"./config_patch.sh",
|
||||
"$INITFS_UNIQUE_UUID$",
|
||||
"$SIGNSYST_UNIQUE_UUID$"
|
||||
],
|
||||
"show_output":"on_failure",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
8
Blastproof/config/config_patch.sh
Executable file
8
Blastproof/config/config_patch.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
rm -f bp.conf
|
||||
INITFS_TYPE_GUID="8362b434-d825-11f0-a68f-10ffe08423a6"
|
||||
SIGNSYST_TYPE_GUID="da0048b4-d826-11f0-b877-10ffe08423a6"
|
||||
INITFS_GUID=$1
|
||||
SIGNSYST_GUID=$2
|
||||
cp bp_template.cfg bp.cfg
|
||||
sed -i -E "s/=(UUID_GENERATION_NEEDED_INITFS)/=$INITFS_GUID/" bp.cfg
|
||||
sed -i -E "s/=(UUID_GENERATION_NEEDED_SIGNSYST)/=$SIGNSYST_GUID/" bp.cfg
|
||||
81
Blastproof/edk2.json
Normal file
81
Blastproof/edk2.json
Normal file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%rootcallerfolder%",
|
||||
"run_context":"sub",
|
||||
"name":"EDK2 setup",
|
||||
"actions":[
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":false,
|
||||
"command":[
|
||||
"git",
|
||||
"clone",
|
||||
"https://github.com/tianocore/edk2.git"
|
||||
],
|
||||
"show_output":"live",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait_dir",
|
||||
"args":{
|
||||
"command_variables":false,
|
||||
"command":[
|
||||
"git",
|
||||
"submodule",
|
||||
"update",
|
||||
"--init",
|
||||
"--recursive",
|
||||
"--progress"
|
||||
],
|
||||
"show_output":"live",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"working_dir_variables":true,
|
||||
"working_dir":"%rootcallerfolder%/$EDK2_DIR$"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait_dir",
|
||||
"args":{
|
||||
"command_variables":false,
|
||||
"command":[
|
||||
"make",
|
||||
"-C",
|
||||
"BaseTools/"
|
||||
],
|
||||
"show_output":"live",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"working_dir_variables":true,
|
||||
"working_dir":"%rootcallerfolder%/$EDK2_DIR$"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait_dir",
|
||||
"args":{
|
||||
"command_variables":false,
|
||||
"command":[
|
||||
"bash",
|
||||
"-c",
|
||||
"../Blastproof/ovmf.sh"
|
||||
],
|
||||
"show_output":"live",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"working_dir_variables":true,
|
||||
"working_dir":"%rootcallerfolder%/$EDK2_DIR$"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
92
Blastproof/fontgen/fontgen.json
Normal file
92
Blastproof/fontgen/fontgen.json
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Fontgen build",
|
||||
"actions":[
|
||||
{
|
||||
"action":"compile_one_cpp",
|
||||
"args":{
|
||||
"source_variables":false,
|
||||
"source":"fontgen.cpp",
|
||||
"compiler_variables":true,
|
||||
"compiler":"$CPP_COMPILER$",
|
||||
"pre_arguments_variables":true,
|
||||
"pre_arguments":[
|
||||
],
|
||||
"post_arguments_variables":true,
|
||||
"post_arguments":[
|
||||
"-o",
|
||||
"$FONTGEN_BINARY_NAME$"
|
||||
],
|
||||
"output_file_variables":true,
|
||||
"output_file":"$FONTGEN_BINARY_NAME$",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":true,
|
||||
"cache_authorized":true,
|
||||
"headers_command_variables":true,
|
||||
"headers_command":"gcc -MMD -MF %dfile% -E %sourcefile% -o /dev/null"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_actions_if",
|
||||
"args":{
|
||||
"condition":{
|
||||
"condition_variables":false,
|
||||
"condition":"cache_contains",
|
||||
"condition_args_variables":false,
|
||||
"condition_args":[
|
||||
"font.fbm"
|
||||
]
|
||||
},
|
||||
"actions":[
|
||||
{
|
||||
"action":"extract_from_cache",
|
||||
"args":{
|
||||
"target_variables":false,
|
||||
"target":"font.fbm",
|
||||
"output_file_variables":true,
|
||||
"output_file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/fontgen/font.fbm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"exit_current_module",
|
||||
"args":{
|
||||
"is_fail":false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"./fontgen",
|
||||
"#FFFFFF",
|
||||
"#000000",
|
||||
"ascii",
|
||||
"./chars"
|
||||
],
|
||||
"show_output":"on_failure",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"store_in_cache",
|
||||
"args":{
|
||||
"key_variables":false,
|
||||
"key":"font.fbm",
|
||||
"file_variables":true,
|
||||
"file":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/fontgen/font.fbm",
|
||||
"overwrite_allowed":false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -12,14 +12,15 @@ extern "C" {
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include "common/versions.h"
|
||||
using namespace std;
|
||||
namespace fs=filesystem;
|
||||
#pragma pack(push,1)
|
||||
struct initfs_header {
|
||||
uint8_t sign[8]={'I','n','i','t','F','i','S','y'};
|
||||
uint16_t bootloader_version=0x0001;
|
||||
uint16_t initfs_version=0x0001;
|
||||
uint32_t os_version=0x00000001;
|
||||
uint16_t bootloader_version=VY_COMMON_VERSIONS_BOOTLOADER;
|
||||
uint16_t initfs_version=VY_COMMON_VERSIONS_INITFS;
|
||||
uint32_t os_version=VY_COMMON_VERSIONS_OS;
|
||||
uint8_t installation_id[48]={0};
|
||||
uint64_t initfs_size=0;
|
||||
uint64_t table_size=0;
|
||||
@@ -48,9 +49,9 @@ struct file_entry {
|
||||
#pragma pack(push,1)
|
||||
struct signsyst_header {
|
||||
uint8_t sign[8]={'S','i','g','n','S','y','s','t'};
|
||||
uint16_t bootloader_version=0x0001;
|
||||
uint16_t initfs_version=0x0001;
|
||||
uint32_t os_version=0x00000001;
|
||||
uint16_t bootloader_version=VY_COMMON_VERSIONS_BOOTLOADER;
|
||||
uint16_t initfs_version=VY_COMMON_VERSIONS_INITFS;
|
||||
uint32_t os_version=VY_COMMON_VERSIONS_OS;
|
||||
uint8_t installation_id[48]={0};
|
||||
uint64_t signature_size=0;
|
||||
uint64_t signature_count=0;
|
||||
@@ -138,7 +139,7 @@ int main(int argc,char **argv) {
|
||||
uint64_t value=(header.initfs_size+header.table_size+header.files_area_size+header.entries_width+header.entries_count+header.files_area_offset)%UINT64_MAX;
|
||||
header.check1=(value*0x9E3779B185EBCA87)^header.entropy_check1;
|
||||
sha3(header.installation_id,sizeof(header.installation_id),header.installation_id_hash_hash,sizeof(header.installation_id_hash_hash));
|
||||
ofstream initfs_footprint("initfs-footprint.bin",ios::binary);
|
||||
ofstream initfs_footprint("initfsfp.bin",ios::binary);
|
||||
if (!initfs_footprint) {
|
||||
cout<<"[InitFSGen] Error: Can't open initfs-footprint.bin."<<endl;
|
||||
return -1;
|
||||
@@ -220,7 +221,7 @@ int main(int argc,char **argv) {
|
||||
initfs_bin.write(reinterpret_cast<char*>(entries_table.data()),entries_table.size());
|
||||
initfs_bin.write(reinterpret_cast<char*>(files_area.data()),files_area.size());
|
||||
initfs_bin.close();
|
||||
ofstream signsyst_hash("signsyst-hash.bin",ios::binary);
|
||||
ofstream signsyst_hash("sshash.bin",ios::binary);
|
||||
if (!signsyst_hash) {
|
||||
cout<<"[InitFSGen] Error: Can't open signsyst-hash.bin."<<endl;
|
||||
return -1;
|
||||
|
||||
108
Blastproof/initfsgen/initfsgen.json
Normal file
108
Blastproof/initfsgen/initfsgen.json
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"version":"0.1",
|
||||
"root_folder":"%filefolder%",
|
||||
"run_context":"sub",
|
||||
"name":"Initfsgen build",
|
||||
"actions":[
|
||||
{
|
||||
"action":"compile_one_cpp",
|
||||
"args":{
|
||||
"source_variables":false,
|
||||
"source":"initfsgen.cpp",
|
||||
"compiler_variables":true,
|
||||
"compiler":"$CPP_COMPILER$",
|
||||
"pre_arguments_variables":true,
|
||||
"pre_arguments":[
|
||||
"-I%rootcallerfolder%",
|
||||
"-c"
|
||||
],
|
||||
"post_arguments_variables":true,
|
||||
"post_arguments":[
|
||||
],
|
||||
"output_file_variables":true,
|
||||
"output_file":"initfsgen.o",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":true,
|
||||
"cache_authorized":true,
|
||||
"headers_command_variables":true,
|
||||
"headers_command":"gcc -I%rootcallerfolder% -MMD -MF %dfile% -E %sourcefile% -o /dev/null"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"$CPP_COMPILER$",
|
||||
"initfsgen.o",
|
||||
"-o",
|
||||
"initfsgen",
|
||||
"-L.",
|
||||
"-lcommoncrypto",
|
||||
"-lcrypto",
|
||||
"-I%rootcallerfolder%"
|
||||
],
|
||||
"show_output":"on_failure",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"run_command_wait_dir",
|
||||
"args":{
|
||||
"command_variables":true,
|
||||
"command":[
|
||||
"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen/initfsgen",
|
||||
"%rootcallerfolder%/$INITFS_DIR$"
|
||||
],
|
||||
"show_output":"on_failure",
|
||||
"success_status":[
|
||||
0
|
||||
],
|
||||
"ignore_success_status":false,
|
||||
"working_dir_variables":true,
|
||||
"working_dir":"%rootcallerfolder%"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"move_file",
|
||||
"args":{
|
||||
"source_file_variables":true,
|
||||
"source_file":"%rootcallerfolder%/initfs.bin",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"move_file",
|
||||
"args":{
|
||||
"source_file_variables":true,
|
||||
"source_file":"%rootcallerfolder%/signsyst.bin",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"move_file",
|
||||
"args":{
|
||||
"source_file_variables":true,
|
||||
"source_file":"%rootcallerfolder%/initfsfp.bin",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen"
|
||||
}
|
||||
},
|
||||
{
|
||||
"action":"move_file",
|
||||
"args":{
|
||||
"source_file_variables":true,
|
||||
"source_file":"%rootcallerfolder%/sshash.bin",
|
||||
"destination_folder_variables":true,
|
||||
"destination_folder":"%rootcallerfolder%/$EDK2_BLASTPROOF_DIR$/initfsgen"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "address.h"
|
||||
#include "params.h"
|
||||
#include "utils.h"
|
||||
|
||||
/*
|
||||
* Specify which level of Merkle tree (the "layer") we're working on
|
||||
*/
|
||||
void set_layer_addr(uint32_t addr[8], uint32_t layer)
|
||||
{
|
||||
((unsigned char *)addr)[SPX_OFFSET_LAYER] = (unsigned char)layer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify which Merkle tree within the level (the "tree address") we're working on
|
||||
*/
|
||||
void set_tree_addr(uint32_t addr[8], uint64_t tree)
|
||||
{
|
||||
#if (SPX_TREE_HEIGHT * (SPX_D - 1)) > 64
|
||||
#error Subtree addressing is currently limited to at most 2^64 trees
|
||||
#endif
|
||||
ull_to_bytes(&((unsigned char *)addr)[SPX_OFFSET_TREE], 8, tree );
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the reason we'll use this address structure for, that is, what
|
||||
* hash will we compute with it. This is used so that unrelated types of
|
||||
* hashes don't accidentally get the same address structure. The type will be
|
||||
* one of the SPX_ADDR_TYPE constants
|
||||
*/
|
||||
void set_type(uint32_t addr[8], uint32_t type)
|
||||
{
|
||||
((unsigned char *)addr)[SPX_OFFSET_TYPE] = (unsigned char)type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the layer and tree fields of the address structure. This is used
|
||||
* when we're doing multiple types of hashes within the same Merkle tree
|
||||
*/
|
||||
void copy_subtree_addr(uint32_t out[8], const uint32_t in[8])
|
||||
{
|
||||
memcpy( out, in, SPX_OFFSET_TREE+8 );
|
||||
}
|
||||
|
||||
/* These functions are used for OTS addresses. */
|
||||
|
||||
/*
|
||||
* Specify which Merkle leaf we're working on; that is, which OTS keypair
|
||||
* we're talking about.
|
||||
*/
|
||||
void set_keypair_addr(uint32_t addr[8], uint32_t keypair)
|
||||
{
|
||||
u32_to_bytes(&((unsigned char *)addr)[SPX_OFFSET_KP_ADDR], keypair);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the layer, tree and keypair fields of the address structure. This is
|
||||
* used when we're doing multiple things within the same OTS keypair
|
||||
*/
|
||||
void copy_keypair_addr(uint32_t out[8], const uint32_t in[8])
|
||||
{
|
||||
memcpy( out, in, SPX_OFFSET_TREE+8 );
|
||||
memcpy( (unsigned char *)out + SPX_OFFSET_KP_ADDR, (unsigned char *)in + SPX_OFFSET_KP_ADDR, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify which Merkle chain within the OTS we're working with
|
||||
* (the chain address)
|
||||
*/
|
||||
void set_chain_addr(uint32_t addr[8], uint32_t chain)
|
||||
{
|
||||
((unsigned char *)addr)[SPX_OFFSET_CHAIN_ADDR] = (unsigned char)chain;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify where in the Merkle chain we are
|
||||
* (the hash address)
|
||||
*/
|
||||
void set_hash_addr(uint32_t addr[8], uint32_t hash)
|
||||
{
|
||||
((unsigned char *)addr)[SPX_OFFSET_HASH_ADDR] = (unsigned char)hash;
|
||||
}
|
||||
|
||||
/* These functions are used for all hash tree addresses (including FORS). */
|
||||
|
||||
/*
|
||||
* Specify the height of the node in the Merkle/FORS tree we are in
|
||||
* (the tree height)
|
||||
*/
|
||||
void set_tree_height(uint32_t addr[8], uint32_t tree_height)
|
||||
{
|
||||
((unsigned char *)addr)[SPX_OFFSET_TREE_HGT] = (unsigned char)tree_height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Specify the distance from the left edge of the node in the Merkle/FORS tree
|
||||
* (the tree index)
|
||||
*/
|
||||
void set_tree_index(uint32_t addr[8], uint32_t tree_index)
|
||||
{
|
||||
u32_to_bytes(&((unsigned char *)addr)[SPX_OFFSET_TREE_INDEX], tree_index );
|
||||
}
|
||||
Binary file not shown.
@@ -1,158 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptTestCI", "vs2015\Argon2OptTestCI\Argon2OptTestCI.vcxproj", "{12956597-5E42-433A-93F3-D4EFF50AA207}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefTestCI", "vs2015\Argon2RefTestCI\Argon2RefTestCI.vcxproj", "{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptGenKAT", "vs2015\Argon2OptGenKAT\Argon2OptGenKAT.vcxproj", "{DBBAAAE6-4560-4D11-8280-30A6650A82EF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefGenKAT", "vs2015\Argon2RefGenKAT\Argon2RefGenKAT.vcxproj", "{71921B4C-A795-4A37-95A3-99D600E01211}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2Opt", "vs2015\Argon2Opt\Argon2Opt.vcxproj", "{CAA75C57-998C-494E-B8A5-5894EF0FC528}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2Ref", "vs2015\Argon2Ref\Argon2Ref.vcxproj", "{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptBench", "vs2015\Argon2OptBench\Argon2OptBench.vcxproj", "{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefBench", "vs2015\Argon2RefBench\Argon2RefBench.vcxproj", "{99203F6A-6E8C-42FC-8C7C-C07E8913D539}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptDll", "vs2015\Argon2OptDll\Argon2OptDll.vcxproj", "{3A898DD8-ACAE-4269-ADFE-EB7260D71583}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefDll", "vs2015\Argon2RefDll\Argon2RefDll.vcxproj", "{19D911A1-533C-4475-B313-F372481A35D4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
ReleaseStatic|x64 = ReleaseStatic|x64
|
||||
ReleaseStatic|x86 = ReleaseStatic|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x64.Build.0 = Debug|x64
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x86.Build.0 = Debug|Win32
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x64.ActiveCfg = Release|x64
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x64.Build.0 = Release|x64
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x86.ActiveCfg = Release|Win32
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x86.Build.0 = Release|Win32
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{12956597-5E42-433A-93F3-D4EFF50AA207}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x64.Build.0 = Debug|x64
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x86.Build.0 = Debug|Win32
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x64.ActiveCfg = Release|x64
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x64.Build.0 = Release|x64
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x86.ActiveCfg = Release|Win32
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x86.Build.0 = Release|Win32
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x64.Build.0 = Debug|x64
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x86.Build.0 = Debug|Win32
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x64.ActiveCfg = Release|x64
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x64.Build.0 = Release|x64
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x86.ActiveCfg = Release|Win32
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x86.Build.0 = Release|Win32
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{DBBAAAE6-4560-4D11-8280-30A6650A82EF}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x64.Build.0 = Debug|x64
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x86.Build.0 = Debug|Win32
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Release|x64.ActiveCfg = Release|x64
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Release|x64.Build.0 = Release|x64
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Release|x86.ActiveCfg = Release|Win32
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.Release|x86.Build.0 = Release|Win32
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{71921B4C-A795-4A37-95A3-99D600E01211}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x64.Build.0 = Debug|x64
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x86.Build.0 = Debug|Win32
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x64.ActiveCfg = Release|x64
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x64.Build.0 = Release|x64
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x86.ActiveCfg = Release|Win32
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x86.Build.0 = Release|Win32
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{CAA75C57-998C-494E-B8A5-5894EF0FC528}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x64.Build.0 = Debug|x64
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x64.ActiveCfg = Release|x64
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x64.Build.0 = Release|x64
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x86.Build.0 = Release|Win32
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x64.Build.0 = Debug|x64
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x64.ActiveCfg = Release|x64
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x64.Build.0 = Release|x64
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x86.Build.0 = Release|Win32
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x64.Build.0 = Debug|x64
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x86.Build.0 = Debug|Win32
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x64.ActiveCfg = Release|x64
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x64.Build.0 = Release|x64
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x86.ActiveCfg = Release|Win32
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x86.Build.0 = Release|Win32
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{99203F6A-6E8C-42FC-8C7C-C07E8913D539}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Debug|x64.Build.0 = Debug|x64
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Debug|x86.Build.0 = Debug|Win32
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Release|x64.ActiveCfg = Release|x64
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Release|x64.Build.0 = Release|x64
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Release|x86.ActiveCfg = Release|Win32
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.Release|x86.Build.0 = Release|Win32
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{3A898DD8-ACAE-4269-ADFE-EB7260D71583}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Debug|x64.Build.0 = Debug|x64
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Debug|x86.Build.0 = Debug|Win32
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Release|x64.ActiveCfg = Release|x64
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Release|x64.Build.0 = Release|x64
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Release|x86.ActiveCfg = Release|Win32
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.Release|x86.Build.0 = Release|Win32
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.ReleaseStatic|x64.ActiveCfg = ReleaseStatic|x64
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.ReleaseStatic|x64.Build.0 = ReleaseStatic|x64
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.ReleaseStatic|x86.ActiveCfg = ReleaseStatic|Win32
|
||||
{19D911A1-533C-4475-B313-F372481A35D4}.ReleaseStatic|x86.Build.0 = ReleaseStatic|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,32 +0,0 @@
|
||||
# 20171227
|
||||
* Added ABI version number
|
||||
* AVX2/AVX-512F optimizations of BLAMKA
|
||||
* Set Argon2 version number from the command line
|
||||
* New bindings
|
||||
* Minor bug and warning fixes (no security issue)
|
||||
|
||||
# 20161029
|
||||
|
||||
* Argon2id added
|
||||
* Better documentation
|
||||
* Dual licensing CC0 / Apache 2.0
|
||||
* Minor bug fixes (no security issue)
|
||||
|
||||
# 20160406
|
||||
|
||||
* Version 1.3 of Argon2
|
||||
* Version number in encoded hash
|
||||
* Refactored low-level API
|
||||
* Visibility control for library symbols
|
||||
* Microsoft Visual Studio solution
|
||||
* New bindings
|
||||
* Minor bug and warning fixes (no security issue)
|
||||
|
||||
|
||||
# 20151206
|
||||
|
||||
* Python bindings
|
||||
* Password read from stdin, instead of being an argument
|
||||
* Compatibility FreeBSD, NetBSD, OpenBSD
|
||||
* Constant-time verification
|
||||
* Minor bug and warning fixes (no security issue)
|
||||
@@ -1,314 +0,0 @@
|
||||
Argon2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2015
|
||||
Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
|
||||
You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
- Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
The terms of the licenses are reproduced below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
@@ -1,255 +0,0 @@
|
||||
#
|
||||
# Argon2 reference source code package - reference C implementations
|
||||
#
|
||||
# Copyright 2015
|
||||
# Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
#
|
||||
# You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
# License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
# these licenses can be found at:
|
||||
#
|
||||
# - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
# - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# You should have received a copy of both of these licenses along with this
|
||||
# software. If not, they may be obtained at the above URLs.
|
||||
#
|
||||
|
||||
RUN = argon2
|
||||
BENCH = bench
|
||||
GENKAT = genkat
|
||||
ARGON2_VERSION ?= ZERO
|
||||
|
||||
# installation parameters for staging area and final installation path
|
||||
# Note; if Linux and not Debian/Ubuntu version also add lib override to make command-line
|
||||
# for RedHat/Fedora, add: LIBRARY_REL=lib64
|
||||
DESTDIR ?=
|
||||
PREFIX ?= /usr
|
||||
|
||||
# Increment on an ABI breaking change
|
||||
ABI_VERSION = 1
|
||||
|
||||
DIST = phc-winner-argon2
|
||||
|
||||
SRC = src/argon2.c src/core.c src/blake2/blake2b.c src/thread.c src/encoding.c
|
||||
SRC_RUN = src/run.c
|
||||
SRC_BENCH = src/bench.c
|
||||
SRC_GENKAT = src/genkat.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
CFLAGS += -std=c89 -O3 -Wall -g -Iinclude -Isrc
|
||||
|
||||
ifeq ($(NO_THREADS), 1)
|
||||
CFLAGS += -DARGON2_NO_THREADS
|
||||
else
|
||||
CFLAGS += -pthread
|
||||
endif
|
||||
|
||||
CI_CFLAGS := $(CFLAGS) -Werror=declaration-after-statement -D_FORTIFY_SOURCE=2 \
|
||||
-Wextra -Wno-type-limits -Werror -coverage -DTEST_LARGE_RAM
|
||||
|
||||
OPTTARGET ?= native
|
||||
OPTTEST := $(shell $(CC) -Iinclude -Isrc -march=$(OPTTARGET) src/opt.c -c \
|
||||
-o /dev/null 2>/dev/null; echo $$?)
|
||||
# Detect compatible platform
|
||||
ifneq ($(OPTTEST), 0)
|
||||
$(info Building without optimizations)
|
||||
SRC += src/ref.c
|
||||
else
|
||||
$(info Building with optimizations for $(OPTTARGET))
|
||||
CFLAGS += -march=$(OPTTARGET)
|
||||
SRC += src/opt.c
|
||||
endif
|
||||
|
||||
BUILD_PATH := $(shell pwd)
|
||||
KERNEL_NAME := $(shell uname -s)
|
||||
MACHINE_NAME := $(shell uname -m)
|
||||
|
||||
LIB_NAME = argon2
|
||||
PC_NAME = lib$(LIB_NAME).pc
|
||||
PC_SRC = $(PC_NAME).in
|
||||
|
||||
ifeq ($(KERNEL_NAME), Linux)
|
||||
LIB_EXT := so.$(ABI_VERSION)
|
||||
LIB_CFLAGS := -shared -fPIC -fvisibility=hidden -DA2_VISCTL=1
|
||||
SO_LDFLAGS := -Wl,-soname,lib$(LIB_NAME).$(LIB_EXT)
|
||||
LINKED_LIB_EXT := so
|
||||
PC_EXTRA_LIBS ?= -lrt -ldl
|
||||
endif
|
||||
ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),DragonFly FreeBSD NetBSD OpenBSD))
|
||||
LIB_EXT := so
|
||||
LIB_CFLAGS := -shared -fPIC
|
||||
PC_EXTRA_LIBS ?=
|
||||
endif
|
||||
ifeq ($(KERNEL_NAME), Darwin)
|
||||
LIB_EXT := $(ABI_VERSION).dylib
|
||||
LIB_CFLAGS = -dynamiclib -install_name $(PREFIX)/$(LIBRARY_REL)/lib$(LIB_NAME).$(LIB_EXT)
|
||||
LINKED_LIB_EXT := dylib
|
||||
PC_EXTRA_LIBS ?=
|
||||
endif
|
||||
ifeq ($(findstring CYGWIN, $(KERNEL_NAME)), CYGWIN)
|
||||
LIB_EXT := dll
|
||||
LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
|
||||
PC_EXTRA_LIBS ?=
|
||||
endif
|
||||
ifeq ($(findstring MINGW, $(KERNEL_NAME)), MINGW)
|
||||
LIB_EXT := dll
|
||||
LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
|
||||
PC_EXTRA_LIBS ?=
|
||||
endif
|
||||
ifeq ($(findstring MSYS, $(KERNEL_NAME)), MSYS)
|
||||
LIB_EXT := dll
|
||||
LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
|
||||
PC_EXTRA_LIBS ?=
|
||||
endif
|
||||
ifeq ($(KERNEL_NAME), SunOS)
|
||||
CC := gcc
|
||||
CFLAGS += -D_REENTRANT
|
||||
LIB_EXT := so
|
||||
LIB_CFLAGS := -shared -fPIC
|
||||
PC_EXTRA_LIBS ?=
|
||||
endif
|
||||
|
||||
ifeq ($(KERNEL_NAME), Linux)
|
||||
ifeq ($(CC), clang)
|
||||
CI_CFLAGS += -fsanitize=address -fsanitize=undefined
|
||||
endif
|
||||
endif
|
||||
|
||||
LIB_SH := lib$(LIB_NAME).$(LIB_EXT)
|
||||
LIB_ST := lib$(LIB_NAME).a
|
||||
|
||||
ifdef LINKED_LIB_EXT
|
||||
LINKED_LIB_SH := lib$(LIB_NAME).$(LINKED_LIB_EXT)
|
||||
endif
|
||||
|
||||
# Some systems don't provide an unprefixed ar when cross-compiling.
|
||||
AR=ar
|
||||
|
||||
LIBRARIES = $(LIB_SH) $(LIB_ST)
|
||||
HEADERS = include/argon2.h
|
||||
|
||||
INSTALL = install
|
||||
|
||||
# relative paths for different OS
|
||||
ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),DragonFly FreeBSD))
|
||||
|
||||
# default for FreeBSD
|
||||
BINARY_REL ?= bin
|
||||
INCLUDE_REL ?= include
|
||||
LIBRARY_REL ?= lib
|
||||
PKGCONFIG_REL ?= libdata
|
||||
|
||||
else ifeq ($(KERNEL_NAME)-$(MACHINE_NAME), Linux-x86_64)
|
||||
|
||||
# default for Debian/Ubuntu x86_64
|
||||
BINARY_REL ?= bin
|
||||
INCLUDE_REL ?= include
|
||||
LIBRARY_REL ?= lib/x86_64-linux-gnu
|
||||
PKGCONFIG_REL ?= $(LIBRARY_REL)
|
||||
|
||||
else
|
||||
|
||||
# NetBSD, ... and Linux64/Linux32 variants that use plain lib directory
|
||||
BINARY_REL ?= bin
|
||||
INCLUDE_REL ?= include
|
||||
LIBRARY_REL ?= lib
|
||||
PKGCONFIG_REL ?= $(LIBRARY_REL)
|
||||
|
||||
endif
|
||||
|
||||
# absolute paths to staging area
|
||||
INST_INCLUDE = $(DESTDIR)$(PREFIX)/$(INCLUDE_REL)
|
||||
INST_LIBRARY = $(DESTDIR)$(PREFIX)/$(LIBRARY_REL)
|
||||
INST_BINARY = $(DESTDIR)$(PREFIX)/$(BINARY_REL)
|
||||
INST_PKGCONFIG = $(DESTDIR)$(PREFIX)/$(PKGCONFIG_REL)/pkgconfig
|
||||
|
||||
# main target
|
||||
.PHONY: all
|
||||
all: $(RUN) libs
|
||||
|
||||
.PHONY: libs
|
||||
libs: $(LIBRARIES) $(PC_NAME)
|
||||
|
||||
$(RUN): $(SRC) $(SRC_RUN)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BENCH): $(SRC) $(SRC_BENCH)
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
$(GENKAT): $(SRC) $(SRC_GENKAT)
|
||||
$(CC) $(CFLAGS) $^ -o $@ -DGENKAT
|
||||
|
||||
$(LIB_SH): $(SRC)
|
||||
$(CC) $(CFLAGS) $(LIB_CFLAGS) $(LDFLAGS) $(SO_LDFLAGS) $^ -o $@
|
||||
|
||||
$(LIB_ST): $(OBJ)
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f '$(RUN)' '$(BENCH)' '$(GENKAT)'
|
||||
rm -f '$(LIB_SH)' '$(LIB_ST)' kat-argon2* '$(PC_NAME)'
|
||||
rm -f testcase
|
||||
rm -rf *.dSYM
|
||||
cd src/ && rm -f *.o
|
||||
cd src/blake2/ && rm -f *.o
|
||||
cd kats/ && rm -f kat-* diff* run_* make_*
|
||||
|
||||
|
||||
# all substitutions to pc template
|
||||
SED_COMMANDS = /^\#\#.*$$/d;
|
||||
SED_COMMANDS += s\#@PREFIX@\#$(PREFIX)\#g;
|
||||
SED_COMMANDS += s\#@EXTRA_LIBS@\#$(PC_EXTRA_LIBS)\#g;
|
||||
SED_COMMANDS += s\#@UPSTREAM_VER@\#$(ARGON2_VERSION)\#g;
|
||||
SED_COMMANDS += s\#@HOST_MULTIARCH@\#$(LIBRARY_REL)\#g;
|
||||
SED_COMMANDS += s\#@INCLUDE@\#$(INCLUDE_REL)\#g;
|
||||
|
||||
# substitute PREFIX and PC_EXTRA_LIBS into pkgconfig pc file
|
||||
$(PC_NAME): $(PC_SRC)
|
||||
sed '$(SED_COMMANDS)' < '$(PC_SRC)' > '$@'
|
||||
|
||||
|
||||
.PHONY: dist
|
||||
dist:
|
||||
cd ..; \
|
||||
tar -c --exclude='.??*' -z -f $(DIST)-`date "+%Y%m%d"`.tgz $(DIST)/*
|
||||
|
||||
.PHONY: test
|
||||
test: $(SRC) src/test.c
|
||||
$(CC) $(CFLAGS) -Wextra -Wno-type-limits $^ -o testcase
|
||||
@sh kats/test.sh
|
||||
./testcase
|
||||
|
||||
.PHONY: testci
|
||||
testci: $(SRC) src/test.c
|
||||
$(CC) $(CI_CFLAGS) $^ -o testcase
|
||||
@sh kats/test.sh
|
||||
./testcase
|
||||
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4}" \
|
||||
-i include/*.h src/*.c src/*.h src/blake2/*.c src/blake2/*.h
|
||||
|
||||
.PHONY: install
|
||||
install: $(RUN) libs
|
||||
$(INSTALL) -d $(INST_INCLUDE)
|
||||
$(INSTALL) -m 0644 $(HEADERS) $(INST_INCLUDE)
|
||||
$(INSTALL) -d $(INST_LIBRARY)
|
||||
$(INSTALL) -m 0644 $(LIBRARIES) $(INST_LIBRARY)
|
||||
ifdef LINKED_LIB_SH
|
||||
cd $(INST_LIBRARY) && ln -sf $(notdir $(LIB_SH) $(LINKED_LIB_SH))
|
||||
endif
|
||||
$(INSTALL) -d $(INST_BINARY)
|
||||
$(INSTALL) $(RUN) $(INST_BINARY)
|
||||
$(INSTALL) -d $(INST_PKGCONFIG)
|
||||
$(INSTALL) -m 0644 $(PC_NAME) $(INST_PKGCONFIG)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
cd $(INST_INCLUDE) && rm -f $(notdir $(HEADERS))
|
||||
cd $(INST_LIBRARY) && rm -f $(notdir $(LIBRARIES) $(LINKED_LIB_SH))
|
||||
cd $(INST_BINARY) && rm -f $(notdir $(RUN))
|
||||
cd $(INST_PKG_CONFIG) && rm -f $(notdir $(PC_NAME))
|
||||
@@ -1,46 +0,0 @@
|
||||
// swift-tools-version:5.3
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "argon2",
|
||||
products: [
|
||||
.library(
|
||||
name: "argon2",
|
||||
targets: ["argon2"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "argon2",
|
||||
path: ".",
|
||||
exclude: [
|
||||
"kats",
|
||||
"vs2015",
|
||||
"latex",
|
||||
"libargon2.pc.in",
|
||||
"export.sh",
|
||||
"appveyor.yml",
|
||||
"Argon2.sln",
|
||||
"argon2-specs.pdf",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"Makefile",
|
||||
"man",
|
||||
"README.md",
|
||||
"src/bench.c",
|
||||
"src/genkat.c",
|
||||
"src/opt.c",
|
||||
"src/run.c",
|
||||
"src/test.c",
|
||||
],
|
||||
sources: [
|
||||
"src/blake2/blake2b.c",
|
||||
"src/argon2.c",
|
||||
"src/core.c",
|
||||
"src/encoding.c",
|
||||
"src/ref.c",
|
||||
"src/thread.c"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -1,303 +0,0 @@
|
||||
# Argon2
|
||||
|
||||
[](https://travis-ci.org/P-H-C/phc-winner-argon2)
|
||||
[](https://ci.appveyor.com/project/P-H-C/phc-winner-argon2)
|
||||
[](https://codecov.io/github/P-H-C/phc-winner-argon2?branch=master)
|
||||
|
||||
This is the reference C implementation of Argon2, the password-hashing
|
||||
function that won the [Password Hashing Competition
|
||||
(PHC)](https://password-hashing.net).
|
||||
|
||||
Argon2 is a password-hashing function that summarizes the state of the
|
||||
art in the design of memory-hard functions and can be used to hash
|
||||
passwords for credential storage, key derivation, or other applications.
|
||||
|
||||
It has a simple design aimed at the highest memory filling rate and
|
||||
effective use of multiple computing units, while still providing defense
|
||||
against tradeoff attacks (by exploiting the cache and memory organization
|
||||
of the recent processors).
|
||||
|
||||
Argon2 has three variants: Argon2i, Argon2d, and Argon2id. Argon2d is faster
|
||||
and uses data-depending memory access, which makes it highly resistant
|
||||
against GPU cracking attacks and suitable for applications with no threats
|
||||
from side-channel timing attacks (eg. cryptocurrencies). Argon2i instead
|
||||
uses data-independent memory access, which is preferred for password
|
||||
hashing and password-based key derivation, but it is slower as it makes
|
||||
more passes over the memory to protect from tradeoff attacks. Argon2id is a
|
||||
hybrid of Argon2i and Argon2d, using a combination of data-depending and
|
||||
data-independent memory accesses, which gives some of Argon2i's resistance to
|
||||
side-channel cache timing attacks and much of Argon2d's resistance to GPU
|
||||
cracking attacks.
|
||||
|
||||
Argon2i, Argon2d, and Argon2id are parametrized by:
|
||||
|
||||
* A **time** cost, which defines the amount of computation realized and
|
||||
therefore the execution time, given in number of iterations
|
||||
* A **memory** cost, which defines the memory usage, given in kibibytes
|
||||
* A **parallelism** degree, which defines the number of parallel threads
|
||||
|
||||
The [Argon2 document](argon2-specs.pdf) gives detailed specs and design
|
||||
rationale.
|
||||
|
||||
Please report bugs as issues on this repository.
|
||||
|
||||
## Usage
|
||||
|
||||
`make` builds the executable `argon2`, the static library `libargon2.a`,
|
||||
and the shared library `libargon2.so` (or on macOS, the dynamic library
|
||||
`libargon2.dylib` -- make sure to specify the installation prefix when
|
||||
you compile: `make PREFIX=/usr`). Make sure to run `make test` to verify
|
||||
that your build produces valid results. `sudo make install PREFIX=/usr`
|
||||
installs it to your system.
|
||||
|
||||
### Command-line utility
|
||||
|
||||
`argon2` is a command-line utility to test specific Argon2 instances
|
||||
on your system. To show usage instructions, run
|
||||
`./argon2 -h` as
|
||||
```
|
||||
Usage: ./argon2 [-h] salt [-i|-d|-id] [-t iterations] [-m memory] [-p parallelism] [-l hash length] [-e|-r] [-v (10|13)]
|
||||
Password is read from stdin
|
||||
Parameters:
|
||||
salt The salt to use, at least 8 characters
|
||||
-i Use Argon2i (this is the default)
|
||||
-d Use Argon2d instead of Argon2i
|
||||
-id Use Argon2id instead of Argon2i
|
||||
-t N Sets the number of iterations to N (default = 3)
|
||||
-m N Sets the memory usage of 2^N KiB (default 12)
|
||||
-p N Sets parallelism to N threads (default 1)
|
||||
-l N Sets hash output length to N bytes (default 32)
|
||||
-e Output only encoded hash
|
||||
-r Output only the raw bytes of the hash
|
||||
-v (10|13) Argon2 version (defaults to the most recent version, currently 13)
|
||||
-h Print argon2 usage
|
||||
```
|
||||
For example, to hash "password" using "somesalt" as a salt and doing 2
|
||||
iterations, consuming 64 MiB, using four parallel threads and an output hash
|
||||
of 24 bytes
|
||||
```
|
||||
$ echo -n "password" | ./argon2 somesalt -t 2 -m 16 -p 4 -l 24
|
||||
Type: Argon2i
|
||||
Iterations: 2
|
||||
Memory: 65536 KiB
|
||||
Parallelism: 4
|
||||
Hash: 45d7ac72e76f242b20b77b9bf9bf9d5915894e669a24e6c6
|
||||
Encoded: $argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG
|
||||
0.188 seconds
|
||||
Verification ok
|
||||
```
|
||||
|
||||
### Library
|
||||
|
||||
`libargon2` provides an API to both low-level and high-level functions
|
||||
for using Argon2.
|
||||
|
||||
The example program below hashes the string "password" with Argon2i
|
||||
using the high-level API and then using the low-level API. While the
|
||||
high-level API takes the three cost parameters (time, memory, and
|
||||
parallelism), the password input buffer, the salt input buffer, and the
|
||||
output buffers, the low-level API takes in these and additional parameters
|
||||
, as defined in [`include/argon2.h`](include/argon2.h).
|
||||
|
||||
There are many additional parameters, but we will highlight three of them here.
|
||||
|
||||
1. The `secret` parameter, which is used for [keyed hashing](
|
||||
https://en.wikipedia.org/wiki/Hash-based_message_authentication_code).
|
||||
This allows a secret key to be input at hashing time (from some external
|
||||
location) and be folded into the value of the hash. This means that even if
|
||||
your salts and hashes are compromised, an attacker cannot brute-force to find
|
||||
the password without the key.
|
||||
|
||||
2. The `ad` parameter, which is used to fold any additional data into the hash
|
||||
value. Functionally, this behaves almost exactly like the `secret` or `salt`
|
||||
parameters; the `ad` parameter is folding into the value of the hash.
|
||||
However, this parameter is used for different data. The `salt` should be a
|
||||
random string stored alongside your password. The `secret` should be a random
|
||||
key only usable at hashing time. The `ad` is for any other data.
|
||||
|
||||
3. The `flags` parameter, which determines which memory should be securely
|
||||
erased. This is useful if you want to securely delete the `pwd` or `secret`
|
||||
fields right after they are used. To do this set `flags` to either
|
||||
`ARGON2_FLAG_CLEAR_PASSWORD` or `ARGON2_FLAG_CLEAR_SECRET`. To change how
|
||||
internal memory is cleared, change the global flag
|
||||
`FLAG_clear_internal_memory` (defaults to clearing internal memory).
|
||||
|
||||
Here the time cost `t_cost` is set to 2 iterations, the
|
||||
memory cost `m_cost` is set to 2<sup>16</sup> kibibytes (64 mebibytes),
|
||||
and parallelism is set to 1 (single-thread).
|
||||
|
||||
Compile for example as `gcc test.c libargon2.a -Isrc -o test`, if the program
|
||||
below is named `test.c` and placed in the project's root directory.
|
||||
|
||||
```c
|
||||
#include "argon2.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define HASHLEN 32
|
||||
#define SALTLEN 16
|
||||
#define PWD "password"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uint8_t hash1[HASHLEN];
|
||||
uint8_t hash2[HASHLEN];
|
||||
|
||||
uint8_t salt[SALTLEN];
|
||||
memset( salt, 0x00, SALTLEN );
|
||||
|
||||
uint8_t *pwd = (uint8_t *)strdup(PWD);
|
||||
uint32_t pwdlen = strlen((char *)pwd);
|
||||
|
||||
uint32_t t_cost = 2; // 2-pass computation
|
||||
uint32_t m_cost = (1<<16); // 64 mebibytes memory usage
|
||||
uint32_t parallelism = 1; // number of threads and lanes
|
||||
|
||||
// high-level API
|
||||
argon2i_hash_raw(t_cost, m_cost, parallelism, pwd, pwdlen, salt, SALTLEN, hash1, HASHLEN);
|
||||
|
||||
// low-level API
|
||||
argon2_context context = {
|
||||
hash2, /* output array, at least HASHLEN in size */
|
||||
HASHLEN, /* digest length */
|
||||
pwd, /* password array */
|
||||
pwdlen, /* password length */
|
||||
salt, /* salt array */
|
||||
SALTLEN, /* salt length */
|
||||
NULL, 0, /* optional secret data */
|
||||
NULL, 0, /* optional associated data */
|
||||
t_cost, m_cost, parallelism, parallelism,
|
||||
ARGON2_VERSION_13, /* algorithm version */
|
||||
NULL, NULL, /* custom memory allocation / deallocation functions */
|
||||
/* by default only internal memory is cleared (pwd is not wiped) */
|
||||
ARGON2_DEFAULT_FLAGS
|
||||
};
|
||||
|
||||
int rc = argon2i_ctx( &context );
|
||||
if(ARGON2_OK != rc) {
|
||||
printf("Error: %s\n", argon2_error_message(rc));
|
||||
exit(1);
|
||||
}
|
||||
free(pwd);
|
||||
|
||||
for( int i=0; i<HASHLEN; ++i ) printf( "%02x", hash1[i] ); printf( "\n" );
|
||||
if (memcmp(hash1, hash2, HASHLEN)) {
|
||||
for( int i=0; i<HASHLEN; ++i ) {
|
||||
printf( "%02x", hash2[i] );
|
||||
}
|
||||
printf("\nfail\n");
|
||||
}
|
||||
else printf("ok\n");
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
To use Argon2d instead of Argon2i call `argon2d_hash_raw` instead of
|
||||
`argon2i_hash_raw` using the high-level API, and `argon2d` instead of
|
||||
`argon2i` using the low-level API. Similarly for Argon2id, call `argon2id_hash_raw`
|
||||
and `argon2id`.
|
||||
|
||||
To produce the crypt-like encoding rather than the raw hash, call
|
||||
`argon2i_hash_encoded` for Argon2i, `argon2d_hash_encoded` for Argon2d, and
|
||||
`argon2id_hash_encoded` for Argon2id
|
||||
|
||||
See [`include/argon2.h`](include/argon2.h) for API details.
|
||||
|
||||
*Note: in this example the salt is set to the all-`0x00` string for the
|
||||
sake of simplicity, but in your application you should use a random salt.*
|
||||
|
||||
|
||||
### Benchmarks
|
||||
|
||||
`make bench` creates the executable `bench`, which measures the execution
|
||||
time of various Argon2 instances:
|
||||
|
||||
```
|
||||
$ ./bench
|
||||
Argon2d 1 iterations 1 MiB 1 threads: 5.91 cpb 5.91 Mcycles
|
||||
Argon2i 1 iterations 1 MiB 1 threads: 4.64 cpb 4.64 Mcycles
|
||||
0.0041 seconds
|
||||
|
||||
Argon2d 1 iterations 1 MiB 2 threads: 2.76 cpb 2.76 Mcycles
|
||||
Argon2i 1 iterations 1 MiB 2 threads: 2.87 cpb 2.87 Mcycles
|
||||
0.0038 seconds
|
||||
|
||||
Argon2d 1 iterations 1 MiB 4 threads: 3.25 cpb 3.25 Mcycles
|
||||
Argon2i 1 iterations 1 MiB 4 threads: 3.57 cpb 3.57 Mcycles
|
||||
0.0048 seconds
|
||||
|
||||
(...)
|
||||
|
||||
Argon2d 1 iterations 4096 MiB 2 threads: 2.15 cpb 8788.08 Mcycles
|
||||
Argon2i 1 iterations 4096 MiB 2 threads: 2.15 cpb 8821.59 Mcycles
|
||||
13.0112 seconds
|
||||
|
||||
Argon2d 1 iterations 4096 MiB 4 threads: 1.79 cpb 7343.72 Mcycles
|
||||
Argon2i 1 iterations 4096 MiB 4 threads: 2.72 cpb 11124.86 Mcycles
|
||||
19.3974 seconds
|
||||
|
||||
(...)
|
||||
```
|
||||
|
||||
## Bindings
|
||||
|
||||
Bindings are available for the following languages (make sure to read
|
||||
their documentation):
|
||||
|
||||
* [Android (Java/Kotlin)](https://github.com/lambdapioneer/argon2kt) by [@lambdapioneer](https://github.com/lambdapioneer)
|
||||
* [Dart](https://github.com/tmthecoder/dargon2) by [@tmthecoder](https://github.com/tmthecoder)
|
||||
* [Elixir](https://github.com/riverrun/argon2_elixir) by [@riverrun](https://github.com/riverrun)
|
||||
* [Erlang](https://github.com/ergenius/eargon2) by [@ergenius](https://github.com/ergenius)
|
||||
* [Go](https://github.com/tvdburgt/go-argon2) by [@tvdburgt](https://github.com/tvdburgt)
|
||||
* [Haskell](https://hackage.haskell.org/package/argon2) by [@hvr](https://github.com/hvr)
|
||||
* [JavaScript (native)](https://github.com/ranisalt/node-argon2), by [@ranisalt](https://github.com/ranisalt)
|
||||
* [JavaScript (native)](https://github.com/jdconley/argon2themax), by [@jdconley](https://github.com/jdconley)
|
||||
* [JavaScript (ffi)](https://github.com/cjlarose/argon2-ffi), by [@cjlarose](https://github.com/cjlarose)
|
||||
* [JavaScript (browser)](https://github.com/antelle/argon2-browser), by [@antelle](https://github.com/antelle)
|
||||
* [JVM](https://github.com/phxql/argon2-jvm) by [@phXql](https://github.com/phxql)
|
||||
* [JVM (with keyed hashing)](https://github.com/kosprov/jargon2-api) by [@kosprov](https://github.com/kosprov)
|
||||
* [Lua (native)](https://github.com/thibaultCha/lua-argon2) by [@thibaultCha](https://github.com/thibaultCha)
|
||||
* [Lua (ffi)](https://github.com/thibaultCha/lua-argon2-ffi) by [@thibaultCha](https://github.com/thibaultCha)
|
||||
* [OCaml](https://github.com/Khady/ocaml-argon2) by [@Khady](https://github.com/Khady)
|
||||
* [Python (native)](https://pypi.python.org/pypi/argon2), by [@flamewow](https://github.com/flamewow)
|
||||
* [Python (ffi)](https://pypi.python.org/pypi/argon2_cffi), by [@hynek](https://github.com/hynek)
|
||||
* [Python (ffi, with keyed hashing)](https://github.com/thusoy/porridge), by [@thusoy](https://github.com/thusoy)
|
||||
* [Python (ffi, with keyed hashing)](https://github.com/ultrahorizon/pyargon2), by [@ultrahorizon](https://github.com/ultrahorizon)
|
||||
* [R](https://cran.r-project.org/package=argon2) by [@wrathematics](https://github.com/wrathematics)
|
||||
* [Ruby](https://github.com/technion/ruby-argon2) by [@technion](https://github.com/technion)
|
||||
* [Rust](https://github.com/quininer/argon2-rs) by [@quininer](https://github.com/quininer)
|
||||
* [Rust](https://docs.rs/argonautica/) by [@bcmyers](https://github.com/bcmyers/)
|
||||
* [C#/.NET CoreCLR](https://github.com/kmaragon/Konscious.Security.Cryptography) by [@kmaragon](https://github.com/kmaragon)
|
||||
* [Perl](https://github.com/Leont/crypt-argon2) by [@leont](https://github.com/Leont)
|
||||
* [mruby](https://github.com/Asmod4n/mruby-argon2) by [@Asmod4n](https://github.com/Asmod4n)
|
||||
* [Swift](https://github.com/ImKcat/CatCrypto) by [@ImKcat](https://github.com/ImKcat)
|
||||
* [Swift](https://github.com/tmthecoder/Argon2Swift) by [@tmthecoder](https://github.com/tmthecoder)
|
||||
|
||||
|
||||
## Test suite
|
||||
|
||||
There are two sets of test suites. One is a low level test for the hash
|
||||
function, the other tests the higher level API. Both of these are built and
|
||||
executed by running:
|
||||
|
||||
`make test`
|
||||
|
||||
## Intellectual property
|
||||
|
||||
Except for the components listed below, the Argon2 code in this
|
||||
repository is copyright (c) 2015 Daniel Dinu, Dmitry Khovratovich (main
|
||||
authors), Jean-Philippe Aumasson and Samuel Neves, and dual licensed under the
|
||||
[CC0 License](https://creativecommons.org/about/cc0) and the
|
||||
[Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For more info
|
||||
see the LICENSE file.
|
||||
|
||||
The string encoding routines in [`src/encoding.c`](src/encoding.c) are
|
||||
copyright (c) 2015 Thomas Pornin, and under
|
||||
[CC0 License](https://creativecommons.org/about/cc0).
|
||||
|
||||
The BLAKE2 code in [`src/blake2/`](src/blake2) is copyright (c) Samuel
|
||||
Neves, 2013-2015, and under
|
||||
[CC0 License](https://creativecommons.org/about/cc0).
|
||||
|
||||
All licenses are therefore GPL-compatible.
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
73619cfe0f35e52fdd1ca2595ffaa359879467407f98b61f4969c2861cc329ce argon2d
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
4ec4569a016c3accc6a25a34252b03a6135939b3c452389917a3f3b65878165b argon2d_v16
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
40a3aeafb092d10cf457a8ee0139c114c911ecf97bd5accf5a99c7ddd6917061 argon2i
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
334f03e627afb67b946a530b90d2e11fb2e6abb44df992c0fb3198c7bacf5930 argon2i_v16
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
ba05643e504fc5778dda99e2d9f42ebe7d22ebb3923cc719fd591b1b14a8d28d argon2id
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
680774be1d3ad2e74bbc56ee715dd6eb97a58279bf22edc57d00e840ca1ae469 argon2id_v16
|
||||
@@ -1,42 +0,0 @@
|
||||
Set-Variable tempfile -option Constant -value "tempfile"
|
||||
|
||||
function hash($path) {
|
||||
$fullPath = Resolve-Path $path
|
||||
$hash = new-object -TypeName System.Security.Cryptography.SHA256CryptoServiceProvider
|
||||
|
||||
$contents = [IO.File]::ReadAllText($fullPath) -replace "`r`n?", "`n"
|
||||
# create UTF-8 encoding without signature
|
||||
$utf8 = New-Object System.Text.UTF8Encoding $false
|
||||
# write the text back
|
||||
[IO.File]::WriteAllText($tempfile, $contents, $utf8)
|
||||
|
||||
$file = [System.IO.File]::Open($tempfile,[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read)
|
||||
$result = [System.BitConverter]::ToString($hash.ComputeHash($file))
|
||||
$file.Dispose()
|
||||
|
||||
if (Test-Path $tempfile) {
|
||||
Remove-Item $tempfile
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function main() {
|
||||
$files = $(Get-ChildItem * | Where-Object { $_.Name -match '^[a-z2]*(_v)?[0-9]*$' } | select -ExpandProperty name)
|
||||
|
||||
foreach ($file in $files) {
|
||||
$new = $(hash $file).replace("-","")
|
||||
$new = $new.ToLower()
|
||||
|
||||
$old=$(Get-Content $file".shasum")
|
||||
$old = $old.Substring(0, $old.IndexOf(" "))
|
||||
|
||||
if ($new -eq $old) {
|
||||
Write-Host $file "`tOK"
|
||||
} else {
|
||||
Write-Host $file "`tERROR"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
for file in `ls | grep '^[a-z2]*\(_v\)\?[0-9]*$' | xargs`
|
||||
do
|
||||
new=`shasum -a 256 $file`
|
||||
old=`cat $file.shasum`
|
||||
if [ "$new" = "$old" ]
|
||||
then
|
||||
echo $file "\t" OK
|
||||
else
|
||||
echo $file "\t" ERROR
|
||||
fi
|
||||
done
|
||||
@@ -1,50 +0,0 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Set-Variable tempfile -option Constant -value "tempfile"
|
||||
|
||||
function CompareFiles($f1, $f2, $i) {
|
||||
$f1_content = $(Get-Content $f1)
|
||||
$f2_content = $(Get-Content $f2)
|
||||
|
||||
if (Compare-Object $f1_content $f2_content) {
|
||||
Write-Host -NoNewline "ERROR"
|
||||
exit $i
|
||||
} else {
|
||||
Write-Host -NoNewline "OK"
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
$i = 0
|
||||
foreach ($opt in @("Ref", "Opt")) {
|
||||
Write-Output "$opt"
|
||||
|
||||
foreach ($version in @(16, 19)) {
|
||||
foreach ($type in @("i", "d", "id")) {
|
||||
$i++
|
||||
|
||||
if ("Ref" -eq $opt) {
|
||||
vs2015\build\Argon2RefGenKAT.exe $type $version > $tempfile
|
||||
} else {
|
||||
vs2015\build\Argon2OptGenKAT.exe $type $version > $tempfile
|
||||
}
|
||||
|
||||
if (19 -eq $version) {
|
||||
$kats = "kats\argon2" + $type
|
||||
} else {
|
||||
$kats = "kats\argon2" + $type + "_v" + $version
|
||||
}
|
||||
|
||||
Write-Host -NoNewline "Argon2$type v=$version : "
|
||||
CompareFiles $tempfile $kats $i
|
||||
Write-Output ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Path $tempfile) {
|
||||
Remove-Item $tempfile
|
||||
}
|
||||
}
|
||||
|
||||
main
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
for opttest in "" "OPTTEST=1"
|
||||
do
|
||||
if [ "" = "$opttest" ]
|
||||
then
|
||||
printf "Default build\n"
|
||||
else
|
||||
printf "Force OPTTEST=1\n"
|
||||
fi
|
||||
|
||||
make genkat $opttest > /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
exit $?
|
||||
fi
|
||||
|
||||
i=0
|
||||
for version in 16 19
|
||||
do
|
||||
for type in i d id
|
||||
do
|
||||
i=$(($i+1))
|
||||
|
||||
printf "argon2$type v=$version: "
|
||||
|
||||
if [ 19 -eq $version ]
|
||||
then
|
||||
kats="kats/argon2"$type
|
||||
else
|
||||
kats="kats/argon2"$type"_v"$version
|
||||
fi
|
||||
|
||||
./genkat $type $version > tmp
|
||||
if diff tmp $kats
|
||||
then
|
||||
printf "OK"
|
||||
else
|
||||
printf "ERROR"
|
||||
exit $i
|
||||
fi
|
||||
printf "\n"
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
rm -f tmp
|
||||
|
||||
exit 0
|
||||
@@ -1,13 +0,0 @@
|
||||
# libargon2 info for pkg-config
|
||||
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib/x86_64-linux-gnu
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libargon2
|
||||
Description: Development libraries for libargon2
|
||||
Version: ZERO
|
||||
Libs: -L${libdir} -largon2 -lrt -ldl
|
||||
Cflags: -I${includedir}
|
||||
URL: https://github.com/P-H-C/phc-winner-argon2
|
||||
@@ -1,18 +0,0 @@
|
||||
# libargon2 info for pkg-config
|
||||
## Template for downstream installers:
|
||||
## - replace @UPSTREAM_VER@ with current version, e.g. '20160406'
|
||||
## - replace @HOST_MULTIARCH@ with target arch lib, e.g. 'lib', 'lib/x86_64-linux-gnu' or 'lib64'
|
||||
## - replace @PREFIX@ with install path, e.g. '/usr', '/usr/local', '/usr/pkg'
|
||||
## - replace @INCLUDE@ with include path, e.g. 'include' or 'include/argon2'
|
||||
|
||||
prefix=@PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@HOST_MULTIARCH@
|
||||
includedir=${prefix}/@INCLUDE@
|
||||
|
||||
Name: libargon2
|
||||
Description: Development libraries for libargon2
|
||||
Version: @UPSTREAM_VER@
|
||||
Libs: -L${libdir} -largon2 @EXTRA_LIBS@
|
||||
Cflags: -I${includedir}
|
||||
URL: https://github.com/P-H-C/phc-winner-argon2
|
||||
Binary file not shown.
@@ -1,57 +0,0 @@
|
||||
.TH ARGON2 "1" "April 2016" "argon2 " "User Commands"
|
||||
|
||||
.SH NAME
|
||||
argon2 \- generate argon2 hashes
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B argon2 salt
|
||||
.RB [ OPTIONS ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
Generate Argon2 hashes from the command line.
|
||||
|
||||
The supplied salt (the first argument to the command) must be at least
|
||||
8 octets in length, and the password is supplied on standard input.
|
||||
|
||||
By default, this uses Argon2i variant (where memory access is
|
||||
independent of secret data) which is the preferred one for password
|
||||
hashing and password-based key derivation.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-h
|
||||
Display tool usage
|
||||
.TP
|
||||
.B \-d
|
||||
Use Argon2d instead of Argon2i (Argon2i is the default)
|
||||
.TP
|
||||
.B \-id
|
||||
Use Argon2id instead of Argon2i (Argon2i is the default)
|
||||
.TP
|
||||
.BI \-t " N"
|
||||
Sets the number of iterations to N (default = 3)
|
||||
.TP
|
||||
.BI \-m " N"
|
||||
Sets the memory usage of 2^N KiB (default = 12)
|
||||
.TP
|
||||
.BI \-p " N"
|
||||
Sets parallelism to N threads (default = 1)
|
||||
.TP
|
||||
.BI \-l " N"
|
||||
Sets hash output length to N bytes (default = 32)
|
||||
.TP
|
||||
.B \-e
|
||||
Output only encoded hash
|
||||
.TP
|
||||
.B \-r
|
||||
Output only the raw bytes of the hash
|
||||
.TP
|
||||
.B \-v (10|13)
|
||||
Argon2 version (defaults to the most recent version, currently 13)
|
||||
|
||||
.SH COPYRIGHT
|
||||
This manpage was written by \fBDaniel Kahn Gillmor\fR for the Debian
|
||||
distribution (but may be used by others). It is released, like the
|
||||
rest of this Argon2 implementation, under a dual license. You may use this work
|
||||
under the terms of a Creative Commons CC0 1.0 License/Waiver or the Apache
|
||||
Public License 2.0, at your option.
|
||||
Binary file not shown.
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef _WIN32
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
#include "argon2.h"
|
||||
|
||||
static uint64_t rdtsc(void) {
|
||||
#ifdef _WIN32
|
||||
return __rdtsc();
|
||||
#else
|
||||
#if defined(__amd64__) || defined(__x86_64__)
|
||||
uint64_t rax, rdx;
|
||||
__asm__ __volatile__("rdtsc" : "=a"(rax), "=d"(rdx) : :);
|
||||
return (rdx << 32) | rax;
|
||||
#elif defined(__i386__) || defined(__i386) || defined(__X86__)
|
||||
uint64_t rax;
|
||||
__asm__ __volatile__("rdtsc" : "=A"(rax) : :);
|
||||
return rax;
|
||||
#else
|
||||
#error "Not implemented!"
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Benchmarks Argon2 with salt length 16, password length 16, t_cost 3,
|
||||
and different m_cost and threads
|
||||
*/
|
||||
static void benchmark() {
|
||||
#define BENCH_OUTLEN 16
|
||||
#define BENCH_INLEN 16
|
||||
const uint32_t inlen = BENCH_INLEN;
|
||||
const unsigned outlen = BENCH_OUTLEN;
|
||||
unsigned char out[BENCH_OUTLEN];
|
||||
unsigned char pwd_array[BENCH_INLEN];
|
||||
unsigned char salt_array[BENCH_INLEN];
|
||||
#undef BENCH_INLEN
|
||||
#undef BENCH_OUTLEN
|
||||
|
||||
uint32_t t_cost = 3;
|
||||
uint32_t m_cost;
|
||||
uint32_t thread_test[4] = {1, 2, 4, 8};
|
||||
argon2_type types[3] = {Argon2_i, Argon2_d, Argon2_id};
|
||||
|
||||
memset(pwd_array, 0, inlen);
|
||||
memset(salt_array, 1, inlen);
|
||||
|
||||
for (m_cost = (uint32_t)1 << 10; m_cost <= (uint32_t)1 << 22; m_cost *= 2) {
|
||||
unsigned i;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
double run_time = 0;
|
||||
uint32_t thread_n = thread_test[i];
|
||||
|
||||
unsigned j;
|
||||
for (j = 0; j < 3; ++j) {
|
||||
clock_t start_time, stop_time;
|
||||
uint64_t start_cycles, stop_cycles;
|
||||
uint64_t delta;
|
||||
double mcycles;
|
||||
|
||||
argon2_type type = types[j];
|
||||
start_time = clock();
|
||||
start_cycles = rdtsc();
|
||||
|
||||
argon2_hash(t_cost, m_cost, thread_n, pwd_array, inlen,
|
||||
salt_array, inlen, out, outlen, NULL, 0, type,
|
||||
ARGON2_VERSION_NUMBER);
|
||||
|
||||
stop_cycles = rdtsc();
|
||||
stop_time = clock();
|
||||
|
||||
delta = (stop_cycles - start_cycles) / (m_cost);
|
||||
mcycles = (double)(stop_cycles - start_cycles) / (1UL << 20);
|
||||
run_time += ((double)stop_time - start_time) / (CLOCKS_PER_SEC);
|
||||
|
||||
printf("%s %d iterations %d MiB %d threads: %2.2f cpb %2.2f "
|
||||
"Mcycles \n", argon2_type2string(type, 1), t_cost,
|
||||
m_cost >> 10, thread_n, (float)delta / 1024, mcycles);
|
||||
}
|
||||
|
||||
printf("%2.4f seconds\n\n", run_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
benchmark();
|
||||
return ARGON2_OK;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "argon2.h"
|
||||
#include "core.h"
|
||||
#ifdef __MINGW32__
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
/* Don't use <inttypes.h> (it's not C89) */
|
||||
#define PRIx64 "llx"
|
||||
#endif
|
||||
|
||||
void initial_kat(const uint8_t *blockhash, const argon2_context *context,
|
||||
argon2_type type) {
|
||||
unsigned i;
|
||||
|
||||
if (blockhash != NULL && context != NULL) {
|
||||
printf("=======================================\n");
|
||||
|
||||
printf("%s version number %d\n", argon2_type2string(type, 1),
|
||||
context->version);
|
||||
|
||||
printf("=======================================\n");
|
||||
|
||||
|
||||
printf("Memory: %u KiB, Iterations: %u, Parallelism: %u lanes, Tag "
|
||||
"length: %u bytes\n",
|
||||
context->m_cost, context->t_cost, context->lanes,
|
||||
context->outlen);
|
||||
|
||||
printf("Password[%u]: ", context->pwdlen);
|
||||
|
||||
if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) {
|
||||
printf("CLEARED\n");
|
||||
} else {
|
||||
for (i = 0; i < context->pwdlen; ++i) {
|
||||
printf("%2.2x ", ((unsigned char *)context->pwd)[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("Salt[%u]: ", context->saltlen);
|
||||
|
||||
for (i = 0; i < context->saltlen; ++i) {
|
||||
printf("%2.2x ", ((unsigned char *)context->salt)[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("Secret[%u]: ", context->secretlen);
|
||||
|
||||
if (context->flags & ARGON2_FLAG_CLEAR_SECRET) {
|
||||
printf("CLEARED\n");
|
||||
} else {
|
||||
for (i = 0; i < context->secretlen; ++i) {
|
||||
printf("%2.2x ", ((unsigned char *)context->secret)[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("Associated data[%u]: ", context->adlen);
|
||||
|
||||
for (i = 0; i < context->adlen; ++i) {
|
||||
printf("%2.2x ", ((unsigned char *)context->ad)[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("Pre-hashing digest: ");
|
||||
|
||||
for (i = 0; i < ARGON2_PREHASH_DIGEST_LENGTH; ++i) {
|
||||
printf("%2.2x ", ((unsigned char *)blockhash)[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void print_tag(const void *out, uint32_t outlen) {
|
||||
unsigned i;
|
||||
if (out != NULL) {
|
||||
printf("Tag: ");
|
||||
|
||||
for (i = 0; i < outlen; ++i) {
|
||||
printf("%2.2x ", ((uint8_t *)out)[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void internal_kat(const argon2_instance_t *instance, uint32_t pass) {
|
||||
|
||||
if (instance != NULL) {
|
||||
uint32_t i, j;
|
||||
printf("\n After pass %u:\n", pass);
|
||||
|
||||
for (i = 0; i < instance->memory_blocks; ++i) {
|
||||
uint32_t how_many_words =
|
||||
(instance->memory_blocks > ARGON2_QWORDS_IN_BLOCK)
|
||||
? 1
|
||||
: ARGON2_QWORDS_IN_BLOCK;
|
||||
|
||||
for (j = 0; j < how_many_words; ++j)
|
||||
printf("Block %.4u [%3u]: %016" PRIx64 "\n", i, j,
|
||||
(unsigned long long)instance->memory[i].v[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fatal(const char *error) {
|
||||
fprintf(stderr, "Error: %s\n", error);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void generate_testvectors(argon2_type type, const uint32_t version) {
|
||||
#define TEST_OUTLEN 32
|
||||
#define TEST_PWDLEN 32
|
||||
#define TEST_SALTLEN 16
|
||||
#define TEST_SECRETLEN 8
|
||||
#define TEST_ADLEN 12
|
||||
argon2_context context;
|
||||
|
||||
unsigned char out[TEST_OUTLEN];
|
||||
unsigned char pwd[TEST_PWDLEN];
|
||||
unsigned char salt[TEST_SALTLEN];
|
||||
unsigned char secret[TEST_SECRETLEN];
|
||||
unsigned char ad[TEST_ADLEN];
|
||||
const allocate_fptr myown_allocator = NULL;
|
||||
const deallocate_fptr myown_deallocator = NULL;
|
||||
|
||||
unsigned t_cost = 3;
|
||||
unsigned m_cost = 32;
|
||||
unsigned lanes = 4;
|
||||
|
||||
memset(pwd, 1, TEST_OUTLEN);
|
||||
memset(salt, 2, TEST_SALTLEN);
|
||||
memset(secret, 3, TEST_SECRETLEN);
|
||||
memset(ad, 4, TEST_ADLEN);
|
||||
|
||||
context.out = out;
|
||||
context.outlen = TEST_OUTLEN;
|
||||
context.version = version;
|
||||
context.pwd = pwd;
|
||||
context.pwdlen = TEST_PWDLEN;
|
||||
context.salt = salt;
|
||||
context.saltlen = TEST_SALTLEN;
|
||||
context.secret = secret;
|
||||
context.secretlen = TEST_SECRETLEN;
|
||||
context.ad = ad;
|
||||
context.adlen = TEST_ADLEN;
|
||||
context.t_cost = t_cost;
|
||||
context.m_cost = m_cost;
|
||||
context.lanes = lanes;
|
||||
context.threads = lanes;
|
||||
context.allocate_cbk = myown_allocator;
|
||||
context.free_cbk = myown_deallocator;
|
||||
context.flags = ARGON2_DEFAULT_FLAGS;
|
||||
|
||||
#undef TEST_OUTLEN
|
||||
#undef TEST_PWDLEN
|
||||
#undef TEST_SALTLEN
|
||||
#undef TEST_SECRETLEN
|
||||
#undef TEST_ADLEN
|
||||
|
||||
argon2_ctx(&context, type);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/* Get and check Argon2 type */
|
||||
const char *type_str = (argc > 1) ? argv[1] : "i";
|
||||
argon2_type type = Argon2_i;
|
||||
uint32_t version = ARGON2_VERSION_NUMBER;
|
||||
if (!strcmp(type_str, "d")) {
|
||||
type = Argon2_d;
|
||||
} else if (!strcmp(type_str, "i")) {
|
||||
type = Argon2_i;
|
||||
} else if (!strcmp(type_str, "id")) {
|
||||
type = Argon2_id;
|
||||
} else {
|
||||
fatal("wrong Argon2 type");
|
||||
}
|
||||
|
||||
/* Get and check Argon2 version number */
|
||||
if (argc > 2) {
|
||||
version = strtoul(argv[2], NULL, 10);
|
||||
}
|
||||
if (ARGON2_VERSION_10 != version && ARGON2_VERSION_NUMBER != version) {
|
||||
fatal("wrong Argon2 version number");
|
||||
}
|
||||
|
||||
generate_testvectors(type, version);
|
||||
return ARGON2_OK;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#ifndef ARGON2_KAT_H
|
||||
#define ARGON2_KAT_H
|
||||
|
||||
#include "core.h"
|
||||
|
||||
/*
|
||||
* Initial KAT function that prints the inputs to the file
|
||||
* @param blockhash Array that contains pre-hashing digest
|
||||
* @param context Holds inputs
|
||||
* @param type Argon2 type
|
||||
* @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes
|
||||
* @pre context member pointers must point to allocated memory of size according
|
||||
* to the length values
|
||||
*/
|
||||
void initial_kat(const uint8_t *blockhash, const argon2_context *context,
|
||||
argon2_type type);
|
||||
|
||||
/*
|
||||
* Function that prints the output tag
|
||||
* @param out output array pointer
|
||||
* @param outlen digest length
|
||||
* @pre out must point to @a outlen bytes
|
||||
**/
|
||||
void print_tag(const void *out, uint32_t outlen);
|
||||
|
||||
/*
|
||||
* Function that prints the internal state at given moment
|
||||
* @param instance pointer to the current instance
|
||||
* @param pass current pass number
|
||||
* @pre instance must have necessary memory allocated
|
||||
**/
|
||||
void internal_kat(const argon2_instance_t *instance, uint32_t pass);
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "argon2.h"
|
||||
#include "core.h"
|
||||
|
||||
#include "blake2/blamka-round-ref.h"
|
||||
#include "blake2/blake2-impl.h"
|
||||
#include "blake2/blake2.h"
|
||||
|
||||
|
||||
/*
|
||||
* Function fills a new memory block and optionally XORs the old block over the new one.
|
||||
* @next_block must be initialized.
|
||||
* @param prev_block Pointer to the previous block
|
||||
* @param ref_block Pointer to the reference block
|
||||
* @param next_block Pointer to the block to be constructed
|
||||
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
|
||||
* @pre all block pointers must be valid
|
||||
*/
|
||||
static void fill_block(const block *prev_block, const block *ref_block,
|
||||
block *next_block, int with_xor) {
|
||||
block blockR, block_tmp;
|
||||
unsigned i;
|
||||
|
||||
copy_block(&blockR, ref_block);
|
||||
xor_block(&blockR, prev_block);
|
||||
copy_block(&block_tmp, &blockR);
|
||||
/* Now blockR = ref_block + prev_block and block_tmp = ref_block + prev_block */
|
||||
if (with_xor) {
|
||||
/* Saving the next block contents for XOR over: */
|
||||
xor_block(&block_tmp, next_block);
|
||||
/* Now blockR = ref_block + prev_block and
|
||||
block_tmp = ref_block + prev_block + next_block */
|
||||
}
|
||||
|
||||
/* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then
|
||||
(16,17,..31)... finally (112,113,...127) */
|
||||
for (i = 0; i < 8; ++i) {
|
||||
BLAKE2_ROUND_NOMSG(
|
||||
blockR.v[16 * i], blockR.v[16 * i + 1], blockR.v[16 * i + 2],
|
||||
blockR.v[16 * i + 3], blockR.v[16 * i + 4], blockR.v[16 * i + 5],
|
||||
blockR.v[16 * i + 6], blockR.v[16 * i + 7], blockR.v[16 * i + 8],
|
||||
blockR.v[16 * i + 9], blockR.v[16 * i + 10], blockR.v[16 * i + 11],
|
||||
blockR.v[16 * i + 12], blockR.v[16 * i + 13], blockR.v[16 * i + 14],
|
||||
blockR.v[16 * i + 15]);
|
||||
}
|
||||
|
||||
/* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then
|
||||
(2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) */
|
||||
for (i = 0; i < 8; i++) {
|
||||
BLAKE2_ROUND_NOMSG(
|
||||
blockR.v[2 * i], blockR.v[2 * i + 1], blockR.v[2 * i + 16],
|
||||
blockR.v[2 * i + 17], blockR.v[2 * i + 32], blockR.v[2 * i + 33],
|
||||
blockR.v[2 * i + 48], blockR.v[2 * i + 49], blockR.v[2 * i + 64],
|
||||
blockR.v[2 * i + 65], blockR.v[2 * i + 80], blockR.v[2 * i + 81],
|
||||
blockR.v[2 * i + 96], blockR.v[2 * i + 97], blockR.v[2 * i + 112],
|
||||
blockR.v[2 * i + 113]);
|
||||
}
|
||||
|
||||
copy_block(next_block, &block_tmp);
|
||||
xor_block(next_block, &blockR);
|
||||
}
|
||||
|
||||
static void next_addresses(block *address_block, block *input_block,
|
||||
const block *zero_block) {
|
||||
input_block->v[6]++;
|
||||
fill_block(zero_block, input_block, address_block, 0);
|
||||
fill_block(zero_block, address_block, address_block, 0);
|
||||
}
|
||||
|
||||
void fill_segment(const argon2_instance_t *instance,
|
||||
argon2_position_t position) {
|
||||
block *ref_block = NULL, *curr_block = NULL;
|
||||
block address_block, input_block, zero_block;
|
||||
uint64_t pseudo_rand, ref_index, ref_lane;
|
||||
uint32_t prev_offset, curr_offset;
|
||||
uint32_t starting_index;
|
||||
uint32_t i;
|
||||
int data_independent_addressing;
|
||||
|
||||
if (instance == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
data_independent_addressing =
|
||||
(instance->type == Argon2_i) ||
|
||||
(instance->type == Argon2_id && (position.pass == 0) &&
|
||||
(position.slice < ARGON2_SYNC_POINTS / 2));
|
||||
|
||||
if (data_independent_addressing) {
|
||||
init_block_value(&zero_block, 0);
|
||||
init_block_value(&input_block, 0);
|
||||
|
||||
input_block.v[0] = position.pass;
|
||||
input_block.v[1] = position.lane;
|
||||
input_block.v[2] = position.slice;
|
||||
input_block.v[3] = instance->memory_blocks;
|
||||
input_block.v[4] = instance->passes;
|
||||
input_block.v[5] = instance->type;
|
||||
}
|
||||
|
||||
starting_index = 0;
|
||||
|
||||
if ((0 == position.pass) && (0 == position.slice)) {
|
||||
starting_index = 2; /* we have already generated the first two blocks */
|
||||
|
||||
/* Don't forget to generate the first block of addresses: */
|
||||
if (data_independent_addressing) {
|
||||
next_addresses(&address_block, &input_block, &zero_block);
|
||||
}
|
||||
}
|
||||
|
||||
/* Offset of the current block */
|
||||
curr_offset = position.lane * instance->lane_length +
|
||||
position.slice * instance->segment_length + starting_index;
|
||||
|
||||
if (0 == curr_offset % instance->lane_length) {
|
||||
/* Last block in this lane */
|
||||
prev_offset = curr_offset + instance->lane_length - 1;
|
||||
} else {
|
||||
/* Previous block */
|
||||
prev_offset = curr_offset - 1;
|
||||
}
|
||||
|
||||
for (i = starting_index; i < instance->segment_length;
|
||||
++i, ++curr_offset, ++prev_offset) {
|
||||
/*1.1 Rotating prev_offset if needed */
|
||||
if (curr_offset % instance->lane_length == 1) {
|
||||
prev_offset = curr_offset - 1;
|
||||
}
|
||||
|
||||
/* 1.2 Computing the index of the reference block */
|
||||
/* 1.2.1 Taking pseudo-random value from the previous block */
|
||||
if (data_independent_addressing) {
|
||||
if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) {
|
||||
next_addresses(&address_block, &input_block, &zero_block);
|
||||
}
|
||||
pseudo_rand = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK];
|
||||
} else {
|
||||
pseudo_rand = instance->memory[prev_offset].v[0];
|
||||
}
|
||||
|
||||
/* 1.2.2 Computing the lane of the reference block */
|
||||
ref_lane = ((pseudo_rand >> 32)) % instance->lanes;
|
||||
|
||||
if ((position.pass == 0) && (position.slice == 0)) {
|
||||
/* Can not reference other lanes yet */
|
||||
ref_lane = position.lane;
|
||||
}
|
||||
|
||||
/* 1.2.3 Computing the number of possible reference block within the
|
||||
* lane.
|
||||
*/
|
||||
position.index = i;
|
||||
ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF,
|
||||
ref_lane == position.lane);
|
||||
|
||||
/* 2 Creating a new block */
|
||||
ref_block =
|
||||
instance->memory + instance->lane_length * ref_lane + ref_index;
|
||||
curr_block = instance->memory + curr_offset;
|
||||
if (ARGON2_VERSION_10 == instance->version) {
|
||||
/* version 1.2.1 and earlier: overwrite, not XOR */
|
||||
fill_block(instance->memory + prev_offset, ref_block, curr_block, 0);
|
||||
} else {
|
||||
if(0 == position.pass) {
|
||||
fill_block(instance->memory + prev_offset, ref_block,
|
||||
curr_block, 0);
|
||||
} else {
|
||||
fill_block(instance->memory + prev_offset, ref_block,
|
||||
curr_block, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "argon2.h"
|
||||
#include "core.h"
|
||||
|
||||
#define T_COST_DEF 3
|
||||
#define LOG_M_COST_DEF 12 /* 2^12 = 4 MiB */
|
||||
#define LANES_DEF 1
|
||||
#define THREADS_DEF 1
|
||||
#define OUTLEN_DEF 32
|
||||
#define MAX_PASS_LEN 128
|
||||
|
||||
#define UNUSED_PARAMETER(x) (void)(x)
|
||||
|
||||
static void usage(const char *cmd) {
|
||||
printf("Usage: %s [-h] salt [-i|-d|-id] [-t iterations] "
|
||||
"[-m log2(memory in KiB) | -k memory in KiB] [-p parallelism] "
|
||||
"[-l hash length] [-e|-r] [-v (10|13)]\n",
|
||||
cmd);
|
||||
printf("\tPassword is read from stdin\n");
|
||||
printf("Parameters:\n");
|
||||
printf("\tsalt\t\tThe salt to use, at least 8 characters\n");
|
||||
printf("\t-i\t\tUse Argon2i (this is the default)\n");
|
||||
printf("\t-d\t\tUse Argon2d instead of Argon2i\n");
|
||||
printf("\t-id\t\tUse Argon2id instead of Argon2i\n");
|
||||
printf("\t-t N\t\tSets the number of iterations to N (default = %d)\n",
|
||||
T_COST_DEF);
|
||||
printf("\t-m N\t\tSets the memory usage of 2^N KiB (default %d)\n",
|
||||
LOG_M_COST_DEF);
|
||||
printf("\t-k N\t\tSets the memory usage of N KiB (default %d)\n",
|
||||
1 << LOG_M_COST_DEF);
|
||||
printf("\t-p N\t\tSets parallelism to N threads (default %d)\n",
|
||||
THREADS_DEF);
|
||||
printf("\t-l N\t\tSets hash output length to N bytes (default %d)\n",
|
||||
OUTLEN_DEF);
|
||||
printf("\t-e\t\tOutput only encoded hash\n");
|
||||
printf("\t-r\t\tOutput only the raw bytes of the hash\n");
|
||||
printf("\t-v (10|13)\tArgon2 version (defaults to the most recent version, currently %x)\n",
|
||||
ARGON2_VERSION_NUMBER);
|
||||
printf("\t-h\t\tPrint %s usage\n", cmd);
|
||||
}
|
||||
|
||||
static void fatal(const char *error) {
|
||||
fprintf(stderr, "Error: %s\n", error);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void print_hex(uint8_t *bytes, size_t bytes_len) {
|
||||
size_t i;
|
||||
for (i = 0; i < bytes_len; ++i) {
|
||||
printf("%02x", bytes[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
Runs Argon2 with certain inputs and parameters, inputs not cleared. Prints the
|
||||
Base64-encoded hash string
|
||||
@out output array with at least 32 bytes allocated
|
||||
@pwd NULL-terminated string, presumably from argv[]
|
||||
@salt salt array
|
||||
@t_cost number of iterations
|
||||
@m_cost amount of requested memory in KB
|
||||
@lanes amount of requested parallelism
|
||||
@threads actual parallelism
|
||||
@type Argon2 type we want to run
|
||||
@encoded_only display only the encoded hash
|
||||
@raw_only display only the hexadecimal of the hash
|
||||
@version Argon2 version
|
||||
*/
|
||||
static void run(uint32_t outlen, char *pwd, size_t pwdlen, char *salt, uint32_t t_cost,
|
||||
uint32_t m_cost, uint32_t lanes, uint32_t threads,
|
||||
argon2_type type, int encoded_only, int raw_only, uint32_t version) {
|
||||
clock_t start_time, stop_time;
|
||||
size_t saltlen, encodedlen;
|
||||
int result;
|
||||
unsigned char * out = NULL;
|
||||
char * encoded = NULL;
|
||||
|
||||
start_time = clock();
|
||||
|
||||
if (!pwd) {
|
||||
fatal("password missing");
|
||||
}
|
||||
|
||||
if (!salt) {
|
||||
clear_internal_memory(pwd, pwdlen);
|
||||
fatal("salt missing");
|
||||
}
|
||||
|
||||
saltlen = strlen(salt);
|
||||
if(UINT32_MAX < saltlen) {
|
||||
fatal("salt is too long");
|
||||
}
|
||||
|
||||
UNUSED_PARAMETER(lanes);
|
||||
|
||||
out = malloc(outlen + 1);
|
||||
if (!out) {
|
||||
clear_internal_memory(pwd, pwdlen);
|
||||
fatal("could not allocate memory for output");
|
||||
}
|
||||
|
||||
encodedlen = argon2_encodedlen(t_cost, m_cost, lanes, (uint32_t)saltlen, outlen, type);
|
||||
encoded = malloc(encodedlen + 1);
|
||||
if (!encoded) {
|
||||
clear_internal_memory(pwd, pwdlen);
|
||||
fatal("could not allocate memory for hash");
|
||||
}
|
||||
|
||||
result = argon2_hash(t_cost, m_cost, threads, pwd, pwdlen, salt, saltlen,
|
||||
out, outlen, encoded, encodedlen, type,
|
||||
version);
|
||||
if (result != ARGON2_OK)
|
||||
fatal(argon2_error_message(result));
|
||||
|
||||
stop_time = clock();
|
||||
|
||||
if (encoded_only)
|
||||
puts(encoded);
|
||||
|
||||
if (raw_only)
|
||||
print_hex(out, outlen);
|
||||
|
||||
if (encoded_only || raw_only) {
|
||||
free(out);
|
||||
free(encoded);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Hash:\t\t");
|
||||
print_hex(out, outlen);
|
||||
free(out);
|
||||
|
||||
printf("Encoded:\t%s\n", encoded);
|
||||
|
||||
printf("%2.3f seconds\n",
|
||||
((double)stop_time - start_time) / (CLOCKS_PER_SEC));
|
||||
|
||||
result = argon2_verify(encoded, pwd, pwdlen, type);
|
||||
if (result != ARGON2_OK)
|
||||
fatal(argon2_error_message(result));
|
||||
printf("Verification ok\n");
|
||||
free(encoded);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
uint32_t outlen = OUTLEN_DEF;
|
||||
uint32_t m_cost = 1 << LOG_M_COST_DEF;
|
||||
uint32_t t_cost = T_COST_DEF;
|
||||
uint32_t lanes = LANES_DEF;
|
||||
uint32_t threads = THREADS_DEF;
|
||||
argon2_type type = Argon2_i; /* Argon2i is the default type */
|
||||
int types_specified = 0;
|
||||
int m_cost_specified = 0;
|
||||
int encoded_only = 0;
|
||||
int raw_only = 0;
|
||||
uint32_t version = ARGON2_VERSION_NUMBER;
|
||||
int i;
|
||||
size_t pwdlen;
|
||||
char pwd[MAX_PASS_LEN], *salt;
|
||||
|
||||
if (argc < 2) {
|
||||
usage(argv[0]);
|
||||
return ARGON2_MISSING_ARGS;
|
||||
} else if (argc >= 2 && strcmp(argv[1], "-h") == 0) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* get password from stdin */
|
||||
pwdlen = fread(pwd, 1, sizeof pwd, stdin);
|
||||
if(pwdlen < 1) {
|
||||
fatal("no password read");
|
||||
}
|
||||
if(pwdlen == MAX_PASS_LEN) {
|
||||
fatal("Provided password longer than supported in command line utility");
|
||||
}
|
||||
|
||||
salt = argv[1];
|
||||
|
||||
/* parse options */
|
||||
for (i = 2; i < argc; i++) {
|
||||
const char *a = argv[i];
|
||||
unsigned long input = 0;
|
||||
if (!strcmp(a, "-h")) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
} else if (!strcmp(a, "-m")) {
|
||||
if (m_cost_specified) {
|
||||
fatal("-m or -k can only be used once");
|
||||
}
|
||||
m_cost_specified = 1;
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
input = strtoul(argv[i], NULL, 10);
|
||||
if (input == 0 || input == ULONG_MAX ||
|
||||
input > ARGON2_MAX_MEMORY_BITS) {
|
||||
fatal("bad numeric input for -m");
|
||||
}
|
||||
m_cost = ARGON2_MIN(UINT64_C(1) << input, UINT32_C(0xFFFFFFFF));
|
||||
if (m_cost > ARGON2_MAX_MEMORY) {
|
||||
fatal("m_cost overflow");
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
fatal("missing -m argument");
|
||||
}
|
||||
} else if (!strcmp(a, "-k")) {
|
||||
if (m_cost_specified) {
|
||||
fatal("-m or -k can only be used once");
|
||||
}
|
||||
m_cost_specified = 1;
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
input = strtoul(argv[i], NULL, 10);
|
||||
if (input == 0 || input == ULONG_MAX) {
|
||||
fatal("bad numeric input for -k");
|
||||
}
|
||||
m_cost = ARGON2_MIN(input, UINT32_C(0xFFFFFFFF));
|
||||
if (m_cost > ARGON2_MAX_MEMORY) {
|
||||
fatal("m_cost overflow");
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
fatal("missing -k argument");
|
||||
}
|
||||
} else if (!strcmp(a, "-t")) {
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
input = strtoul(argv[i], NULL, 10);
|
||||
if (input == 0 || input == ULONG_MAX ||
|
||||
input > ARGON2_MAX_TIME) {
|
||||
fatal("bad numeric input for -t");
|
||||
}
|
||||
t_cost = input;
|
||||
continue;
|
||||
} else {
|
||||
fatal("missing -t argument");
|
||||
}
|
||||
} else if (!strcmp(a, "-p")) {
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
input = strtoul(argv[i], NULL, 10);
|
||||
if (input == 0 || input == ULONG_MAX ||
|
||||
input > ARGON2_MAX_THREADS || input > ARGON2_MAX_LANES) {
|
||||
fatal("bad numeric input for -p");
|
||||
}
|
||||
threads = input;
|
||||
lanes = threads;
|
||||
continue;
|
||||
} else {
|
||||
fatal("missing -p argument");
|
||||
}
|
||||
} else if (!strcmp(a, "-l")) {
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
input = strtoul(argv[i], NULL, 10);
|
||||
outlen = input;
|
||||
continue;
|
||||
} else {
|
||||
fatal("missing -l argument");
|
||||
}
|
||||
} else if (!strcmp(a, "-i")) {
|
||||
type = Argon2_i;
|
||||
++types_specified;
|
||||
} else if (!strcmp(a, "-d")) {
|
||||
type = Argon2_d;
|
||||
++types_specified;
|
||||
} else if (!strcmp(a, "-id")) {
|
||||
type = Argon2_id;
|
||||
++types_specified;
|
||||
} else if (!strcmp(a, "-e")) {
|
||||
encoded_only = 1;
|
||||
} else if (!strcmp(a, "-r")) {
|
||||
raw_only = 1;
|
||||
} else if (!strcmp(a, "-v")) {
|
||||
if (i < argc - 1) {
|
||||
i++;
|
||||
if (!strcmp(argv[i], "10")) {
|
||||
version = ARGON2_VERSION_10;
|
||||
} else if (!strcmp(argv[i], "13")) {
|
||||
version = ARGON2_VERSION_13;
|
||||
} else {
|
||||
fatal("invalid Argon2 version");
|
||||
}
|
||||
} else {
|
||||
fatal("missing -v argument");
|
||||
}
|
||||
} else {
|
||||
fatal("unknown argument");
|
||||
}
|
||||
}
|
||||
|
||||
if (types_specified > 1) {
|
||||
fatal("cannot specify multiple Argon2 types");
|
||||
}
|
||||
|
||||
if(encoded_only && raw_only)
|
||||
fatal("cannot provide both -e and -r");
|
||||
|
||||
if(!encoded_only && !raw_only) {
|
||||
printf("Type:\t\t%s\n", argon2_type2string(type, 1));
|
||||
printf("Iterations:\t%u\n", t_cost);
|
||||
printf("Memory:\t\t%u KiB\n", m_cost);
|
||||
printf("Parallelism:\t%u\n", lanes);
|
||||
}
|
||||
|
||||
run(outlen, pwd, pwdlen, salt, t_cost, m_cost, lanes, threads, type,
|
||||
encoded_only, raw_only, version);
|
||||
|
||||
return ARGON2_OK;
|
||||
}
|
||||
|
||||
@@ -1,289 +0,0 @@
|
||||
/*
|
||||
* Argon2 reference source code package - reference C implementations
|
||||
*
|
||||
* Copyright 2015
|
||||
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
||||
*
|
||||
* You may use this work under the terms of a Creative Commons CC0 1.0
|
||||
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
||||
* these licenses can be found at:
|
||||
*
|
||||
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
||||
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* You should have received a copy of both of these licenses along with this
|
||||
* software. If not, they may be obtained at the above URLs.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "argon2.h"
|
||||
|
||||
#define OUT_LEN 32
|
||||
#define ENCODED_LEN 108
|
||||
|
||||
/* Test harness will assert:
|
||||
* argon2_hash() returns ARGON2_OK
|
||||
* HEX output matches expected
|
||||
* encoded output matches expected
|
||||
* argon2_verify() correctly verifies value
|
||||
*/
|
||||
|
||||
void hashtest(uint32_t version, uint32_t t, uint32_t m, uint32_t p, char *pwd,
|
||||
char *salt, char *hexref, char *mcfref, argon2_type type) {
|
||||
unsigned char out[OUT_LEN];
|
||||
unsigned char hex_out[OUT_LEN * 2 + 4];
|
||||
char encoded[ENCODED_LEN];
|
||||
int ret, i;
|
||||
|
||||
printf("Hash test: $v=%d t=%d, m=%d, p=%d, pass=%s, salt=%s: ", version,
|
||||
t, m, p, pwd, salt);
|
||||
|
||||
ret = argon2_hash(t, 1 << m, p, pwd, strlen(pwd), salt, strlen(salt), out,
|
||||
OUT_LEN, encoded, ENCODED_LEN, type, version);
|
||||
assert(ret == ARGON2_OK);
|
||||
|
||||
for (i = 0; i < OUT_LEN; ++i)
|
||||
sprintf((char *)(hex_out + i * 2), "%02x", out[i]);
|
||||
assert(memcmp(hex_out, hexref, OUT_LEN * 2) == 0);
|
||||
|
||||
if (ARGON2_VERSION_NUMBER == version) {
|
||||
assert(memcmp(encoded, mcfref, strlen(mcfref)) == 0);
|
||||
}
|
||||
|
||||
ret = argon2_verify(encoded, pwd, strlen(pwd), type);
|
||||
assert(ret == ARGON2_OK);
|
||||
ret = argon2_verify(mcfref, pwd, strlen(pwd), type);
|
||||
assert(ret == ARGON2_OK);
|
||||
|
||||
printf("PASS\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
unsigned char out[OUT_LEN];
|
||||
char const *msg;
|
||||
int version;
|
||||
|
||||
version = ARGON2_VERSION_10;
|
||||
printf("Test Argon2i version number: %02x\n", version);
|
||||
|
||||
/* Multiple test cases for various input values */
|
||||
hashtest(version, 2, 16, 1, "password", "somesalt",
|
||||
"f6c4db4a54e2a370627aff3db6176b94a2a209a62c8e36152711802f7b30c694",
|
||||
"$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", Argon2_i);
|
||||
#ifdef TEST_LARGE_RAM
|
||||
hashtest(version, 2, 20, 1, "password", "somesalt",
|
||||
"9690ec55d28d3ed32562f2e73ea62b02b018757643a2ae6e79528459de8106e9",
|
||||
"$argon2i$m=1048576,t=2,p=1$c29tZXNhbHQ"
|
||||
"$lpDsVdKNPtMlYvLnPqYrArAYdXZDoq5ueVKEWd6BBuk", Argon2_i);
|
||||
#endif
|
||||
hashtest(version, 2, 18, 1, "password", "somesalt",
|
||||
"3e689aaa3d28a77cf2bc72a51ac53166761751182f1ee292e3f677a7da4c2467",
|
||||
"$argon2i$m=262144,t=2,p=1$c29tZXNhbHQ"
|
||||
"$Pmiaqj0op3zyvHKlGsUxZnYXURgvHuKS4/Z3p9pMJGc", Argon2_i);
|
||||
hashtest(version, 2, 8, 1, "password", "somesalt",
|
||||
"fd4dd83d762c49bdeaf57c47bdcd0c2f1babf863fdeb490df63ede9975fccf06",
|
||||
"$argon2i$m=256,t=2,p=1$c29tZXNhbHQ"
|
||||
"$/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY", Argon2_i);
|
||||
hashtest(version, 2, 8, 2, "password", "somesalt",
|
||||
"b6c11560a6a9d61eac706b79a2f97d68b4463aa3ad87e00c07e2b01e90c564fb",
|
||||
"$argon2i$m=256,t=2,p=2$c29tZXNhbHQ"
|
||||
"$tsEVYKap1h6scGt5ovl9aLRGOqOth+AMB+KwHpDFZPs", Argon2_i);
|
||||
hashtest(version, 1, 16, 1, "password", "somesalt",
|
||||
"81630552b8f3b1f48cdb1992c4c678643d490b2b5eb4ff6c4b3438b5621724b2",
|
||||
"$argon2i$m=65536,t=1,p=1$c29tZXNhbHQ"
|
||||
"$gWMFUrjzsfSM2xmSxMZ4ZD1JCytetP9sSzQ4tWIXJLI", Argon2_i);
|
||||
hashtest(version, 4, 16, 1, "password", "somesalt",
|
||||
"f212f01615e6eb5d74734dc3ef40ade2d51d052468d8c69440a3a1f2c1c2847b",
|
||||
"$argon2i$m=65536,t=4,p=1$c29tZXNhbHQ"
|
||||
"$8hLwFhXm6110c03D70Ct4tUdBSRo2MaUQKOh8sHChHs", Argon2_i);
|
||||
hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
|
||||
"e9c902074b6754531a3a0be519e5baf404b30ce69b3f01ac3bf21229960109a3",
|
||||
"$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$6ckCB0tnVFMaOgvlGeW69ASzDOabPwGsO/ISKZYBCaM", Argon2_i);
|
||||
hashtest(version, 2, 16, 1, "password", "diffsalt",
|
||||
"79a103b90fe8aef8570cb31fc8b22259778916f8336b7bdac3892569d4f1c497",
|
||||
"$argon2i$m=65536,t=2,p=1$ZGlmZnNhbHQ"
|
||||
"$eaEDuQ/orvhXDLMfyLIiWXeJFvgza3vaw4kladTxxJc", Argon2_i);
|
||||
|
||||
/* Error state tests */
|
||||
|
||||
/* Handle an invalid encoding correctly (it is missing a $) */
|
||||
ret = argon2_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
|
||||
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_DECODING_FAIL);
|
||||
printf("Recognise an invalid encoding: PASS\n");
|
||||
|
||||
/* Handle an invalid encoding correctly (it is missing a $) */
|
||||
ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_DECODING_FAIL);
|
||||
printf("Recognise an invalid encoding: PASS\n");
|
||||
|
||||
/* Handle an invalid encoding correctly (salt is too short) */
|
||||
ret = argon2_verify("$argon2i$m=65536,t=2,p=1$"
|
||||
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_SALT_TOO_SHORT);
|
||||
printf("Recognise an invalid salt in encoding: PASS\n");
|
||||
|
||||
/* Handle an mismatching hash (the encoded password is "passwore") */
|
||||
ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_VERIFY_MISMATCH);
|
||||
printf("Verify with mismatched password: PASS\n");
|
||||
|
||||
msg = argon2_error_message(ARGON2_DECODING_FAIL);
|
||||
assert(strcmp(msg, "Decoding failed") == 0);
|
||||
printf("Decode an error message: PASS\n");
|
||||
|
||||
printf("\n");
|
||||
|
||||
version = ARGON2_VERSION_NUMBER;
|
||||
printf("Test Argon2i version number: %02x\n", version);
|
||||
|
||||
/* Multiple test cases for various input values */
|
||||
hashtest(version, 2, 16, 1, "password", "somesalt",
|
||||
"c1628832147d9720c5bd1cfd61367078729f6dfb6f8fea9ff98158e0d7816ed0",
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA", Argon2_i);
|
||||
#ifdef TEST_LARGE_RAM
|
||||
hashtest(version, 2, 20, 1, "password", "somesalt",
|
||||
"d1587aca0922c3b5d6a83edab31bee3c4ebaef342ed6127a55d19b2351ad1f41",
|
||||
"$argon2i$v=19$m=1048576,t=2,p=1$c29tZXNhbHQ"
|
||||
"$0Vh6ygkiw7XWqD7asxvuPE667zQu1hJ6VdGbI1GtH0E", Argon2_i);
|
||||
#endif
|
||||
hashtest(version, 2, 18, 1, "password", "somesalt",
|
||||
"296dbae80b807cdceaad44ae741b506f14db0959267b183b118f9b24229bc7cb",
|
||||
"$argon2i$v=19$m=262144,t=2,p=1$c29tZXNhbHQ"
|
||||
"$KW266AuAfNzqrUSudBtQbxTbCVkmexg7EY+bJCKbx8s", Argon2_i);
|
||||
hashtest(version, 2, 8, 1, "password", "somesalt",
|
||||
"89e9029f4637b295beb027056a7336c414fadd43f6b208645281cb214a56452f",
|
||||
"$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ"
|
||||
"$iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8", Argon2_i);
|
||||
hashtest(version, 2, 8, 2, "password", "somesalt",
|
||||
"4ff5ce2769a1d7f4c8a491df09d41a9fbe90e5eb02155a13e4c01e20cd4eab61",
|
||||
"$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ"
|
||||
"$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2E", Argon2_i);
|
||||
hashtest(version, 1, 16, 1, "password", "somesalt",
|
||||
"d168075c4d985e13ebeae560cf8b94c3b5d8a16c51916b6f4ac2da3ac11bbecf",
|
||||
"$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQ"
|
||||
"$0WgHXE2YXhPr6uVgz4uUw7XYoWxRkWtvSsLaOsEbvs8", Argon2_i);
|
||||
hashtest(version, 4, 16, 1, "password", "somesalt",
|
||||
"aaa953d58af3706ce3df1aefd4a64a84e31d7f54175231f1285259f88174ce5b",
|
||||
"$argon2i$v=19$m=65536,t=4,p=1$c29tZXNhbHQ"
|
||||
"$qqlT1YrzcGzj3xrv1KZKhOMdf1QXUjHxKFJZ+IF0zls", Argon2_i);
|
||||
hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
|
||||
"14ae8da01afea8700c2358dcef7c5358d9021282bd88663a4562f59fb74d22ee",
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$FK6NoBr+qHAMI1jc73xTWNkCEoK9iGY6RWL1n7dNIu4", Argon2_i);
|
||||
hashtest(version, 2, 16, 1, "password", "diffsalt",
|
||||
"b0357cccfbef91f3860b0dba447b2348cbefecadaf990abfe9cc40726c521271",
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ"
|
||||
"$sDV8zPvvkfOGCw26RHsjSMvv7K2vmQq/6cxAcmxSEnE", Argon2_i);
|
||||
|
||||
|
||||
/* Error state tests */
|
||||
|
||||
/* Handle an invalid encoding correctly (it is missing a $) */
|
||||
ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
|
||||
"$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_DECODING_FAIL);
|
||||
printf("Recognise an invalid encoding: PASS\n");
|
||||
|
||||
/* Handle an invalid encoding correctly (it is missing a $) */
|
||||
ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_DECODING_FAIL);
|
||||
printf("Recognise an invalid encoding: PASS\n");
|
||||
|
||||
/* Handle an invalid encoding correctly (salt is too short) */
|
||||
ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$"
|
||||
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_SALT_TOO_SHORT);
|
||||
printf("Recognise an invalid salt in encoding: PASS\n");
|
||||
|
||||
/* Handle an mismatching hash (the encoded password is "passwore") */
|
||||
ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
|
||||
"password", strlen("password"), Argon2_i);
|
||||
assert(ret == ARGON2_VERIFY_MISMATCH);
|
||||
printf("Verify with mismatched password: PASS\n");
|
||||
|
||||
msg = argon2_error_message(ARGON2_DECODING_FAIL);
|
||||
assert(strcmp(msg, "Decoding failed") == 0);
|
||||
printf("Decode an error message: PASS\n\n");
|
||||
|
||||
printf("Test Argon2id version number: %02x\n", version);
|
||||
|
||||
/* Multiple test cases for various input values */
|
||||
hashtest(version, 2, 16, 1, "password", "somesalt",
|
||||
"09316115d5cf24ed5a15a31a3ba326e5cf32edc24702987c02b6566f61913cf7",
|
||||
"$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$CTFhFdXPJO1aFaMaO6Mm5c8y7cJHAph8ArZWb2GRPPc", Argon2_id);
|
||||
hashtest(version, 2, 18, 1, "password", "somesalt",
|
||||
"78fe1ec91fb3aa5657d72e710854e4c3d9b9198c742f9616c2f085bed95b2e8c",
|
||||
"$argon2id$v=19$m=262144,t=2,p=1$c29tZXNhbHQ"
|
||||
"$eP4eyR+zqlZX1y5xCFTkw9m5GYx0L5YWwvCFvtlbLow", Argon2_id);
|
||||
hashtest(version, 2, 8, 1, "password", "somesalt",
|
||||
"9dfeb910e80bad0311fee20f9c0e2b12c17987b4cac90c2ef54d5b3021c68bfe",
|
||||
"$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ"
|
||||
"$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4", Argon2_id);
|
||||
hashtest(version, 2, 8, 2, "password", "somesalt",
|
||||
"6d093c501fd5999645e0ea3bf620d7b8be7fd2db59c20d9fff9539da2bf57037",
|
||||
"$argon2id$v=19$m=256,t=2,p=2$c29tZXNhbHQ"
|
||||
"$bQk8UB/VmZZF4Oo79iDXuL5/0ttZwg2f/5U52iv1cDc", Argon2_id);
|
||||
hashtest(version, 1, 16, 1, "password", "somesalt",
|
||||
"f6a5adc1ba723dddef9b5ac1d464e180fcd9dffc9d1cbf76cca2fed795d9ca98",
|
||||
"$argon2id$v=19$m=65536,t=1,p=1$c29tZXNhbHQ"
|
||||
"$9qWtwbpyPd3vm1rB1GThgPzZ3/ydHL92zKL+15XZypg", Argon2_id);
|
||||
hashtest(version, 4, 16, 1, "password", "somesalt",
|
||||
"9025d48e68ef7395cca9079da4c4ec3affb3c8911fe4f86d1a2520856f63172c",
|
||||
"$argon2id$v=19$m=65536,t=4,p=1$c29tZXNhbHQ"
|
||||
"$kCXUjmjvc5XMqQedpMTsOv+zyJEf5PhtGiUghW9jFyw", Argon2_id);
|
||||
hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
|
||||
"0b84d652cf6b0c4beaef0dfe278ba6a80df6696281d7e0d2891b817d8c458fde",
|
||||
"$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
|
||||
"$C4TWUs9rDEvq7w3+J4umqA32aWKB1+DSiRuBfYxFj94", Argon2_id);
|
||||
hashtest(version, 2, 16, 1, "password", "diffsalt",
|
||||
"bdf32b05ccc42eb15d58fd19b1f856b113da1e9a5874fdcc544308565aa8141c",
|
||||
"$argon2id$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ"
|
||||
"$vfMrBczELrFdWP0ZsfhWsRPaHppYdP3MVEMIVlqoFBw", Argon2_id);
|
||||
|
||||
/* Common error state tests */
|
||||
|
||||
printf("\n");
|
||||
printf("Common error state tests\n");
|
||||
|
||||
ret = argon2_hash(2, 1, 1, "password", strlen("password"),
|
||||
"diffsalt", strlen("diffsalt"),
|
||||
out, OUT_LEN, NULL, 0, Argon2_id, version);
|
||||
assert(ret == ARGON2_MEMORY_TOO_LITTLE);
|
||||
printf("Fail on invalid memory: PASS\n");
|
||||
|
||||
ret = argon2_hash(2, 1 << 12, 1, NULL, strlen("password"),
|
||||
"diffsalt", strlen("diffsalt"),
|
||||
out, OUT_LEN, NULL, 0, Argon2_id, version);
|
||||
assert(ret == ARGON2_PWD_PTR_MISMATCH);
|
||||
printf("Fail on invalid null pointer: PASS\n");
|
||||
|
||||
ret = argon2_hash(2, 1 << 12, 1, "password", strlen("password"), "s", 1,
|
||||
out, OUT_LEN, NULL, 0, Argon2_id, version);
|
||||
assert(ret == ARGON2_SALT_TOO_SHORT);
|
||||
printf("Fail on salt too short: PASS\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user