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

e9dbaa
diff -ur a/builtin/receive-pack.c b/builtin/receive-pack.c
e9dbaa
--- a/builtin/receive-pack.c	2020-06-01 17:49:27.000000000 +0200
e9dbaa
+++ b/builtin/receive-pack.c	2020-06-15 15:28:48.149268576 +0200
e9dbaa
@@ -29,6 +29,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>"),
e9dbaa
@@ -419,43 +421,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
e9dbaa
--- a/Makefile	2020-06-01 17:49:27.000000000 +0200
e9dbaa
+++ b/Makefile	2020-06-15 15:00:45.212758547 +0200
e9dbaa
@@ -1830,6 +1830,8 @@
e9dbaa
 	BASIC_CFLAGS += -DHAVE_GETDELIM
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)"'