From patchwork Sun Sep 1 16:03:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13786537 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77AC33FC7 for ; Sun, 1 Sep 2024 16:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206605; cv=none; b=i0eFLA3/DT5lwH9rgjWoL368g/SRZBP2pIp26eClolhXRikm0zpw5bMphjMaMjMpyWMwp6gqPkLCOU9SbL9HZN/9YFpgzTipXLZx9qqt3+7lhY1kk05DP4MtGuXldimrvOsTDlfDOtIxJSSeTL22NwTWE8WJ+vhdrJuREn7NdQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206605; c=relaxed/simple; bh=JWL1QB+C9Bz8PGAWNSpqnc78THbHgpk6npVdnjiapYs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jUpVd9YoOlqZW8G4/BtPz2JLJv/ghmIRgFit6PkUa+NdMLOi5OAXQEYeUA7J8fDMwVrVmkrYPvhbR84720mq7hvcAKZEKvGx/unnWHFz8Vj0xJznlriKsFVC/BmUJ2KdLnc35GvX8PlnN7KM5sl0yoW50Ea8SB5MrFqFgmP6Huw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=TPiQSTjm; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="TPiQSTjm" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-2703967b10cso1604677fac.0 for ; Sun, 01 Sep 2024 09:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1725206603; x=1725811403; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2ZJUDImOQAnmS9B4qfB6vHVZUFMx5xAPAatcEzZLZcA=; b=TPiQSTjm6yJdklc2M56lR75N1Esnmh9RhlfbVDuMdJIt5DovRW0QI6crC+jjwZxF23 g9xONsA37YqKJeiej7MUi26FqNnNDjVId/1XrqU7kCJrMS0gCuB/CmjoYZiKt18xvIcr GzXjO/kkHRzDH1815BJQHw+I8Q5NbjEm66zOIpN22f/acAvs6+WAk/7oPH1ITgzhQTaj li3S990Cq9uT/agurBmuIQMEUkHsJ90LXyidxk2/gmWJcgEdAEqpWrMS4P8Bn5m38B+9 pocQ8MHnBy9L/MI2knRfKoYan+nwSa2kZ3ZF8MJT/XVJOjGI3OcXU3UIw4AbBQHOXvw6 Y9/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725206603; x=1725811403; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2ZJUDImOQAnmS9B4qfB6vHVZUFMx5xAPAatcEzZLZcA=; b=cBID4xzpPVVniuauBrpzPYsCCDgvWfIMsnEo3dha25vk0D+4XYq/uMQ33U1DG88bhL 20kHVp+c9J9+iLPAMQPZya7ID2XNlcfJEpAZAQl1U/FEBMGd0dCxHWMkCbOGBSkJDg1f KNrqNgsd/Kx4HYlX7pmS1MTa9PmwRv64fbbN/VylZO0knMN27QIZWW9326ZrtJ2uzo9W +uMLFtzw1UPRMRR7C8ZX+9QYFog2/Hj3zIYM3JrvnMRHUKyioGMtBnNeUlePLOq9rkFK lZ5WX1Wv2ZaXmEQrtOHmaPT4ENS4C2ITKTIjnftKvB8f6YAIqvQOmV6IpmZY/EE8zFBs 3Yng== X-Gm-Message-State: AOJu0Yz2xu32MDx5hSB911TaCrakP44+1I4o8x6F9c2yVTx0KW2cAVDL +omiaVrc0ntnf9UZ+QU+8nJE8pCKZdYXUWyitAjzNeVMCLnSAZqV/sa+2eBRQwNpHyWAZvVEqsZ Yc+U= X-Google-Smtp-Source: AGHT+IF3eNA00a7Q9+VVNbmTYiXI7NP7J4MwX8XAV5SbaoEzmuOs/ENlO2O3DkaMyuHbTygcmud1/w== X-Received: by 2002:a05:6870:bb10:b0:25e:29e7:14c8 with SMTP id 586e51a60fabf-27790319b11mr12953890fac.42.1725206603243; Sun, 01 Sep 2024 09:03:23 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6d4988bdbbcsm7957707b3.12.2024.09.01.09.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 09:03:22 -0700 (PDT) Date: Sun, 1 Sep 2024 12:03:21 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , "brian m. carlson" , Elijah Newren , Patrick Steinhardt , Junio C Hamano Subject: [PATCH 1/4] sha1: do not redefine `platform_SHA_CTX` and friends Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Our in-tree SHA-1 wrappers all define platform_SHA_CTX and related macros to point at the opaque "context" type, init, update, and similar functions for each specific implementation. In hash.h, we use these platform_ variables to set up the function pointers for, e.g., the_hash_algo->init_fn(), etc. But while these header files have a header-specific macro that prevents them declaring their structs / functions multiple times, they unconditionally define the platform variables, making it impossible to load multiple SHA-1 implementations at once. As a prerequisite for loading a separate SHA-1 implementation for non-cryptographic uses, only define the platform_ variables if they have not already been defined. Signed-off-by: Taylor Blau --- block-sha1/sha1.h | 2 ++ sha1/openssl.h | 2 ++ sha1dc_git.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/block-sha1/sha1.h b/block-sha1/sha1.h index 9fb0441b988..47bb9166368 100644 --- a/block-sha1/sha1.h +++ b/block-sha1/sha1.h @@ -16,7 +16,9 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx); void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, size_t len); void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx); +#ifndef platform_SHA_CTX #define platform_SHA_CTX blk_SHA_CTX #define platform_SHA1_Init blk_SHA1_Init #define platform_SHA1_Update blk_SHA1_Update #define platform_SHA1_Final blk_SHA1_Final +#endif diff --git a/sha1/openssl.h b/sha1/openssl.h index 006c1f4ba54..1038af47daf 100644 --- a/sha1/openssl.h +++ b/sha1/openssl.h @@ -40,10 +40,12 @@ static inline void openssl_SHA1_Clone(struct openssl_SHA1_CTX *dst, EVP_MD_CTX_copy_ex(dst->ectx, src->ectx); } +#ifndef platform_SHA_CTX #define platform_SHA_CTX openssl_SHA1_CTX #define platform_SHA1_Init openssl_SHA1_Init #define platform_SHA1_Clone openssl_SHA1_Clone #define platform_SHA1_Update openssl_SHA1_Update #define platform_SHA1_Final openssl_SHA1_Final +#endif #endif /* SHA1_OPENSSL_H */ diff --git a/sha1dc_git.h b/sha1dc_git.h index 60e3ce84395..f6f880cabea 100644 --- a/sha1dc_git.h +++ b/sha1dc_git.h @@ -18,7 +18,10 @@ void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *); void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len); #define platform_SHA_IS_SHA1DC /* used by "test-tool sha1-is-sha1dc" */ + +#ifndef platform_SHA_CTX #define platform_SHA_CTX SHA1_CTX #define platform_SHA1_Init git_SHA1DCInit #define platform_SHA1_Update git_SHA1DCUpdate #define platform_SHA1_Final git_SHA1DCFinal +#endif From patchwork Sun Sep 1 16:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13786538 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D8183FC7 for ; Sun, 1 Sep 2024 16:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206609; cv=none; b=UgvFL8cbpU4aLAflM2r+FE7lntNg6PqJ7/6ENhqLeT7LdA4AaluHv9kazcWM+jpAAegsr9hm5tACUkaoU29KqSFOKjB73VjGVivykU0W15OfX/PAC+Q828YoQL9R2fbfhFcb6g9jU+3FIL7+nU8qkLCwMasRssx4/TwWEO9LhCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206609; c=relaxed/simple; bh=n6m/ooHFJiW946LrmVaeWObLfvksuS5JA72QxCSkbTk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YDPWDlti3hDe/E8jasAj6L06VwR3r7Av9HN3Rps8qntP1chzbabVp/2TzjWteeqtWQ23xXzSMrnaaTU5oofL8Cqa7rT76zfh9N2tgl92rfg53G7tD77k2w4vy4WKz7DWn0FQIxbjjXeoKRcw9EngCkrT5A5zKDtcJnsYVdIk1hQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=xxjqgatZ; arc=none smtp.client-ip=209.85.219.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="xxjqgatZ" Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e1651f48c31so3613617276.0 for ; Sun, 01 Sep 2024 09:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1725206607; x=1725811407; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=h8JEotwuqYFfilVvomhWPuE3s5qThO28UMnzR5Rkdes=; b=xxjqgatZ/ozbQHaNNnKohldIZai9lPx6gwoRVYZPs+KqMk/3SPuqnTLf28on17tLpE T/7WFJjjKt3Zdn4rqI7yhpi8fvsiJYowp/hMnwna/FX+9cRXSx+IQ5oORWeT1YG87YuX rqm0qvfUgtNpuDHb8ANtsBQNrK6+1iNJrlASDArALdkmEUoQHPgjSCj1xTPV8hdLx99I 13Yn5TYzfx8N0yiOBJev82DaAJLusvy4salbDzFShIXbzq43My8LeoeA3xrVDegmM0W4 3eVzSsypYG9DBtZKWAAHEl6HHysKLYlN6rmOH3oX40ayrNt1oIsAUmwmaPdL52e3VMAS UpqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725206607; x=1725811407; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h8JEotwuqYFfilVvomhWPuE3s5qThO28UMnzR5Rkdes=; b=fmeZjiEf2GJpif6NCEZrWqXYUNnCCjvzu7j/YOimO0RvPBGHVnXGjM2+1EigJQIxQB wUKPtzq5/zzZrds5ScVV+US6478arMVsagk2jf650cXiFOAkoPKw2Yr4ywHZ52Qo5zCQ rsB/+X1xtkjDgdkhedX34c7x+RzOLG95wUetPN4ms4xPjj9sNTeuNr6AnoribuzICmX2 gUn4p0iPT22/4PnGw3V/bgx0ciYbb1b0mmqYwCeBKLN6TBiyZW8ItewFjl10rYl6XZ82 wVqm7OKqST+IftbR+uhPHWLLvib9B1rZ3LWuZBLyt7WtA3uOJ4VVQ8HxCYjyrDfTWcq8 6bwA== X-Gm-Message-State: AOJu0Yz1s+VtjfWW4ODhFVw+pHmMFIrDOj+gBef2BoPWnIi8Bo2ZDjVR 0w5IuiQbxzzYdfL8Sle7cX/YLrpoiRUkrC/RWyrZMVR5y5ds4ILUAnc/K1yKpss7hEGg9shevYX r0dc= X-Google-Smtp-Source: AGHT+IHSxA/n/Zo7rm2L9ferXOgxn1XJFEuETC/CsOPSObT25WtNrKwu0x0ecQf2tYwVbj/3aMV9Ag== X-Received: by 2002:a05:690c:418f:b0:6d3:f400:81e1 with SMTP id 00721157ae682-6d40e17f6a2mr62712687b3.14.1725206606760; Sun, 01 Sep 2024 09:03:26 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6d53b206498sm6042007b3.8.2024.09.01.09.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 09:03:26 -0700 (PDT) Date: Sun, 1 Sep 2024 12:03:24 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , "brian m. carlson" , Elijah Newren , Patrick Steinhardt , Junio C Hamano Subject: [PATCH 2/4] hash.h: scaffolding for _fast hashing variants Message-ID: <6ac6f934c32bdc600cdb8d2a08d4aa390c1f2994.1725206584.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Git's default SHA-1 implementation is collision-detecting, which hardens us against known SHA-1 attacks against Git objects. This makes Git object writes safer at the expense of some speed when hashing through the collision-detecting implementation, which is slower than non-collision detecting alternatives. Prepare for loading a separate "fast" SHA-1 implementation that can be used for non-cryptographic purposes, like computing the checksum of files that use the hashwrite() API. This commit does not actually introduce any new compile-time knobs to control which implementation is used as the fast SHA-1 variant, but does add scaffolding so that the "git_hash_algo" structure has five new function pointers which are "fast" variants of the five existing hashing-related function pointers: - git_hash_init_fn fast_init_fn - git_hash_clone_fn fast_clone_fn - git_hash_update_fn fast_update_fn - git_hash_final_fn fast_final_fn - git_hash_final_oid_fn fast_final_oid_fn The following commit will introduce compile-time knobs to specify which SHA-1 implementation is used for non-cryptographic uses. Signed-off-by: Taylor Blau --- hash.h | 42 ++++++++++++++++++++++++++++++++++++++++++ object-file.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/hash.h b/hash.h index 72ffbc862e5..f255e5c1e8a 100644 --- a/hash.h +++ b/hash.h @@ -44,14 +44,32 @@ #define platform_SHA1_Final SHA1_Final #endif +#ifndef platform_SHA_CTX_fast +#define platform_SHA_CTX_fast platform_SHA_CTX +#define platform_SHA1_Init_fast platform_SHA1_Init +#define platform_SHA1_Update_fast platform_SHA1_Update +#define platform_SHA1_Final_fast platform_SHA1_Final +#ifdef platform_SHA1_Clone +#define platform_SHA1_Clone_fast platform_SHA1_Clone +#endif +#endif + #define git_SHA_CTX platform_SHA_CTX #define git_SHA1_Init platform_SHA1_Init #define git_SHA1_Update platform_SHA1_Update #define git_SHA1_Final platform_SHA1_Final +#define git_SHA_CTX_fast platform_SHA_CTX_fast +#define git_SHA1_Init_fast platform_SHA1_Init_fast +#define git_SHA1_Update_fast platform_SHA1_Update_fast +#define git_SHA1_Final_fast platform_SHA1_Final_fast + #ifdef platform_SHA1_Clone #define git_SHA1_Clone platform_SHA1_Clone #endif +#ifdef platform_SHA1_Clone_fast +#define git_SHA1_Clone_fast platform_SHA1_Clone_fast +#endif #ifndef platform_SHA256_CTX #define platform_SHA256_CTX SHA256_CTX @@ -81,6 +99,13 @@ static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src) memcpy(dst, src, sizeof(*dst)); } #endif +#ifndef SHA1_NEEDS_CLONE_HELPER_FAST +static inline void git_SHA1_Clone_fast(git_SHA_CTX_fast *dst, + const git_SHA_CTX_fast *src) +{ + memcpy(dst, src, sizeof(*dst)); +} +#endif #ifndef SHA256_NEEDS_CLONE_HELPER static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src) @@ -178,6 +203,8 @@ enum get_oid_result { /* A suitably aligned type for stack allocations of hash contexts. */ union git_hash_ctx { git_SHA_CTX sha1; + git_SHA_CTX_fast sha1_fast; + git_SHA256_CTX sha256; }; typedef union git_hash_ctx git_hash_ctx; @@ -222,6 +249,21 @@ struct git_hash_algo { /* The hash finalization function for object IDs. */ git_hash_final_oid_fn final_oid_fn; + /* The fast hash initialization function. */ + git_hash_init_fn fast_init_fn; + + /* The fast hash context cloning function. */ + git_hash_clone_fn fast_clone_fn; + + /* The fast hash update function. */ + git_hash_update_fn fast_update_fn; + + /* The fast hash finalization function. */ + git_hash_final_fn fast_final_fn; + + /* The fast hash finalization function for object IDs. */ + git_hash_final_oid_fn fast_final_oid_fn; + /* The OID of the empty tree. */ const struct object_id *empty_tree; diff --git a/object-file.c b/object-file.c index c5994202ba0..9691292ef5a 100644 --- a/object-file.c +++ b/object-file.c @@ -115,6 +115,33 @@ static void git_hash_sha1_final_oid(struct object_id *oid, git_hash_ctx *ctx) oid->algo = GIT_HASH_SHA1; } +static void git_hash_sha1_init_fast(git_hash_ctx *ctx) +{ + git_SHA1_Init_fast(&ctx->sha1_fast); +} + +static void git_hash_sha1_clone_fast(git_hash_ctx *dst, const git_hash_ctx *src) +{ + git_SHA1_Clone_fast(&dst->sha1_fast, &src->sha1_fast); +} + +static void git_hash_sha1_update_fast(git_hash_ctx *ctx, const void *data, + size_t len) +{ + git_SHA1_Update_fast(&ctx->sha1_fast, data, len); +} + +static void git_hash_sha1_final_fast(unsigned char *hash, git_hash_ctx *ctx) +{ + git_SHA1_Final_fast(hash, &ctx->sha1_fast); +} + +static void git_hash_sha1_final_oid_fast(struct object_id *oid, git_hash_ctx *ctx) +{ + git_SHA1_Final_fast(oid->hash, &ctx->sha1_fast); + memset(oid->hash + GIT_SHA1_RAWSZ, 0, GIT_MAX_RAWSZ - GIT_SHA1_RAWSZ); + oid->algo = GIT_HASH_SHA1; +} static void git_hash_sha256_init(git_hash_ctx *ctx) { @@ -189,6 +216,11 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = { .update_fn = git_hash_unknown_update, .final_fn = git_hash_unknown_final, .final_oid_fn = git_hash_unknown_final_oid, + .fast_init_fn = git_hash_unknown_init, + .fast_clone_fn = git_hash_unknown_clone, + .fast_update_fn = git_hash_unknown_update, + .fast_final_fn = git_hash_unknown_final, + .fast_final_oid_fn = git_hash_unknown_final_oid, .empty_tree = NULL, .empty_blob = NULL, .null_oid = NULL, @@ -204,6 +236,11 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = { .update_fn = git_hash_sha1_update, .final_fn = git_hash_sha1_final, .final_oid_fn = git_hash_sha1_final_oid, + .fast_init_fn = git_hash_sha1_init_fast, + .fast_clone_fn = git_hash_sha1_clone_fast, + .fast_update_fn = git_hash_sha1_update_fast, + .fast_final_fn = git_hash_sha1_final_fast, + .fast_final_oid_fn = git_hash_sha1_final_oid_fast, .empty_tree = &empty_tree_oid, .empty_blob = &empty_blob_oid, .null_oid = &null_oid_sha1, @@ -219,6 +256,11 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = { .update_fn = git_hash_sha256_update, .final_fn = git_hash_sha256_final, .final_oid_fn = git_hash_sha256_final_oid, + .fast_init_fn = git_hash_sha256_init, + .fast_clone_fn = git_hash_sha256_clone, + .fast_update_fn = git_hash_sha256_update, + .fast_final_fn = git_hash_sha256_final, + .fast_final_oid_fn = git_hash_sha256_final_oid, .empty_tree = &empty_tree_oid_sha256, .empty_blob = &empty_blob_oid_sha256, .null_oid = &null_oid_sha256, From patchwork Sun Sep 1 16:03:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13786539 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B39CB17DFF4 for ; Sun, 1 Sep 2024 16:03:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206614; cv=none; b=l7IERGRR50oycpmIfOFq1hDBgAkt65KulBHiH136fenQqRnqUK51to0qkGbOKNbCxPKRKW9LFMT4VqV8HFsEbAUHhyo0IWIrVBFu6Hi6wFc+DXBqmnjvHaH2QHaZ5jfjlIBe9QG8Z468rzVr4oBit+K0cKruui7WXssalLiy7pM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206614; c=relaxed/simple; bh=7fTJuw9P9vU6sJtyZFlLHwvsZlxS+aPCP4dPuOMdegE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nBgvuRQ3nX/6C5OE8XWkKEtKFnTjzTaAiGVMJasaLmU9Nd93WifY4uproD1hBa34xZqme0mRL/lCXnqQ1feAQo/le4YK/NLkktd68hXcuLkxqbEBrzsS5l1mKao2hvKJRuHQQo/lJeAPstuAYobOtYXN+ka4INiz/6cZFLfkrzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=EqeNeXrK; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="EqeNeXrK" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-27018df4ff3so2200676fac.1 for ; Sun, 01 Sep 2024 09:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1725206610; x=1725811410; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6LxYreUVxCdHo+0bKb2lGeQIBpUecTpOEGnIHyvKrhA=; b=EqeNeXrKiAPYNykvhgvc/OOs+Usjp7X95flMEfTw2DsjCVXvM3W+yEZKqL2VEZq8yx 3PMRIDmRtzNZQlxJ/RaVw/YsONPXN8+utsLPmxNl+tsZ9vHXueqimI6kVIMA/Fran3QD +9/XQm7EceL6cwq/4o+1n7K7FSe97niizi/x8SJKsVg/qo8IEvWe7CDbu6fyPJOiqs1S wwITB8KoEctDIeTuyuGKPOQr0rCC2ECHD4cHJ4/Q1pV19RbRytzffGNOYhwdu5BGScwC 0gR/XxUlNK40mrJTEi4qaavJVPe3JCWIP1hmoRy42TjXYCHsHdrg/21vT+fnvR5wnor3 8gYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725206610; x=1725811410; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6LxYreUVxCdHo+0bKb2lGeQIBpUecTpOEGnIHyvKrhA=; b=VCvnrQj9zFlLmSjg+lXcAwGqlCe2Wb2ySvrj1H0EmSrWo6icUOha51FxzOhg/Klrmu f1uSMd5BLAIjTGFvcGIIfaeYD7xwRSGZbEVh9rAyxDP2F6c6A6xUtvLl9vlZPS6mj+7d iw/zf3ENLa5zHjGv/fVA0W8lwxLY1aUWlOKDh+myYHZBVcmC+O417noRtHSR94N1nVSZ sIIqhd7wI29KAMtfG1v1IjP1R7UrAlp5UWV06wlPANEqaLE+Of92mbZw0jGspQov7/Lf fkub28Zaf+kuS50eiC/8/S/tKLJtZUg413roT4M3yyeEp//u1HXGET3lcuFyIpFcNwrE x1yQ== X-Gm-Message-State: AOJu0YwqjufwT8Aoc6gW84eqy9BSUmnXg+ygmjJaS1fp5UiKQAX9Asn6 l/FTZ+VHMsH/RkY9S4h3F5/5rqUX262eEU+/FlXuQmkk2qWyAXd1KJ7hpUh2DW7mdFsjIkfkm9z 7joc= X-Google-Smtp-Source: AGHT+IEsgVAFLsIIMNMTVUF/Hv6A6pm5a98nUKQQLLgaLHmzfxXVQTuQ6GWT5siZoAwIf3UqsLMPQw== X-Received: by 2002:a05:6871:4e97:b0:261:44d:3b86 with SMTP id 586e51a60fabf-277d0443357mr5518965fac.23.1725206610431; Sun, 01 Sep 2024 09:03:30 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e1a626e3d5asm1436013276.44.2024.09.01.09.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 09:03:29 -0700 (PDT) Date: Sun, 1 Sep 2024 12:03:28 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , "brian m. carlson" , Elijah Newren , Patrick Steinhardt , Junio C Hamano Subject: [PATCH 3/4] Makefile: allow specifying a SHA-1 for non-cryptographic uses Message-ID: <682e4c2cc3581c72262ea6a9b488a246fc6fde28.1725206584.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Introduce _FAST variants of the OPENSSL_SHA1, BLK_SHA1, and APPLE_COMMON_CRYPTO_SHA1 compile-time knobs which indicate which SHA-1 implementation is to be used for non-cryptographic uses. There are a couple of small implementation notes worth mentioning: - There is no way to select the collision detecting SHA-1 as the "fast" fallback, since the fast fallback is only for non-cryptographic uses, and is meant to be faster than our collision-detecting implementation. - There are no similar knobs for SHA-256, since no collision attacks are presently known and thus no collision-detecting implementations actually exist. Signed-off-by: Taylor Blau --- Makefile | 25 +++++++++++++++++++++++++ hash.h | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/Makefile b/Makefile index e298c8b55ec..d24f9088802 100644 --- a/Makefile +++ b/Makefile @@ -517,6 +517,10 @@ include shared.mak # Define APPLE_COMMON_CRYPTO_SHA1 to use Apple's CommonCrypto for # SHA-1. # +# Define the same Makefile knobs as above, but suffixed with _FAST to +# use the corresponding implementations for "fast" SHA-1 hashing for +# non-cryptographic purposes. +# # If don't enable any of the *_SHA1 settings in this section, Git will # default to its built-in sha1collisiondetection library, which is a # collision-detecting sha1 This is slower, but may detect attempted @@ -1982,6 +1986,27 @@ endif endif endif +ifdef OPENSSL_SHA1_FAST +ifndef OPENSSL_SHA1 + EXTLIBS += $(LIB_4_CRYPTO) + BASIC_CFLAGS += -DSHA1_OPENSSL_FAST +endif +else +ifdef BLK_SHA1_FAST +ifndef BLK_SHA1 + LIB_OBJS += block-sha1/sha1.o + BASIC_CFLAGS += -DSHA1_BLK_FAST +endif +else +ifdef APPLE_COMMON_CRYPTO_SHA1_FAST +ifndef APPLE_COMMON_CRYPTO_SHA1 + COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL + BASIC_CFLAGS += -DSHA1_APPLE_FAST +endif +endif +endif +endif + ifdef OPENSSL_SHA256 EXTLIBS += $(LIB_4_CRYPTO) BASIC_CFLAGS += -DSHA256_OPENSSL diff --git a/hash.h b/hash.h index f255e5c1e8a..450e579b405 100644 --- a/hash.h +++ b/hash.h @@ -15,6 +15,31 @@ #include "block-sha1/sha1.h" #endif +#if defined(SHA1_APPLE_FAST) +#include +#define platform_SHA_CTX_fast CC_SHA1_CTX +#define platform_SHA1_Init_fast CC_SHA1_Init +#define platform_SHA1_Update_fast CC_SHA1_Update +#define platform_SHA1_Final_fast CC_SHA1_Final +#elif defined(SHA1_OPENSSL_FAST) +# include +# if defined(OPENSSL_API_LEVEL) && OPENSSL_API_LEVEL >= 3 +# define SHA1_NEEDS_CLONE_HELPER_FAST +# include "sha1/openssl.h" +# endif +# define platform_SHA_CTX_fast openssl_SHA1_CTX +# define platform_SHA1_Init_fast openssl_SHA1_Init +# define platform_SHA1_Clone_fast openssl_SHA1_Clone +# define platform_SHA1_Update_fast openssl_SHA1_Update +# define platform_SHA1_Final_fast openssl_SHA1_Final +#elif defined(SHA1_BLK_FAST) +#include "block-sha1/sha1.h" +#define platform_SHA_CTX_fast blk_SHA_CTX +#define platform_SHA1_Init_fast blk_SHA1_Init +#define platform_SHA1_Update_fast blk_SHA1_Update +#define platform_SHA1_Final_fast blk_SHA1_Final +#endif + #if defined(SHA256_NETTLE) #include "sha256/nettle.h" #elif defined(SHA256_GCRYPT) From patchwork Sun Sep 1 16:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13786540 Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E799183CAF for ; Sun, 1 Sep 2024 16:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206617; cv=none; b=UO3oUlQ8wZT26uChtyPSn0AA/dUkfcVIcR3UdDkw5SAg/p16rj+x+Qfd4PX/U43TLfaNu7KUht6LXO67Wfolt86MuGKwAv4FRFxnBubx3z9eK6GH5VJLiMLMLeSkucSpT/rqSpcydfwvisJLNiK/74+J0KX4IL/pOSXoRcE/G9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725206617; c=relaxed/simple; bh=uxffkUl2BIiQ85XgcgvdR5a6LyYcEDUS0oln3AoW9rw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qLjvHqc7az3Ov/zkJXHCzxMnLQQHe5H6yvMsskvW8Qb4in+F6oaF7ZCA50FAsoCPRCw/tcsJ5A76i48aAG8RnC5C3cw5q/2MUUkFMIe9YqxdM068ognfdKQuweajFLwAMo+SThpMtpx5nEcx7SDRHUrmVyMK/iw3tsIelkvyq7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com; spf=none smtp.mailfrom=ttaylorr.com; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b=eMyyY0Aq; arc=none smtp.client-ip=209.85.219.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ttaylorr.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="eMyyY0Aq" Received: by mail-yb1-f170.google.com with SMTP id 3f1490d57ef6-e1a9e4fa5aaso854095276.2 for ; Sun, 01 Sep 2024 09:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1725206614; x=1725811414; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EcHdwGMtPU4DstWWCxwP4CpV3Zt4cbcBQ5eoR9PyQOI=; b=eMyyY0AqEVMIOu3gs2UI3OHlDVG6H2EnT8pOU4RWpBs0TfYkmhquKAaAq6J+bw/rC/ s2502uQX1PbL8GdgMd7M1O8Qx7rl2DnUKE1DrR7SJJpV7Va6S6MM/BlwmVn94CvK+0lo z7W+SVxe626j/wcuWv0MZIGFnprWj1YyvbRoXViTAr1UopRVhDkaCLTvNfY4dcwifn92 ky3jctLFvVQimmSnWxlJCqqevOpyjPf19nt31AEd3Uja6vvS4BPuRcfdg7vAyOjXDwPw 3mEC03PNDjiH5ApHdXbWV3zd1+y29utWVTsHmn7FfZtvmu3xioLmWDgartr4rc6WLvy+ kUmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725206614; x=1725811414; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EcHdwGMtPU4DstWWCxwP4CpV3Zt4cbcBQ5eoR9PyQOI=; b=wvmSD8Qy6UDR1WX8tBu2M39iHTcI/Vs10pobPD1gdR93MGfeExXz6MZDtx2iQXiHUi y3mFR7a9JbUQ7y5i7jjJkVqhCoP6exKOTSaRuDFIl0n2vKOG4scHjIXBKu8Z0GZHXXru kJu/9GlXWwlpVI3EUydkf5A14BwOFTER1r2LGOsKtA27RbNcauRgXzgQnJClGsYakalJ ruUzsThp8MZgUAnGHBhRhWq4sopM06xPY88zmEC7TxU8yHNPcwhTkUj5QJEa7qT1gfOT ryaQzwES2om9CmnVPG2NerJSLnQ/6AR7W/Y7xASLUPLxsPt9Q9TRbH3rHEREieY3u4DS 4w1w== X-Gm-Message-State: AOJu0YyLEs+9A1ZB+BVIjYcIXEx+qsJJrC36M/0AidDKgbmf6lEO+jAN m/CxMyvjWhn4fFAq9omciZ0DxpWh58oH3ubmy1SHHf9xizMvBN/8YaWJORHHgGV3h8u404PO25y ofUI= X-Google-Smtp-Source: AGHT+IH9tf0UZcEa1wbwIRlCiLh1ALGrjrJl7MkkRbVRLzGxGDRebBbEt+rTaLOQfntxGWxq4N416Q== X-Received: by 2002:a05:690c:6d8b:b0:675:a51b:fafd with SMTP id 00721157ae682-6d40f535fffmr95784627b3.31.1725206614212; Sun, 01 Sep 2024 09:03:34 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6d6c4eebe3fsm1993487b3.49.2024.09.01.09.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 09:03:33 -0700 (PDT) Date: Sun, 1 Sep 2024 12:03:32 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , "brian m. carlson" , Elijah Newren , Patrick Steinhardt , Junio C Hamano Subject: [PATCH 4/4] csum-file.c: use fast SHA-1 implementation when available Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Update hashwrite() and friends to use the fast_-variants of hashing functions, calling for e.g., "the_hash_algo->fast_update_fn()" instead of "the_hash_algo->update_fn()". These callers only use the_hash_algo to produce a checksum, which we depend on for data integrity, but not for cryptographic purposes, so these callers are safe to use the fast (and potentially non-collision detecting) SHA-1 implementation. To time this, I took a freshly packed copy of linux.git, and ran the following with and without the OPENSSL_SHA1_FAST=1 build-knob. Both versions were compiled with -O3: $ git for-each-ref --format='%(objectname)' refs/heads refs/tags >in $ valgrind --tool=callgrind ~/src/git/git-pack-objects \ --revs --stdout --all-progress --use-bitmap-index /dev/null Without OPENSSL_SHA1_FAST=1 (that is, using the collision-detecting SHA-1 implementation for both cryptographic and non-cryptographic purposes), we spend a significant amount of our instruction count in hashwrite(): $ callgrind_annotate --inclusive=yes | grep hashwrite | head -n1 159,998,868,413 (79.42%) /home/ttaylorr/src/git/csum-file.c:hashwrite [/home/ttaylorr/src/git/git-pack-objects] , and the resulting "clone" takes 19.219 seconds of wall clock time, 18.94 seconds of user time and 0.28 seconds of system time. Compiling with OPENSSL_SHA1_FAST=1, we spend ~60% fewer instructions in hashwrite(): $ callgrind_annotate --inclusive=yes | grep hashwrite | head -n1 59,164,001,176 (58.79%) /home/ttaylorr/src/git/csum-file.c:hashwrite [/home/ttaylorr/src/git/git-pack-objects] , and generate the resulting "clone" much faster, in only 11.597 seconds of wall time, 11.37 seconds of user time, and 0.23 seconds of system time, for a ~40% speed-up. Signed-off-by: Taylor Blau --- csum-file.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/csum-file.c b/csum-file.c index bf82ad8f9f5..cb8c39ecf3a 100644 --- a/csum-file.c +++ b/csum-file.c @@ -50,7 +50,7 @@ void hashflush(struct hashfile *f) if (offset) { if (!f->skip_hash) - the_hash_algo->update_fn(&f->ctx, f->buffer, offset); + the_hash_algo->fast_update_fn(&f->ctx, f->buffer, offset); flush(f, f->buffer, offset); f->offset = 0; } @@ -73,7 +73,7 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, if (f->skip_hash) hashclr(f->buffer, the_repository->hash_algo); else - the_hash_algo->final_fn(f->buffer, &f->ctx); + the_hash_algo->fast_final_fn(f->buffer, &f->ctx); if (result) hashcpy(result, f->buffer, the_repository->hash_algo); @@ -128,7 +128,7 @@ void hashwrite(struct hashfile *f, const void *buf, unsigned int count) * f->offset is necessarily zero. */ if (!f->skip_hash) - the_hash_algo->update_fn(&f->ctx, buf, nr); + the_hash_algo->fast_update_fn(&f->ctx, buf, nr); flush(f, buf, nr); } else { /* @@ -174,7 +174,7 @@ static struct hashfile *hashfd_internal(int fd, const char *name, f->name = name; f->do_crc = 0; f->skip_hash = 0; - the_hash_algo->init_fn(&f->ctx); + the_hash_algo->fast_init_fn(&f->ctx); f->buffer_len = buffer_len; f->buffer = xmalloc(buffer_len); @@ -208,7 +208,7 @@ void hashfile_checkpoint(struct hashfile *f, struct hashfile_checkpoint *checkpo { hashflush(f); checkpoint->offset = f->total; - the_hash_algo->clone_fn(&checkpoint->ctx, &f->ctx); + the_hash_algo->fast_clone_fn(&checkpoint->ctx, &f->ctx); } int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint) @@ -219,7 +219,7 @@ int hashfile_truncate(struct hashfile *f, struct hashfile_checkpoint *checkpoint lseek(f->fd, offset, SEEK_SET) != offset) return -1; f->total = offset; - the_hash_algo->clone_fn(&f->ctx, &checkpoint->ctx); + the_hash_algo->fast_clone_fn(&f->ctx, &checkpoint->ctx); f->offset = 0; /* hashflush() was called in checkpoint */ return 0; } @@ -245,9 +245,9 @@ int hashfile_checksum_valid(const unsigned char *data, size_t total_len) if (total_len < the_hash_algo->rawsz) return 0; /* say "too short"? */ - the_hash_algo->init_fn(&ctx); - the_hash_algo->update_fn(&ctx, data, data_len); - the_hash_algo->final_fn(got, &ctx); + the_hash_algo->fast_init_fn(&ctx); + the_hash_algo->fast_update_fn(&ctx, data, data_len); + the_hash_algo->fast_final_fn(got, &ctx); return hasheq(got, data + data_len, the_repository->hash_algo); }