From 4a75300b45d69cb0e8db7752072fb937b63b3fc2 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 16 Aug 2020 11:31:20 +0200 Subject: [PATCH] Validate argon2 lanes before memory cost --- .../crypto_pwhash/argon2/argon2-core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index 26d8d0f0..90c6d073 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -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 */ if (ARGON2_MIN_MEMORY > context->m_cost) { return ARGON2_MEMORY_TOO_LITTLE; @@ -347,15 +356,6 @@ argon2_validate_inputs(const argon2_context *context) 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 */ if (ARGON2_MIN_THREADS > context->threads) { return ARGON2_THREADS_TOO_FEW;