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

a98108
diff -ur a/builtin/receive-pack.c b/builtin/receive-pack.c
a98108
--- a/builtin/receive-pack.c	2020-04-20 17:52:30.000000000 +0200
a98108
+++ b/builtin/receive-pack.c	2020-05-26 16:03:25.809849961 +0200
a98108
@@ -28,6 +28,8 @@
a98108
 #include "protocol.h"
a98108
 #include "commit-reach.h"
a98108
 #include "worktree.h"
a98108
+#include <openssl/hmac.h>	
a98108
+#include <openssl/evp.h>
a98108
 
a98108
 static const char * const receive_pack_usage[] = {
a98108
 	N_("git receive-pack <git-dir>"),
a98108
@@ -418,43 +420,11 @@
a98108
 	return 0;
a98108
 }
a98108
 
a98108
-static void hmac(unsigned char *out,
a98108
+static inline void hmac(unsigned char *out,
a98108
 		      const char *key_in, size_t key_len,
a98108
 		      const char *text, size_t text_len)
a98108
 {
a98108
-	unsigned char key[GIT_MAX_BLKSZ];
a98108
-	unsigned char k_ipad[GIT_MAX_BLKSZ];
a98108
-	unsigned char k_opad[GIT_MAX_BLKSZ];
a98108
-	int i;
a98108
-	git_hash_ctx ctx;
a98108
-
a98108
-	/* RFC 2104 2. (1) */
a98108
-	memset(key, '\0', GIT_MAX_BLKSZ);
a98108
-	if (the_hash_algo->blksz < key_len) {
a98108
-		the_hash_algo->init_fn(&ctx;;
a98108
-		the_hash_algo->update_fn(&ctx, key_in, key_len);
a98108
-		the_hash_algo->final_fn(key, &ctx;;
a98108
-	} else {
a98108
-		memcpy(key, key_in, key_len);
a98108
-	}
a98108
-
a98108
-	/* RFC 2104 2. (2) & (5) */
a98108
-	for (i = 0; i < sizeof(key); i++) {
a98108
-		k_ipad[i] = key[i] ^ 0x36;
a98108
-		k_opad[i] = key[i] ^ 0x5c;
a98108
-	}
a98108
-
a98108
-	/* RFC 2104 2. (3) & (4) */
a98108
-	the_hash_algo->init_fn(&ctx;;
a98108
-	the_hash_algo->update_fn(&ctx, k_ipad, sizeof(k_ipad));
a98108
-	the_hash_algo->update_fn(&ctx, text, text_len);
a98108
-	the_hash_algo->final_fn(out, &ctx;;
a98108
-
a98108
-	/* RFC 2104 2. (6) & (7) */
a98108
-	the_hash_algo->init_fn(&ctx;;
a98108
-	the_hash_algo->update_fn(&ctx, k_opad, sizeof(k_opad));
a98108
-	the_hash_algo->update_fn(&ctx, out, the_hash_algo->rawsz);
a98108
-	the_hash_algo->final_fn(out, &ctx;;
a98108
+	HMAC(EVP_sha1(), key_in, key_len, text, text_len, out, NULL);
a98108
 }
a98108
 
a98108
 static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
a98108
diff -ur a/Makefile b/Makefile
a98108
--- a/Makefile	2020-04-20 17:52:30.000000000 +0200
a98108
+++ b/Makefile	2020-05-26 16:04:48.672551647 +0200
a98108
@@ -1832,6 +1832,8 @@
a98108
 	BASIC_CFLAGS += -DHAVE_GETDELIM
a98108
 endif
a98108
 
a98108
+EXTLIBS += -lcrypto
a98108
+
a98108
 ifneq ($(PROCFS_EXECUTABLE_PATH),)
a98108
 	procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
a98108
 	BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'