summaryrefslogtreecommitdiff
path: root/git-2.43.0-core-crypto-hmac.patch
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-08-05 02:05:39 +0000
committerCoprDistGit <infra@openeuler.org>2024-08-05 02:05:39 +0000
commitd23cd896d4fde33b5e323ec84af1c1472c59c461 (patch)
tree1415b8bb99a5761240c41c8b1615a381cc84c16c /git-2.43.0-core-crypto-hmac.patch
parent96b302672a8bc92199343579778067efaefe48c7 (diff)
automatic import of gitopeneuler24.03_LTS
Diffstat (limited to 'git-2.43.0-core-crypto-hmac.patch')
-rw-r--r--git-2.43.0-core-crypto-hmac.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/git-2.43.0-core-crypto-hmac.patch b/git-2.43.0-core-crypto-hmac.patch
new file mode 100644
index 0000000..26343f8
--- /dev/null
+++ b/git-2.43.0-core-crypto-hmac.patch
@@ -0,0 +1,70 @@
+diff -ur b/builtin/receive-pack.c a/builtin/receive-pack.c
+--- b/builtin/receive-pack.c 2023-11-20 03:07:41.000000000 +0100
++++ a/builtin/receive-pack.c 2023-12-06 15:34:28.294170714 +0100
+@@ -40,6 +40,8 @@
+ #include "worktree.h"
+ #include "shallow.h"
+ #include "parse-options.h"
++#include <openssl/hmac.h>
++#include <openssl/evp.h>
+
+ static const char * const receive_pack_usage[] = {
+ N_("git receive-pack <git-dir>"),
+@@ -538,43 +540,11 @@
+ return 0;
+ }
+
+-static void hmac_hash(unsigned char *out,
++static inline void hmac_hash(unsigned char *out,
+ const char *key_in, size_t key_len,
+ const char *text, size_t text_len)
+ {
+- unsigned char key[GIT_MAX_BLKSZ];
+- unsigned char k_ipad[GIT_MAX_BLKSZ];
+- unsigned char k_opad[GIT_MAX_BLKSZ];
+- int i;
+- git_hash_ctx ctx;
+-
+- /* RFC 2104 2. (1) */
+- memset(key, '\0', GIT_MAX_BLKSZ);
+- if (the_hash_algo->blksz < key_len) {
+- the_hash_algo->init_fn(&ctx);
+- the_hash_algo->update_fn(&ctx, key_in, key_len);
+- the_hash_algo->final_fn(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) */
+- the_hash_algo->init_fn(&ctx);
+- the_hash_algo->update_fn(&ctx, k_ipad, sizeof(k_ipad));
+- the_hash_algo->update_fn(&ctx, text, text_len);
+- the_hash_algo->final_fn(out, &ctx);
+-
+- /* RFC 2104 2. (6) & (7) */
+- the_hash_algo->init_fn(&ctx);
+- the_hash_algo->update_fn(&ctx, k_opad, sizeof(k_opad));
+- the_hash_algo->update_fn(&ctx, out, the_hash_algo->rawsz);
+- the_hash_algo->final_fn(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 -ur b/Makefile a/Makefile
+--- b/Makefile 2023-11-20 03:07:41.000000000 +0100
++++ a/Makefile 2023-12-06 15:35:08.506316431 +0100
+@@ -2123,6 +2123,8 @@
+ EXTLIBS += -lcrypto -lssl
+ endif
+
++EXTLIBS += -lcrypto
++
+ ifneq ($(PROCFS_EXECUTABLE_PATH),)
+ procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
+ BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'