From 7567cef4c6192fb5356bbdd7db802be77be0439b Mon Sep 17 00:00:00 2001 From: tevador <37503146+tevador@users.noreply.github.com> Date: Wed, 30 Oct 2019 20:09:27 +0100 Subject: [PATCH] Fix symbol collisions with blake2b (#145) --- src/argon2_core.c | 4 ++-- src/blake2/blake2.h | 11 ++++++++++- src/blake2/blake2b.c | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/argon2_core.c b/src/argon2_core.c index a70f9dc..f2e7f3d 100644 --- a/src/argon2_core.c +++ b/src/argon2_core.c @@ -307,13 +307,13 @@ void rxa2_fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instanc store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 0); store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH + 4, l); - rxa2_blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, + blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, ARGON2_PREHASH_SEED_LENGTH); load_block(&instance->memory[l * instance->lane_length + 0], blockhash_bytes); store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 1); - rxa2_blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, + blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, ARGON2_PREHASH_SEED_LENGTH); load_block(&instance->memory[l * instance->lane_length + 1], blockhash_bytes); diff --git a/src/blake2/blake2.h b/src/blake2/blake2.h index 7ac301c..3d15be1 100644 --- a/src/blake2/blake2.h +++ b/src/blake2/blake2.h @@ -84,6 +84,15 @@ extern "C" { 1 / !!(sizeof(blake2b_param) == sizeof(uint64_t) * CHAR_BIT) }; + //randomx namespace +#define blake2b_init randomx_blake2b_init +#define blake2b_init_key randomx_blake2b_init_key +#define blake2b_init_param randomx_blake2b_init_param +#define blake2b_update randomx_blake2b_update +#define blake2b_final randomx_blake2b_final +#define blake2b randomx_blake2b +#define blake2b_long randomx_blake2b_long + /* Streaming API */ int blake2b_init(blake2b_state *S, size_t outlen); int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, @@ -97,7 +106,7 @@ extern "C" { const void *key, size_t keylen); /* Argon2 Team - Begin Code */ - int rxa2_blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); + int blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); /* Argon2 Team - End Code */ #if defined(__cplusplus) diff --git a/src/blake2/blake2b.c b/src/blake2/blake2b.c index 5931ee5..b9f1b56 100644 --- a/src/blake2/blake2b.c +++ b/src/blake2/blake2b.c @@ -347,7 +347,7 @@ fail: } /* Argon2 Team - Begin Code */ -int rxa2_blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) { +int blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) { uint8_t *out = (uint8_t *)pout; blake2b_state blake_state; uint8_t outlen_bytes[sizeof(uint32_t)] = { 0 };