diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-07 08:21:44 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2025-07-07 08:21:44 +0200 |
| commit | c11730490ad68737120d569b9760e2c35e28977e (patch) | |
| tree | 199c6e305cfe96a74616865e80aadc52696e607a /libbb/hash_hmac.c | |
| parent | 1a0913d57ce8287703cfe666d9240e3a147ea30d (diff) | |
libbb/yescrypt: remove redundant SHA256 HMAC implementation
function old new delta
hmac_blocks - 88 +88
static.PBKDF2_SHA256 176 213 +37
yescrypt_kdf32_body 1046 1052 +6
static.smix 759 762 +3
hmac_block 88 64 -24
HMAC_SHA256_Final 53 - -53
HMAC_SHA256_Buf 58 - -58
HMAC_SHA256_Init 159 - -159
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 3/1 up/down: 134/-294) Total: -160 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/hash_hmac.c')
| -rw-r--r-- | libbb/hash_hmac.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libbb/hash_hmac.c b/libbb/hash_hmac.c index 8cf936949..9e48e0f51 100644 --- a/libbb/hash_hmac.c +++ b/libbb/hash_hmac.c @@ -18,7 +18,7 @@ // if we often need HMAC hmac with the same key. // // text is often given in disjoint pieces. -void FAST_FUNC hmac_begin(hmac_ctx_t *ctx, uint8_t *key, unsigned key_size, md5sha_begin_func *begin) +void FAST_FUNC hmac_begin(hmac_ctx_t *ctx, const uint8_t *key, unsigned key_size, md5sha_begin_func *begin) { #if HMAC_ONLY_SHA256 #define begin sha256_begin @@ -64,6 +64,14 @@ unsigned FAST_FUNC hmac_end(hmac_ctx_t *ctx, uint8_t *out) return sha_end(&ctx->hashed_key_xor_opad, out); } +unsigned FAST_FUNC hmac_block(const uint8_t *key, unsigned key_size, md5sha_begin_func *begin, const void *in, unsigned sz, uint8_t *out) +{ + hmac_ctx_t ctx; + hmac_begin(&ctx, key, key_size, begin); + hmac_hash(&ctx, in, sz); + return hmac_end(&ctx, out); +} + /* TLS helpers */ void FAST_FUNC hmac_hash_v( |
