From 88a1499f7de6994fb135686757aba1978c3c8dca Mon Sep 17 00:00:00 2001 From: dchidindu5 Date: Thu, 19 Mar 2026 01:21:33 +0100 Subject: [PATCH] Fix misleading comments in SHA-crypt and derived code Fixes #5951 --- src/gost12256hash_fmt_plug.c | 3 ++- src/gost94hash_fmt_plug.c | 3 ++- src/sm3crypt_fmt_plug.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gost12256hash_fmt_plug.c b/src/gost12256hash_fmt_plug.c index b60e2b3400..6503721235 100644 --- a/src/gost12256hash_fmt_plug.c +++ b/src/gost12256hash_fmt_plug.c @@ -258,7 +258,8 @@ static int crypt_all(int *pcount, struct db_salt *salt) /* Start computation of S byte sequence. */ GOST34112012Init(&alt_ctx, 256); - /* For every character in the password add the entire password. */ + /* Repeat the following 16+A[0] times, where A[0] represents the + first byte in digest A interpreted as an 8-bit unsigned value */ for (cnt = 0; cnt < 16 + ((unsigned char*)crypt_out[index])[0]; ++cnt) GOST34112012Update(&alt_ctx, cur_salt->salt, cur_salt->len); diff --git a/src/gost94hash_fmt_plug.c b/src/gost94hash_fmt_plug.c index 6992ec4758..a42d19c8f4 100644 --- a/src/gost94hash_fmt_plug.c +++ b/src/gost94hash_fmt_plug.c @@ -258,7 +258,8 @@ static int crypt_all(int *pcount, struct db_salt *salt) /* Start computation of S byte sequence. */ john_gost_init(&alt_ctx); - /* For every character in the password add the entire password. */ + /* Repeat the following 16+A[0] times, where A[0] represents the + first byte in digest A interpreted as an 8-bit unsigned value */ for (cnt = 0; cnt < 16 + ((unsigned char*)crypt_out[index])[0]; ++cnt) john_gost_update(&alt_ctx, cur_salt->salt, cur_salt->len); diff --git a/src/sm3crypt_fmt_plug.c b/src/sm3crypt_fmt_plug.c index 0fd050532e..7f754e1d2d 100644 --- a/src/sm3crypt_fmt_plug.c +++ b/src/sm3crypt_fmt_plug.c @@ -255,7 +255,8 @@ static int crypt_all(int *pcount, struct db_salt *salt) /* Start computation of S byte sequence. */ sm3_init(&alt_ctx); - /* For every character in the password add the entire password. */ + /* Repeat the following 16+A[0] times, where A[0] represents the + first byte in digest A interpreted as an 8-bit unsigned value */ for (cnt = 0; cnt < 16 + ((unsigned char*)crypt_out[index])[0]; ++cnt) sm3_update(&alt_ctx, cur_salt->salt, cur_salt->len);