argon2: let fill_memory_blocks() accept a pass counter
This commit is contained in:
parent
06f5c9a773
commit
8ab638b983
@ -288,22 +288,21 @@ index_alpha(const argon2_instance_t *instance,
|
||||
}
|
||||
|
||||
void
|
||||
fill_memory_blocks(argon2_instance_t *instance)
|
||||
fill_memory_blocks(argon2_instance_t *instance, uint32_t pass)
|
||||
{
|
||||
uint32_t r, s;
|
||||
uint32_t s;
|
||||
|
||||
if (instance == NULL || instance->lanes == 0) {
|
||||
return; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
|
||||
for (r = 0; r < instance->passes; ++r) {
|
||||
for (s = 0; s < ARGON2_SYNC_POINTS; ++s) {
|
||||
uint32_t l;
|
||||
|
||||
for (l = 0; l < instance->lanes; ++l) {
|
||||
argon2_position_t position;
|
||||
|
||||
position.pass = r;
|
||||
position.pass = pass;
|
||||
position.lane = l;
|
||||
position.slice = (uint8_t) s;
|
||||
position.index = 0;
|
||||
@ -311,7 +310,6 @@ fill_memory_blocks(argon2_instance_t *instance)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
validate_inputs(const argon2_context *context)
|
||||
|
@ -96,6 +96,7 @@ typedef struct Argon2_instance_t {
|
||||
block_region *region; /* Memory region pointer */
|
||||
uint64_t *pseudo_rands;
|
||||
uint32_t passes; /* Number of passes */
|
||||
uint32_t current_pass;
|
||||
uint32_t memory_blocks; /* Number of blocks in memory */
|
||||
uint32_t segment_length;
|
||||
uint32_t lane_length;
|
||||
@ -224,6 +225,6 @@ void fill_segment_ref(const argon2_instance_t *instance,
|
||||
* @param instance Pointer to the current instance
|
||||
* @return Zero if successful, -1 if memory failed to allocate
|
||||
*/
|
||||
void fill_memory_blocks(argon2_instance_t *instance);
|
||||
void fill_memory_blocks(argon2_instance_t *instance, uint32_t pass);
|
||||
|
||||
#endif
|
||||
|
@ -29,6 +29,7 @@ argon2_ctx(argon2_context *context, argon2_type type)
|
||||
/* 1. Validate all inputs */
|
||||
int result = validate_inputs(context);
|
||||
uint32_t memory_blocks, segment_length;
|
||||
uint32_t pass;
|
||||
argon2_instance_t instance;
|
||||
|
||||
if (ARGON2_OK != result) {
|
||||
@ -53,6 +54,7 @@ argon2_ctx(argon2_context *context, argon2_type type)
|
||||
|
||||
instance.region = NULL;
|
||||
instance.passes = context->t_cost;
|
||||
instance.current_pass = ~ 0U;
|
||||
instance.memory_blocks = memory_blocks;
|
||||
instance.segment_length = segment_length;
|
||||
instance.lane_length = segment_length * ARGON2_SYNC_POINTS;
|
||||
@ -70,7 +72,9 @@ argon2_ctx(argon2_context *context, argon2_type type)
|
||||
}
|
||||
|
||||
/* 4. Filling memory */
|
||||
fill_memory_blocks(&instance);
|
||||
for (pass = 0; pass < instance.passes; pass++) {
|
||||
fill_memory_blocks(&instance, pass);
|
||||
}
|
||||
|
||||
/* 5. Finalization */
|
||||
finalize(context, &instance);
|
||||
|
Loading…
Reference in New Issue
Block a user