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

6ced29
diff -ru git-2.18.1/builtin/receive-pack.c git-2.18.1_patched/builtin/receive-pack.c
6ced29
--- git-2.18.1/builtin/receive-pack.c	2018-09-27 22:44:44.000000000 +0200
6ced29
+++ git-2.18.1_patched/builtin/receive-pack.c	2019-06-11 11:19:52.887797134 +0200
6ced29
@@ -26,6 +26,8 @@
6ced29
 #include "oidset.h"
6ced29
 #include "packfile.h"
6ced29
 #include "protocol.h"
6ced29
+#include <openssl/hmac.h>
6ced29
+#include <openssl/evp.h>
6ced29
 
6ced29
 static const char * const receive_pack_usage[] = {
6ced29
 	N_("git receive-pack <git-dir>"),
6ced29
@@ -419,43 +421,11 @@
6ced29
 
6ced29
 #define HMAC_BLOCK_SIZE 64
6ced29
 
6ced29
-static void hmac_sha1(unsigned char *out,
6ced29
+static inline void hmac_sha1(unsigned char *out,
6ced29
 		      const char *key_in, size_t key_len,
6ced29
 		      const char *text, size_t text_len)
6ced29
 {
6ced29
-	unsigned char key[HMAC_BLOCK_SIZE];
6ced29
-	unsigned char k_ipad[HMAC_BLOCK_SIZE];
6ced29
-	unsigned char k_opad[HMAC_BLOCK_SIZE];
6ced29
-	int i;
6ced29
-	git_SHA_CTX ctx;
6ced29
-
6ced29
-	/* RFC 2104 2. (1) */
6ced29
-	memset(key, '\0', HMAC_BLOCK_SIZE);
6ced29
-	if (HMAC_BLOCK_SIZE < key_len) {
6ced29
-		git_SHA1_Init(&ctx;;
6ced29
-		git_SHA1_Update(&ctx, key_in, key_len);
6ced29
-		git_SHA1_Final(key, &ctx;;
6ced29
-	} else {
6ced29
-		memcpy(key, key_in, key_len);
6ced29
-	}
6ced29
-
6ced29
-	/* RFC 2104 2. (2) & (5) */
6ced29
-	for (i = 0; i < sizeof(key); i++) {
6ced29
-		k_ipad[i] = key[i] ^ 0x36;
6ced29
-		k_opad[i] = key[i] ^ 0x5c;
6ced29
-	}
6ced29
-
6ced29
-	/* RFC 2104 2. (3) & (4) */
6ced29
-	git_SHA1_Init(&ctx;;
6ced29
-	git_SHA1_Update(&ctx, k_ipad, sizeof(k_ipad));
6ced29
-	git_SHA1_Update(&ctx, text, text_len);
6ced29
-	git_SHA1_Final(out, &ctx;;
6ced29
-
6ced29
-	/* RFC 2104 2. (6) & (7) */
6ced29
-	git_SHA1_Init(&ctx;;
6ced29
-	git_SHA1_Update(&ctx, k_opad, sizeof(k_opad));
6ced29
-	git_SHA1_Update(&ctx, out, GIT_SHA1_RAWSZ);
6ced29
-	git_SHA1_Final(out, &ctx;;
6ced29
+	HMAC(EVP_sha1(), key_in, key_len, text, text_len, out, NULL);
6ced29
 }
6ced29
 
6ced29
 static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
6ced29
diff -ru git-2.18.1/Makefile git-2.18.1_patched/Makefile
6ced29
--- git-2.18.1/Makefile	2018-09-27 22:44:44.000000000 +0200
6ced29
+++ git-2.18.1_patched/Makefile	2019-06-10 17:28:26.137986964 +0200
6ced29
@@ -1721,6 +1721,8 @@
6ced29
 	BASIC_CFLAGS += -DHAVE_GETDELIM
6ced29
 endif
6ced29
 
6ced29
+EXTLIBS += -lcrypto
6ced29
+
6ced29
 ifneq ($(PROCFS_EXECUTABLE_PATH),)
6ced29
 	procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
6ced29
 	BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'