We don't need the ability to use a custom allocator

This commit is contained in:
Frank Denis 2015-12-29 22:33:36 +01:00
parent 28ca446f73
commit 69cfab0522
3 changed files with 4 additions and 32 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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;