Blame SOURCES/git-2.38.1-core-crypto-hmac.patch

ecd892
diff -ur a/builtin/receive-pack.c b/builtin/receive-pack.c
4b9f28
--- a/builtin/receive-pack.c	2022-10-07 06:48:26.000000000 +0200
4b9f28
+++ b/builtin/receive-pack.c	2022-11-21 16:34:02.417278135 +0100
4b9f28
@@ -30,6 +30,8 @@
ecd892
 #include "commit-reach.h"
ecd892
 #include "worktree.h"
ecd892
 #include "shallow.h"
ecd892
+#include <openssl/hmac.h>	
ecd892
+#include <openssl/evp.h>
ecd892
 
ecd892
 static const char * const receive_pack_usage[] = {
ecd892
 	N_("git receive-pack <git-dir>"),
4b9f28
@@ -528,43 +530,11 @@
ecd892
 	return 0;
ecd892
 }
ecd892
 
ecd892
-static void hmac_hash(unsigned char *out,
ecd892
+static inline void hmac_hash(unsigned char *out,
ecd892
 		      const char *key_in, size_t key_len,
ecd892
 		      const char *text, size_t text_len)
ecd892
 {
ecd892
-	unsigned char key[GIT_MAX_BLKSZ];
ecd892
-	unsigned char k_ipad[GIT_MAX_BLKSZ];
ecd892
-	unsigned char k_opad[GIT_MAX_BLKSZ];
ecd892
-	int i;
ecd892
-	git_hash_ctx ctx;
ecd892
-
ecd892
-	/* RFC 2104 2. (1) */
ecd892
-	memset(key, '\0', GIT_MAX_BLKSZ);
ecd892
-	if (the_hash_algo->blksz < key_len) {
ecd892
-		the_hash_algo->init_fn(&ctx;;
ecd892
-		the_hash_algo->update_fn(&ctx, key_in, key_len);
ecd892
-		the_hash_algo->final_fn(key, &ctx;;
ecd892
-	} else {
ecd892
-		memcpy(key, key_in, key_len);
ecd892
-	}
ecd892
-
ecd892
-	/* RFC 2104 2. (2) & (5) */
ecd892
-	for (i = 0; i < sizeof(key); i++) {
ecd892
-		k_ipad[i] = key[i] ^ 0x36;
ecd892
-		k_opad[i] = key[i] ^ 0x5c;
ecd892
-	}
ecd892
-
ecd892
-	/* RFC 2104 2. (3) & (4) */
ecd892
-	the_hash_algo->init_fn(&ctx;;
ecd892
-	the_hash_algo->update_fn(&ctx, k_ipad, sizeof(k_ipad));
ecd892
-	the_hash_algo->update_fn(&ctx, text, text_len);
ecd892
-	the_hash_algo->final_fn(out, &ctx;;
ecd892
-
ecd892
-	/* RFC 2104 2. (6) & (7) */
ecd892
-	the_hash_algo->init_fn(&ctx;;
ecd892
-	the_hash_algo->update_fn(&ctx, k_opad, sizeof(k_opad));
ecd892
-	the_hash_algo->update_fn(&ctx, out, the_hash_algo->rawsz);
ecd892
-	the_hash_algo->final_fn(out, &ctx;;
ecd892
+	HMAC(EVP_sha1(), key_in, key_len, text, text_len, out, NULL);
ecd892
 }
ecd892
 
ecd892
 static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
ecd892
diff -ur a/Makefile b/Makefile
4b9f28
--- a/Makefile	2022-10-07 06:48:26.000000000 +0200
4b9f28
+++ b/Makefile	2022-11-21 16:35:56.986792752 +0100
4b9f28
@@ -2008,6 +2008,8 @@
4b9f28
 	EXTLIBS += -lcrypto -lssl
ecd892
 endif
ecd892
 
ecd892
+EXTLIBS += -lcrypto
ecd892
+
ecd892
 ifneq ($(PROCFS_EXECUTABLE_PATH),)
ecd892
 	procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
ecd892
 	BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'