aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-01-31 13:55:31 +0100
committerJunio C Hamano <gitster@pobox.com>2025-01-31 10:06:11 -0800
commit0578f1e66aa381356bfe2f53decf3864d88d23d3 (patch)
treeca26e9efacec048463fe529f72998ba59924f479 /builtin/receive-pack.c
parenthash: provide generic wrappers to update hash contexts (diff)
downloadgit-0578f1e66aa381356bfe2f53decf3864d88d23d3.tar.gz
git-0578f1e66aa381356bfe2f53decf3864d88d23d3.zip
global: adapt callers to use generic hash context helpers
Adapt callers to use generic hash context helpers instead of using the hash algorithm to update them. This makes the callsites easier to reason about and removes the possibility that the wrong hash algorithm is used to update the hash context's state. And as a nice side effect this also gets rid of a bunch of users of `the_hash_algo`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r--builtin/receive-pack.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index d2360c453c..cc358600ca 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -572,8 +572,8 @@ static void hmac_hash(unsigned char *out,
memset(key, '\0', GIT_MAX_BLKSZ);
if (the_hash_algo->blksz < key_len) {
the_hash_algo->init_fn(&ctx);
- the_hash_algo->update_fn(&ctx, key_in, key_len);
- the_hash_algo->final_fn(key, &ctx);
+ git_hash_update(&ctx, key_in, key_len);
+ git_hash_final(key, &ctx);
} else {
memcpy(key, key_in, key_len);
}
@@ -586,15 +586,15 @@ static void hmac_hash(unsigned char *out,
/* RFC 2104 2. (3) & (4) */
the_hash_algo->init_fn(&ctx);
- the_hash_algo->update_fn(&ctx, k_ipad, sizeof(k_ipad));
- the_hash_algo->update_fn(&ctx, text, text_len);
- the_hash_algo->final_fn(out, &ctx);
+ git_hash_update(&ctx, k_ipad, sizeof(k_ipad));
+ git_hash_update(&ctx, text, text_len);
+ git_hash_final(out, &ctx);
/* RFC 2104 2. (6) & (7) */
the_hash_algo->init_fn(&ctx);
- the_hash_algo->update_fn(&ctx, k_opad, sizeof(k_opad));
- the_hash_algo->update_fn(&ctx, out, the_hash_algo->rawsz);
- the_hash_algo->final_fn(out, &ctx);
+ git_hash_update(&ctx, k_opad, sizeof(k_opad));
+ git_hash_update(&ctx, out, the_hash_algo->rawsz);
+ git_hash_final(out, &ctx);
}
static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)