sha1-file: add a constant for hash block size

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>

brian m. carlson committed Nov 14, 2018 at 04:09 UTC a2ce0a752600a44979da94b19aa1b367c6850bd7
3 files changed +9
cache.h
+4
@@ -45,10 +45,14 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);
45 /* The length in bytes and in hex digits of an object name (SHA-1 value). */
46 #define GIT_SHA1_RAWSZ 20
47 #define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
48 +/* The block size of SHA-1. */
49 +#define GIT_SHA1_BLKSZ 64
50
51 /* The length in byte and in hex digits of the largest possible hash value. */
52 #define GIT_MAX_RAWSZ GIT_SHA1_RAWSZ
53 #define GIT_MAX_HEXSZ GIT_SHA1_HEXSZ
54 +/* The largest possible block size for any supported hash. */
55 +#define GIT_MAX_BLKSZ GIT_SHA1_BLKSZ
56
57 struct object_id {
58 unsigned char hash[GIT_MAX_RAWSZ];
hash.h
+3
@@ -81,6 +81,9 @@ struct git_hash_algo {
81 /* The length of the hash in hex characters. */
82 size_t hexsz;
83
84 + /* The block size of the hash. */
85 + size_t blksz;
86 +
87 /* The hash initialization function. */
88 git_hash_init_fn init_fn;
89
sha1-file.c
+2
@@ -90,6 +90,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
90 0x00000000,
91 0,
92 0,
93 + 0,
94 git_hash_unknown_init,
95 git_hash_unknown_update,
96 git_hash_unknown_final,
@@ -102,6 +103,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
103 0x73686131,
104 GIT_SHA1_RAWSZ,
105 GIT_SHA1_HEXSZ,
106 + GIT_SHA1_BLKSZ,
107 git_hash_sha1_init,
108 git_hash_sha1_update,
109 git_hash_sha1_final,