Skip to content

Commit

Permalink
Issue different code when verify mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt committed Feb 22, 2016
1 parent 6525f74 commit 7438782
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions include/argon2.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ typedef enum Argon2_ErrorCodes {

ARGON2_DECODING_LENGTH_FAIL = 34,

ARGON2_VERIFY_MISMATCH = 35,

ARGON2_ERROR_CODES_LENGTH /* Do NOT remove; Do NOT add error codes after
this
error code */
Expand Down
12 changes: 6 additions & 6 deletions src/argon2.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ static const char *Argon2_ErrorMessage[] = {
/*},
{ARGON2_THREAD_FAIL */ "Threading failure",
/*,
{ARGON2_DECODING_LENGTH_FAIL */ "Some of encoded parameters are too long or too short" /*},*/
{ARGON2_DECODING_LENGTH_FAIL */ "Some of encoded parameters are too long or too short",
/*,
{ARGON2_VERIFY_MISMATCH */ "The password does not match the supplied hash" /*},*/
};

int argon2_ctx(argon2_context *context, argon2_type type) {
Expand Down Expand Up @@ -334,15 +336,13 @@ int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
free(ctx.ad);
free(ctx.salt);

if (ret != ARGON2_OK || argon2_compare(out, ctx.out, ctx.outlen)) {
free(out);
free(ctx.out);
return ARGON2_DECODING_FAIL;
if (ret == ARGON2_OK && argon2_compare(out, ctx.out, ctx.outlen)) {
ret = ARGON2_VERIFY_MISMATCH;
}
free(out);
free(ctx.out);

return ARGON2_OK;
return ret;
}

int argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen) {
Expand Down

0 comments on commit 7438782

Please sign in to comment.