From beac50920960c00a0a2a9d7372f183d7e500c730 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 27 Jun 2017 16:33:09 +0200 Subject: [PATCH] Let crypto_pwhash_str_verify work both with Argon2i and Argon2id --- src/libsodium/crypto_pwhash/crypto_pwhash.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libsodium/crypto_pwhash/crypto_pwhash.c b/src/libsodium/crypto_pwhash/crypto_pwhash.c index 5bc2db21..3bccfe2b 100644 --- a/src/libsodium/crypto_pwhash/crypto_pwhash.c +++ b/src/libsodium/crypto_pwhash/crypto_pwhash.c @@ -1,5 +1,6 @@ #include +#include #include "crypto_pwhash.h" @@ -154,7 +155,17 @@ crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES], const char * const passwd, unsigned long long passwdlen) { - return crypto_pwhash_argon2i_str_verify(str, passwd, passwdlen); + if (strncmp(str, crypto_pwhash_argon2id_STRPREFIX, + sizeof crypto_pwhash_argon2id_STRPREFIX - 1) == 0) { + return crypto_pwhash_argon2id_str_verify(str, passwd, passwdlen); + } + if (strncmp(str, crypto_pwhash_argon2i_STRPREFIX, + sizeof crypto_pwhash_argon2i_STRPREFIX - 1) == 0) { + return crypto_pwhash_argon2i_str_verify(str, passwd, passwdlen); + } + errno = EINVAL; + + return -1; } const char *