1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-26 13:51:04 -07:00

Remove a non-constant modulo operation in argon2

Adapted from a change originally written by @Sc00bz
This commit is contained in:
Frank Denis 2024-11-09 13:24:26 +01:00
parent cd6b337b37
commit 985ad65bfb

View File

@ -152,8 +152,8 @@ static uint32_t index_alpha(const argon2_instance_t *instance,
* Other lanes : (SYNC_POINTS - 1) last segments
*/
uint32_t reference_area_size;
uint64_t relative_position;
uint32_t start_position, absolute_position;
uint64_t relative_position, absolute_position;
uint32_t start_position;
if (position->pass == 0) {
/* First pass */
@ -203,9 +203,9 @@ static uint32_t index_alpha(const argon2_instance_t *instance,
}
/* 1.2.6. Computing absolute position */
absolute_position = (start_position + relative_position) %
instance->lane_length; /* absolute position */
return absolute_position;
absolute_position = start_position + relative_position - instance->lane_length;
absolute_position += instance->lane_length & (absolute_position >> 32);
return (uint32_t) absolute_position;
}
/*