libbb/yescrypt: code shrink
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)
| @@ -2189,6 +2189,8 @@ char *decode_base64(char *dst, const char **pp_src) FAST_FUNC; | |
| char *decode_base32(char *dst, const char **pp_src) FAST_FUNC; | |
| void read_base64(FILE *src_stream, FILE *dst_stream, int flags) FAST_FUNC; | |
| + | int FAST_FUNC i2a64(int i); |
| + | |
| typedef struct md5_ctx_t { | |
| uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */ | |
| void (*process_block)(struct md5_ctx_t*) FAST_FUNC; | |
| @@ -13,11 +13,10 @@ | |
| #endif | |
| #include "libbb.h" | |
| - | /* static const uint8_t ascii64[] ALIGN1 = |
| + | /* 0..63 -> |
| * "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | |
| */ | |
| - | |
| - | static int i64c(int i) |
| + | int FAST_FUNC i2a64(int i) |
| { | |
| i &= 0x3f; | |
| if (i == 0) | |
| @@ -45,8 +44,8 @@ int FAST_FUNC crypt_make_rand64encoded(char *p, int cnt /*, int x */) | |
| * It has no problem with visibly alternating lowest bit | |
| * but is also weak in cryptographic sense + needs div, | |
| * which needs more code (and slower) on many CPUs */ | |
| - | *p++ = i64c(x >> 16); |
| - | *p++ = i64c(x >> 22); |
| + | *p++ = i2a64(x >> 16); |
| + | *p++ = i2a64(x >> 22); |
| } while (--cnt); | |
| *p = '\0'; | |
| return x; | |
| @@ -120,8 +119,7 @@ static char* | |
| to64(char *s, unsigned v, int n) | |
| { | |
| while (--n >= 0) { | |
| - | /* *s++ = ascii64[v & 0x3f]; */ |
| - | *s++ = i64c(v); |
| + | *s++ = i2a64(v); |
| v >>= 6; | |
| } | |
| return s; | |
| @@ -703,10 +703,10 @@ to64_msb_first(char *s, unsigned v) | |
| *s++ = ascii64[(v >> 6) & 0x3f]; /* bits 11..6 */ | |
| *s = ascii64[v & 0x3f]; /* bits 5..0 */ | |
| #endif | |
| - | *s++ = i64c(v >> 18); /* bits 23..18 */ |
| - | *s++ = i64c(v >> 12); /* bits 17..12 */ |
| - | *s++ = i64c(v >> 6); /* bits 11..6 */ |
| - | *s = i64c(v); /* bits 5..0 */ |
| + | *s++ = i2a64(v >> 18); /* bits 23..18 */ |
| + | *s++ = i2a64(v >> 12); /* bits 17..12 */ |
| + | *s++ = i2a64(v >> 6); /* bits 11..6 */ |
| + | *s = i2a64(v); /* bits 5..0 */ |
| } | |
| static char * | |
| @@ -107,7 +107,7 @@ HMAC_SHA256_Buf(const void *K, size_t Klen, const void *in, size_t len, | |
| * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and | |
| * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). | |
| */ | |
| - | void |
| + | static void |
| PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, | |
| const uint8_t *salt, size_t saltlen, | |
| uint64_t c, uint8_t *buf, size_t dkLen) | |
| @@ -24,26 +24,8 @@ | |
| * SUCH DAMAGE. | |
| */ | |
| - | /* |
| - | * Use #defines in order to avoid namespace collisions with anyone else's |
| - | * SHA256 code (e.g., the code in OpenSSL). |
| - | */ |
| - | #define HMAC_SHA256_Init libcperciva_HMAC_SHA256_Init |
| - | #define HMAC_SHA256_Update libcperciva_HMAC_SHA256_Update |
| - | #define HMAC_SHA256_Final libcperciva_HMAC_SHA256_Final |
| - | #define HMAC_SHA256_Buf libcperciva_HMAC_SHA256_Buf |
| - | #define HMAC_SHA256_CTX libcperciva_HMAC_SHA256_CTX |
| - | |
| /* Context structure for HMAC-SHA256 operations. */ | |
| typedef struct { | |
| sha256_ctx_t ictx; | |
| sha256_ctx_t octx; | |
| } HMAC_SHA256_CTX; | |
| - | |
| - | /** |
| - | * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): |
| - | * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and |
| - | * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). |
| - | */ |
| - | extern void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, |
| - | uint64_t, uint8_t *, size_t); |
| @@ -88,7 +88,7 @@ static uint8_t *encode64_uint32_fixed( | |
| for (bits = 0; bits < srcbits; bits += 6) { | |
| if (dstlen < 2) | |
| return NULL; | |
| - | *dst++ = itoa64[src & 0x3f]; |
| + | *dst++ = i2a64(src); |
| dstlen--; | |
| src >>= 6; | |
| } | |
| @@ -124,12 +124,6 @@ VECTOR_TO_CPU(be,32); | |
| VECTOR_TO_CPU(be,64); | |
| - | const unsigned char ascii64[65] = |
| - | "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| - | /* 0000000000111111111122222222223333333333444444444455555555556666 */ |
| - | /* 0123456789012345678901234567890123456789012345678901234567890123 */ |
| - | #define itoa64 ascii64 |
| - | |
| #define YESCRYPT_INTERNAL | |
| #include "alg-sha256.h" | |
| #include "alg-yescrypt.h" | |