Add crypto_pwhash_argon2i_ALG_ARGON2I13

This commit is contained in:
Frank Denis 2016-04-01 20:48:34 +02:00
parent 384e08b7f4
commit d7f5877df5
5 changed files with 18 additions and 4 deletions

View File

@ -13,6 +13,12 @@
#define STR_HASHBYTES 32U
int
crypto_pwhash_argon2i_alg_argon2i13(void)
{
return crypto_pwhash_argon2i_ALG_ARGON2I13;
}
size_t
crypto_pwhash_argon2i_saltbytes(void)
{
@ -74,8 +80,11 @@ crypto_pwhash_argon2i(unsigned char * const out,
unsigned long long passwdlen,
const unsigned char * const salt,
unsigned long long opslimit,
size_t memlimit)
size_t memlimit, int alg)
{
if (alg != crypto_pwhash_argon2i_ALG_ARGON2I13) {
return -1;
}
memlimit /= 1024U;
if (outlen > ARGON2_MAX_OUTLEN || passwdlen > ARGON2_MAX_PWD_LENGTH ||
opslimit > ARGON2_MAX_TIME || memlimit > ARGON2_MAX_MEMORY) {

View File

@ -80,7 +80,7 @@ crypto_pwhash(unsigned char * const out, unsigned long long outlen,
return -1;
}
return crypto_pwhash_argon2i(out, outlen, passwd, passwdlen, salt,
opslimit, memlimit);
opslimit, memlimit, alg);
}
int

View File

@ -13,7 +13,7 @@
extern "C" {
#endif
#define crypto_pwhash_ALG_ARGON2I13 1
#define crypto_pwhash_ALG_ARGON2I13 crypto_pwhash_argon2i_ALG_ARGON2I13
SODIUM_EXPORT
int crypto_pwhash_alg_argon2i13(void);

View File

@ -12,6 +12,10 @@
extern "C" {
#endif
#define crypto_pwhash_argon2i_ALG_ARGON2I13 1
SODIUM_EXPORT
int crypto_pwhash_argon2i_alg_argon2i13(void);
#define crypto_pwhash_argon2i_SALTBYTES 16U
SODIUM_EXPORT
size_t crypto_pwhash_argon2i_saltbytes(void);
@ -55,7 +59,7 @@ int crypto_pwhash_argon2i(unsigned char * const out,
unsigned long long passwdlen,
const unsigned char * const salt,
unsigned long long opslimit,
size_t memlimit)
size_t memlimit, int alg)
__attribute__ ((warn_unused_result));
SODIUM_EXPORT

View File

@ -353,6 +353,7 @@ int main(void)
crypto_pwhash_memlimit_moderate());
assert(crypto_pwhash_argon2i_memlimit_sensitive() ==
crypto_pwhash_memlimit_sensitive());
assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_argon2i_alg_argon2i13());
assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_ALG_ARGON2I13);
assert(crypto_pwhash_alg_argon2i13() == crypto_pwhash_alg_default());