Browse Source

Add crypto_pwhash_argon2i_ALG_ARGON2I13

next
Frank Denis 8 years ago
parent
commit
d7f5877df5
  1. 11
      src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c
  2. 2
      src/libsodium/crypto_pwhash/crypto_pwhash.c
  3. 2
      src/libsodium/include/sodium/crypto_pwhash.h
  4. 6
      src/libsodium/include/sodium/crypto_pwhash_argon2i.h
  5. 1
      test/default/pwhash.c

11
src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c

@ -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) {

2
src/libsodium/crypto_pwhash/crypto_pwhash.c

@ -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

2
src/libsodium/include/sodium/crypto_pwhash.h

@ -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);

6
src/libsodium/include/sodium/crypto_pwhash_argon2i.h

@ -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

1
test/default/pwhash.c

@ -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());

Loading…
Cancel
Save