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