From 1b3bbed828ccecbf99271755b7066d25e7d50f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Ho=C5=A1ek?= Date: Wed, 11 Feb 2026 13:04:31 +0100 Subject: [PATCH] lib/crypt-sha*, lib/crypt-sm3: fix misleading comment A copied comment misrepresents the calculation step of the S byte sequence in the crypt algorithms based on SHA2 and sm3. Replace it with an actual description of what is happening. --- lib/crypt-sha256.c | 3 ++- lib/crypt-sha512.c | 3 ++- lib/crypt-sm3.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/crypt-sha256.c b/lib/crypt-sha256.c index 88870aed..e6bfc625 100644 --- a/lib/crypt-sha256.c +++ b/lib/crypt-sha256.c @@ -212,7 +212,8 @@ crypt_sha256crypt_rn (const char *phrase, size_t phr_size, /* Start computation of S byte sequence. */ SHA256_Init (ctx); - /* For every character in the password add the entire password. */ + /* Add the salt n times where n is the value of the first byte of the + intermediate result plus 16. */ for (cnt = 0; cnt < (size_t) 16 + (size_t) result[0]; ++cnt) SHA256_Update (ctx, salt, salt_size); diff --git a/lib/crypt-sha512.c b/lib/crypt-sha512.c index 5544c49c..72d56288 100644 --- a/lib/crypt-sha512.c +++ b/lib/crypt-sha512.c @@ -214,7 +214,8 @@ crypt_sha512crypt_rn (const char *phrase, size_t phr_size, /* Start computation of S byte sequence. */ SHA512_Init (ctx); - /* For every character in the password add the entire password. */ + /* Add the salt n times where n is the value of the first byte of the + intermediate result plus 16. */ for (cnt = 0; cnt < (size_t) 16 + (size_t) result[0]; ++cnt) SHA512_Update (ctx, salt, salt_size); diff --git a/lib/crypt-sm3.c b/lib/crypt-sm3.c index 1fbb960c..0d1a7ae3 100644 --- a/lib/crypt-sm3.c +++ b/lib/crypt-sm3.c @@ -213,7 +213,8 @@ crypt_sm3crypt_rn (const char *phrase, size_t phr_size, /* Start computation of S byte sequence. */ sm3_init (ctx); - /* For every character in the password add the entire password. */ + /* Add the salt n times where n is the value of the first byte of the + intermediate result plus 16. */ for (cnt = 0; cnt < (size_t) 16 + (size_t) result[0]; ++cnt) sm3_update (ctx, salt, salt_size);