Module Name:    src
Committed By:   nia
Date:           Tue Oct 12 10:51:33 UTC 2021

Modified Files:
        src/lib/libcrypt: crypt-argon2.c

Log Message:
crypt-argon2: Properly honor user's version number.

Follow upstream by defaulting to 0x10 if it's not specified.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libcrypt/crypt-argon2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.3 src/lib/libcrypt/crypt-argon2.c:1.4
--- src/lib/libcrypt/crypt-argon2.c:1.3	Tue Oct 12 09:40:38 2021
+++ src/lib/libcrypt/crypt-argon2.c	Tue Oct 12 10:51:33 2021
@@ -100,7 +100,7 @@ static int decode_option(argon2_context 
 		a += 2;
 		if ((getnum(a, &tmp))<0) { /* on error, default to current */
 			/* should start thinking about aborting */
-			ctx->version = ARGON2_VERSION_NUMBER;
+			ctx->version = ARGON2_VERSION_10;
 		} else {
 			ctx->version = tmp;
 		}
@@ -110,7 +110,7 @@ static int decode_option(argon2_context 
 		 * This is a parameter list, not a version number, use the
 		 * default version.
 		 */
-		ctx->version = ARGON2_VERSION_NUMBER;
+		ctx->version = ARGON2_VERSION_10;
 	}
 
 	/* parse labelled argon2 params */
@@ -184,7 +184,6 @@ __crypt_argon2(const char *pw, const cha
 	/* argon2 variable, default to id */
 	argon2_type atype = Argon2_id;
 	/* default to current argon2 version */
-	int version=ARGON2_VERSION_NUMBER;
 	/* argon2 context to collect params */
 	argon2_context ctx = ARGON2_CONTEXT_INITIALIZER;
 	/* argon2 encoded buffer */
@@ -247,7 +246,7 @@ __crypt_argon2(const char *pw, const cha
 	/* same encoding format as argon2 api, but with original salt */
 	snprintf(rbuf, sizeof(rbuf)-1, "$%s$v=%d$m=%d,t=%d,p=%d$%s$%s",
 			argon2_type2string(atype,0),
-			version,
+			ctx.version,
 			ctx.m_cost,
 			ctx.t_cost,
 			ctx.threads,

Reply via email to