]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: hash-method - Add block size
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 3 Dec 2020 14:28:40 +0000 (16:28 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 7 Dec 2020 10:09:56 +0000 (10:09 +0000)
This is needed for HMAC

src/lib/hash-method.c
src/lib/hash-method.h
src/lib/md4.c
src/lib/md5.c
src/lib/sha1.c
src/lib/sha2.c
src/lib/sha3.c

index a32e9951410e53de3df890ffb5b9c0653b80e084..ccf0f8b2c5586975a5c6e8c39ad9b072ad522a05 100644 (file)
@@ -75,6 +75,7 @@ buffer_t *t_hash_data(const struct hash_method *meth,
 
 static const struct hash_method hash_method_size = {
        .name = "size",
+       .block_size = 1,
        .context_size = sizeof(uint64_t),
        .digest_size = sizeof(uint64_t),
 
index 2c68b91065810455cae2c9f24d6db9ded7e105b0..c4250de0a7c4ebb468bd77539491f4bcd2add625 100644 (file)
@@ -5,6 +5,8 @@
 
 struct hash_method {
        const char *name;
+       /* Block size for the algorithm */
+       unsigned int block_size;
        /* Number of bytes that must be allocated for context */
        unsigned int context_size;
        /* Number of bytes that must be allocated for result()'s digest */
index ced55feb2a6f6fff3e87070cde8eaf50accae0c5..06e3231bde091aae8831d06f6a619da056835c34 100644 (file)
@@ -290,6 +290,7 @@ static void hash_method_result_md4(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_md4 = {
        .name = "md4",
+       .block_size = 64, /* block size is 512 bits */
        .context_size = sizeof(struct md4_context),
        .digest_size = MD4_RESULTLEN,
 
index a479b80c9d35638dce5f17618b42da25b68908e6..6b5da6c307df32b9db28f0ee19405a7daa69481e 100644 (file)
@@ -304,6 +304,7 @@ static void hash_method_result_md5(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_md5 = {
        .name = "md5",
+       .block_size = 64, /* block size is 512 bits */
        .context_size = sizeof(struct md5_context),
        .digest_size = MD5_RESULTLEN,
 
index 62379e1634623e9a2cb9af323a2434de5df31e64..b647a911b587b0a6d7eafa007e7ccc4dc6ef989b 100644 (file)
@@ -278,6 +278,7 @@ static void hash_method_result_sha1(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_sha1 = {
        .name = "sha1",
+       .block_size = 64, /* block size is 512 bits */
        .context_size = sizeof(struct sha1_ctxt),
        .digest_size = SHA1_RESULTLEN,
 
index db7f82c0ed1ff15a4e05a7002e72433da9250cca..b6b8b365f54c0469a5f03f24373ca4a656373c1e 100644 (file)
@@ -442,6 +442,7 @@ static void hash_method_result_sha256(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_sha256 = {
        .name = "sha256",
+       .block_size = SHA256_BLOCK_SIZE,
        .context_size = sizeof(struct sha256_ctx),
        .digest_size = SHA256_RESULTLEN,
 
@@ -466,6 +467,7 @@ static void hash_method_result_sha512(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_sha512 = {
        .name = "sha512",
+       .block_size = SHA512_BLOCK_SIZE,
        .context_size = sizeof(struct sha512_ctx),
        .digest_size = SHA512_RESULTLEN,
 
index a8bdfcdc6a711364f2f6864eae143823b7b79685..a8c0b14d5d5c6873c6a2ed765a75851de9d35821 100644 (file)
@@ -304,6 +304,7 @@ static void hash_method_result_sha3_256(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_sha3_256 = {
        .name = "sha3-256",
+       .block_size = SHA256_BLOCK_SIZE,
        .context_size = sizeof(struct sha3_ctx),
        .digest_size = SHA256_RESULTLEN,
 
@@ -324,6 +325,7 @@ static void hash_method_result_sha3_512(void *context, unsigned char *result_r)
 
 const struct hash_method hash_method_sha3_512 = {
        .name = "sha3-512",
+       .block_size = SHA512_BLOCK_SIZE,
        .context_size = sizeof(struct sha3_ctx),
        .digest_size = SHA512_RESULTLEN,