From patchwork Sun Nov 4 23:44:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 10667197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7823E15E9 for ; Sun, 4 Nov 2018 23:45:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68A75296A3 for ; Sun, 4 Nov 2018 23:45:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D3AA296A7; Sun, 4 Nov 2018 23:45:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A43E296AC for ; Sun, 4 Nov 2018 23:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730649AbeKEJCA (ORCPT ); Mon, 5 Nov 2018 04:02:00 -0500 Received: from injection.crustytoothpaste.net ([192.241.140.119]:53230 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729402AbeKEJCA (ORCPT ); Mon, 5 Nov 2018 04:02:00 -0500 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:941b:b2ff:ecfe:7f28]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id A843D61B7E; Sun, 4 Nov 2018 23:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1541375114; bh=eq6uz2zRn1FRia7VIpcK09IaJzAI1LgMumjeI1hEKmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=zW+tJ6vgfXUy70WRuzVUrXRIcXPOZ2KOXoP/k6ncOXgRwssQnSQbSH1aZZqfQCf7z Bik9keuVHjXmieV+NXEYrlYefDCh7YkgcAaVca8BdKMHcNeYcEUOruZlpOLI/3a86I K7ooFmOtHUJ5DMBn4O0/I6EROVGlT/Oiq19qo1OCWlR+HdwXcxh39VTJm5rTADycze tzfok2LGnhF5JpNgfCNdYCLBaVpkeHLm7nRMpbh5Fevj6XABZvK/RRIM/7h8hBZnT2 U9zGQX+l7KGr0q7DahtbzO2wJUCPG8x/lyklck4/ax6KuKDSJp6Y5N6HVp8toNO3jG +54lqrKgTKWHR+2kZct81bmZ52ZNtclXRJ3G/fLL2WSRXcDpwnV2vAI/1EK+HLbTrE Kf6mdWa6GMUcbEbDnzpzMk4tJH+TW+Z0WOnR9jMcRsw/lz69xCrX/jL7+RtOYej/5Y No7X8Q/kqHc/f3+jz7U9IoGoNASzq0wEmjX9TdEOFhbTj+wmMWq From: "brian m. carlson" To: git@vger.kernel.org Cc: Derrick Stolee , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Duy Nguyen , =?utf-8?q?SZEDER_G=C3=A1bor?= , Jakub Narebski , Christian Couder Subject: [PATCH v5 07/12] sha1-file: add a constant for hash block size Date: Sun, 4 Nov 2018 23:44:53 +0000 Message-Id: <20181104234458.139223-8-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0 In-Reply-To: <20181104234458.139223-1-sandals@crustytoothpaste.net> References: <20181025024005.154208-1-sandals@crustytoothpaste.net> <20181104234458.139223-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 127.0.1.1 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is one place we need the hash algorithm block size: the HMAC code for push certs. Expose this constant in struct git_hash_algo and expose values for SHA-1 and for the largest value of any hash. Signed-off-by: brian m. carlson --- cache.h | 4 ++++ hash.h | 3 +++ sha1-file.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/cache.h b/cache.h index bab8e8964f..9e5d1dd85a 100644 --- a/cache.h +++ b/cache.h @@ -45,10 +45,14 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long); /* The length in bytes and in hex digits of an object name (SHA-1 value). */ #define GIT_SHA1_RAWSZ 20 #define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ) +/* The block size of SHA-1. */ +#define GIT_SHA1_BLKSZ 64 /* The length in byte and in hex digits of the largest possible hash value. */ #define GIT_MAX_RAWSZ GIT_SHA1_RAWSZ #define GIT_MAX_HEXSZ GIT_SHA1_HEXSZ +/* The largest possible block size for any supported hash. */ +#define GIT_MAX_BLKSZ GIT_SHA1_BLKSZ struct object_id { unsigned char hash[GIT_MAX_RAWSZ]; diff --git a/hash.h b/hash.h index 80881eea47..1bcf7ab6fd 100644 --- a/hash.h +++ b/hash.h @@ -81,6 +81,9 @@ struct git_hash_algo { /* The length of the hash in hex characters. */ size_t hexsz; + /* The block size of the hash. */ + size_t blksz; + /* The hash initialization function. */ git_hash_init_fn init_fn; diff --git a/sha1-file.c b/sha1-file.c index 7e9dedc744..9bdd04ea45 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -90,6 +90,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = { 0x00000000, 0, 0, + 0, git_hash_unknown_init, git_hash_unknown_update, git_hash_unknown_final, @@ -102,6 +103,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = { 0x73686131, GIT_SHA1_RAWSZ, GIT_SHA1_HEXSZ, + GIT_SHA1_BLKSZ, git_hash_sha1_init, git_hash_sha1_update, git_hash_sha1_final,