Validate argon2 lanes before memory cost

This commit is contained in:
Frank Denis 2020-08-16 11:31:20 +02:00
parent 1510197621
commit 4a75300b45

View File

@ -325,6 +325,15 @@ argon2_validate_inputs(const argon2_context *context)
} }
} }
/* Validate lanes */
if (ARGON2_MIN_LANES > context->lanes) {
return ARGON2_LANES_TOO_FEW;
}
if (ARGON2_MAX_LANES < context->lanes) {
return ARGON2_LANES_TOO_MANY;
}
/* Validate memory cost */ /* Validate memory cost */
if (ARGON2_MIN_MEMORY > context->m_cost) { if (ARGON2_MIN_MEMORY > context->m_cost) {
return ARGON2_MEMORY_TOO_LITTLE; return ARGON2_MEMORY_TOO_LITTLE;
@ -347,15 +356,6 @@ argon2_validate_inputs(const argon2_context *context)
return ARGON2_TIME_TOO_LARGE; return ARGON2_TIME_TOO_LARGE;
} }
/* Validate lanes */
if (ARGON2_MIN_LANES > context->lanes) {
return ARGON2_LANES_TOO_FEW;
}
if (ARGON2_MAX_LANES < context->lanes) {
return ARGON2_LANES_TOO_MANY;
}
/* Validate threads */ /* Validate threads */
if (ARGON2_MIN_THREADS > context->threads) { if (ARGON2_MIN_THREADS > context->threads) {
return ARGON2_THREADS_TOO_FEW; return ARGON2_THREADS_TOO_FEW;