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

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