Make argon2i blocks allocation functions static
This commit is contained in:
parent
74809e7296
commit
82ed2169b0
@ -65,7 +65,14 @@ static void store_block(void *output, const block *src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***************Memory allocators*****************/
|
/***************Memory allocators*****************/
|
||||||
int allocate_memory(block_region **region, uint32_t m_cost) {
|
/* Allocates memory to the given pointer
|
||||||
|
* @param memory pointer to the pointer to the memory
|
||||||
|
* @param m_cost number of blocks to allocate in the memory
|
||||||
|
* @return ARGON2_OK if @memory is a valid pointer and memory is allocated
|
||||||
|
*/
|
||||||
|
static int allocate_memory(block_region **memory, uint32_t m_cost);
|
||||||
|
|
||||||
|
static int allocate_memory(block_region **region, uint32_t m_cost) {
|
||||||
void *base;
|
void *base;
|
||||||
block *memory;
|
block *memory;
|
||||||
size_t memory_size;
|
size_t memory_size;
|
||||||
@ -122,14 +129,25 @@ int allocate_memory(block_region **region, uint32_t m_cost) {
|
|||||||
|
|
||||||
/*********Memory functions*/
|
/*********Memory functions*/
|
||||||
|
|
||||||
void clear_memory(argon2_instance_t *instance, int clear) {
|
/* Clears memory
|
||||||
|
* @param instance pointer to the current instance
|
||||||
|
* @param clear_memory indicates if we clear the memory with zeros.
|
||||||
|
*/
|
||||||
|
static void clear_memory(argon2_instance_t *instance, int clear);
|
||||||
|
|
||||||
|
static void clear_memory(argon2_instance_t *instance, int clear) {
|
||||||
if (instance->region != NULL && clear) {
|
if (instance->region != NULL && clear) {
|
||||||
sodium_memzero(instance->region->memory,
|
sodium_memzero(instance->region->memory,
|
||||||
sizeof(block) * instance->memory_blocks);
|
sizeof(block) * instance->memory_blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_memory(block_region *region) {
|
/* Deallocates memory
|
||||||
|
* @param memory pointer to the blocks
|
||||||
|
*/
|
||||||
|
static void free_memory(block_region *memory);
|
||||||
|
|
||||||
|
static void free_memory(block_region *region) {
|
||||||
if (region->base) {
|
if (region->base) {
|
||||||
#if defined(MAP_ANON) && defined(HAVE_MMAP)
|
#if defined(MAP_ANON) && defined(HAVE_MMAP)
|
||||||
if (munmap(region->base, region->size)) {
|
if (munmap(region->base, region->size)) {
|
||||||
|
@ -103,24 +103,6 @@ typedef struct Argon2_thread_data {
|
|||||||
/*************************Argon2 core
|
/*************************Argon2 core
|
||||||
* functions**************************************************/
|
* functions**************************************************/
|
||||||
|
|
||||||
/* Allocates memory to the given pointer
|
|
||||||
* @param memory pointer to the pointer to the memory
|
|
||||||
* @param m_cost number of blocks to allocate in the memory
|
|
||||||
* @return ARGON2_OK if @memory is a valid pointer and memory is allocated
|
|
||||||
*/
|
|
||||||
int allocate_memory(block_region **memory, uint32_t m_cost);
|
|
||||||
|
|
||||||
/* Clears memory
|
|
||||||
* @param instance pointer to the current instance
|
|
||||||
* @param clear_memory indicates if we clear the memory with zeros.
|
|
||||||
*/
|
|
||||||
void clear_memory(argon2_instance_t *instance, int clear);
|
|
||||||
|
|
||||||
/* Deallocates memory
|
|
||||||
* @param memory pointer to the blocks
|
|
||||||
*/
|
|
||||||
void free_memory(block_region *memory);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Computes absolute position of reference block in the lane following a skewed
|
* Computes absolute position of reference block in the lane following a skewed
|
||||||
* distribution and using a pseudo-random value as input
|
* distribution and using a pseudo-random value as input
|
||||||
|
Loading…
Reference in New Issue
Block a user