Let crypto_pwhash_str_verify work both with Argon2i and Argon2id

This commit is contained in:
Frank Denis 2017-06-27 16:33:09 +02:00
parent 2805a23574
commit beac509209

View File

@ -1,5 +1,6 @@
#include <errno.h>
#include <string.h>
#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 *