From 69cfab05223a85070a8b0f4a50e336535b55876f Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 29 Dec 2015 22:33:36 +0100 Subject: [PATCH] We don't need the ability to use a custom allocator --- .../crypto_pwhash/argon2/argon2-core.c | 31 +++---------------- src/libsodium/crypto_pwhash/argon2/argon2.c | 2 -- src/libsodium/crypto_pwhash/argon2/argon2.h | 3 -- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index 5bafa46e..501a8517 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -172,12 +172,7 @@ void finalize(const argon2_context *context, argon2_instance_t *instance) { clear_memory(instance, context->flags & ARGON2_FLAG_CLEAR_PASSWORD); /* Deallocate the memory */ - if (NULL != context->free_cbk) { - context->free_cbk((uint8_t *)instance->region->memory, - instance->memory_blocks * sizeof(block)); - } else { - free_memory(instance->region); - } + free_memory(instance->region); } } @@ -393,14 +388,6 @@ int validate_inputs(const argon2_context *context) { return ARGON2_THREADS_TOO_MANY; } - if (NULL != context->allocate_cbk && NULL == context->free_cbk) { - return ARGON2_FREE_MEMORY_CBK_NULL; - } - - if (NULL == context->allocate_cbk && NULL != context->free_cbk) { - return ARGON2_ALLOCATE_MEMORY_CBK_NULL; - } - return ARGON2_OK; } @@ -511,19 +498,9 @@ int initialize(argon2_instance_t *instance, argon2_context *context) { /* 1. Memory allocation */ - if (NULL != context->allocate_cbk) { - uint8_t *p; - result = context->allocate_cbk(&p, instance->memory_blocks * - ARGON2_BLOCK_SIZE); - if (ARGON2_OK != result) { - return result; - } - memcpy(&(instance->region->memory), p, sizeof(instance->region->memory)); - } else { - result = allocate_memory(&(instance->region), instance->memory_blocks); - if (ARGON2_OK != result) { - return result; - } + result = allocate_memory(&(instance->region), instance->memory_blocks); + if (ARGON2_OK != result) { + return result; } /* 2. Initial hashing */ diff --git a/src/libsodium/crypto_pwhash/argon2/argon2.c b/src/libsodium/crypto_pwhash/argon2/argon2.c index de078afc..7750beb9 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2.c @@ -118,8 +118,6 @@ int argon2_hash(const uint32_t t_cost, const uint32_t m_cost, context.m_cost = m_cost; context.lanes = parallelism; context.threads = parallelism; - context.allocate_cbk = NULL; - context.free_cbk = NULL; context.flags = ARGON2_DEFAULT_FLAGS; result = argon2_core(&context, type); diff --git a/src/libsodium/crypto_pwhash/argon2/argon2.h b/src/libsodium/crypto_pwhash/argon2/argon2.h index c3913263..f1f7fc2c 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2.h +++ b/src/libsodium/crypto_pwhash/argon2/argon2.h @@ -181,9 +181,6 @@ typedef struct Argon2_Context { uint32_t lanes; /* number of lanes */ uint32_t threads; /* maximum number of threads */ - 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;