]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sha1-file: add a constant for hash block size
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 14 Nov 2018 04:09:33 +0000 (04:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Nov 2018 07:54:52 +0000 (16:54 +0900)
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 <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
hash.h
sha1-file.c

diff --git a/cache.h b/cache.h
index 85a8e7b10136afdf66e239bfbb5b60a52d44ef87..5d969727f96d33c5b723c9179cb11c16605ab25d 100644 (file)
--- 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 80881eea47b8401a780a7f3d4975f226237796f7..1bcf7ab6fda4f77b846bcf427cba38180b164f1e 100644 (file)
--- 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;
 
index 3a75d515eb981b76447db69f1649f35f238e2244..9aadaf0c8d657e388a6c7a8ad4f66ac2d9157dec 100644 (file)
@@ -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,