Move "sha256-hash a memory array and produce the digest" helper to libbb
This commit was genuinely broken at the time (not related to our build system): libbb/yescrypt eklenirken (2025-07-06 - 2025-07-07 arasi) once unutulan kaynak dosyalari (pw_encrypt_yes.c, hash_sha256_block.c, pw_ascii64.c), ardindan 64-bit'te derlenmeyen bir 'buflen' degiskeni (alg-yescrypt-kdf.c) vardi - busybox'in kendi kodundaki gercek hatalar (e5d3a8763 ile duzeltildi)
No binary (build failed)
—
(log yok)
| @@ -2233,6 +2233,7 @@ enum { | |
| SHA512_OUTSIZE = 64, | |
| SHA3_OUTSIZE = 28, | |
| }; | |
| + | void FAST_FUNC sha256_block(const void *in, size_t len, uint8_t hash[32]); |
| extern uint32_t *global_crc32_table; | |
| uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; | |
| @@ -25,38 +25,22 @@ | |
| * SUCH DAMAGE. | |
| */ | |
| - | /** |
| - | * SHA256_Buf(in, len, digest): |
| - | * Compute the SHA256 hash of ${len} bytes from ${in} and write it to ${digest}. |
| - | */ |
| - | void |
| - | SHA256_Buf(const void * in, size_t len, uint8_t digest[32]) |
| - | { |
| - | sha256_ctx_t ctx; |
| - | sha256_begin(&ctx); |
| - | sha256_hash(&ctx, in, len); |
| - | sha256_end(&ctx, digest); |
| - | } |
| - | |
| /** | |
| * HMAC_SHA256_Init(ctx, K, Klen): | |
| * Initialize the HMAC-SHA256 context ${ctx} with ${Klen} bytes of key from | |
| * ${K}. | |
| */ | |
| static void | |
| - | HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen) |
| + | HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, const void *_K, size_t Klen) |
| { | |
| uint8_t pad[64]; | |
| uint8_t khash[32]; | |
| - | const uint8_t * K = _K; |
| + | const uint8_t *K = _K; |
| size_t i; | |
| /* If Klen > 64, the key is really SHA256(K). */ | |
| if (Klen > 64) { | |
| - | // SHA256_Init(&ctx->ictx); |
| - | // _SHA256_Update(&ctx->ictx, K, Klen, tmp32); |
| - | // _SHA256_Final(khash, &ctx->ictx, tmp32); |
| - | SHA256_Buf(K, Klen, khash); |
| + | sha256_block(K, Klen, khash); |
| K = khash; | |
| Klen = 32; | |
| } | |
| @@ -81,7 +65,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen) | |
| * Input ${len} bytes from ${in} into the HMAC-SHA256 context ${ctx}. | |
| */ | |
| static void | |
| - | HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void * in, size_t len) |
| + | HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx, const void *in, size_t len) |
| { | |
| /* Feed data to the inner SHA256 operation. */ | |
| sha256_hash(&ctx->ictx, in, len); | |
| @@ -93,7 +77,7 @@ HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void * in, size_t len) | |
| * buffer ${digest}. | |
| */ | |
| static void | |
| - | HMAC_SHA256_Final(uint8_t digest[32], HMAC_SHA256_CTX * ctx) |
| + | HMAC_SHA256_Final(uint8_t digest[32], HMAC_SHA256_CTX *ctx) |
| { | |
| uint8_t ihash[32]; | |
| @@ -34,12 +34,6 @@ | |
| #define HMAC_SHA256_Buf libcperciva_HMAC_SHA256_Buf | |
| #define HMAC_SHA256_CTX libcperciva_HMAC_SHA256_CTX | |
| - | /** |
| - | * SHA256_Buf(in, len, digest): |
| - | * Compute the SHA256 hash of ${len} bytes from ${in} and write it to ${digest}. |
| - | */ |
| - | extern void SHA256_Buf(const void *, size_t, uint8_t[32]); |
| - | |
| /* Context structure for HMAC-SHA256 operations. */ | |
| typedef struct { | |
| sha256_ctx_t ictx; | |
| @@ -945,7 +945,7 @@ static int yescrypt_kdf32_body( | |
| size_t clen = /*buflen:*/32; | |
| if (clen > sizeof(dk)) | |
| clen = sizeof(dk); | |
| - | SHA256_Buf(sha256, sizeof(sha256), dk); |
| + | sha256_block(sha256, sizeof(sha256), dk); |
| memcpy(buf32, dk, clen); | |
| } | |
| } | |