aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_init_md4_hasher.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-31 07:41:27 +0200
committerMattias Andrée <maandree@kth.se>2024-08-31 07:41:27 +0200
commitd1acc40f9361cf5d1f0e92a0a2569b518b29b1cf (patch)
treea0538a97e06b8783f07eeed5cc3d686e3a8a686f /libhashsum_init_md4_hasher.c
parentAdd more tests + m fixes (diff)
downloadlibhashsum-d1acc40f9361cf5d1f0e92a0a2569b518b29b1cf.tar.gz
libhashsum-d1acc40f9361cf5d1f0e92a0a2569b518b29b1cf.tar.bz2
libhashsum-d1acc40f9361cf5d1f0e92a0a2569b518b29b1cf.tar.xz
Add support for extended hash + add support for output hash to custom buffer when supported
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libhashsum_init_md4_hasher.c')
-rw-r--r--libhashsum_init_md4_hasher.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libhashsum_init_md4_hasher.c b/libhashsum_init_md4_hasher.c
index bc361d8..abcc115 100644
--- a/libhashsum_init_md4_hasher.c
+++ b/libhashsum_init_md4_hasher.c
@@ -122,15 +122,17 @@ finalise_common(struct libhashsum_hasher *this, uint8_t *m, size_t bytes, unsign
memset(&this->state.md4.m, 0, sizeof(this->state.md4.m));
this->state.md4.count = 0;
+ if (!this->hash_output)
+ this->hash_output = this->state.md4.h.sum;
+
for (i = 0; i < 4U; i++) {
hi = this->state.md4.h.h32[i];
- this->state.md4.h.sum[i * 4U + 0U] = (uint8_t)(hi >> 0);
- this->state.md4.h.sum[i * 4U + 1U] = (uint8_t)(hi >> 8);
- this->state.md4.h.sum[i * 4U + 2U] = (uint8_t)(hi >> 16);
- this->state.md4.h.sum[i * 4U + 3U] = (uint8_t)(hi >> 24);
+ this->hash_output[i * 4U + 0U] = (uint8_t)(hi >> 0);
+ this->hash_output[i * 4U + 1U] = (uint8_t)(hi >> 8);
+ this->hash_output[i * 4U + 2U] = (uint8_t)(hi >> 16);
+ this->hash_output[i * 4U + 3U] = (uint8_t)(hi >> 24);
}
- this->hash_output = this->state.md4.h.sum;
return 0;
}
@@ -185,6 +187,7 @@ libhashsum_init_md4_hasher(struct libhashsum_hasher *this)
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
+ this->stretch = NULL;
this->destroy = NULL;
memset(&this->state.md4, 0, sizeof(this->state.md4));
this->state.md4.h.h32[0] = UINT32_C(0x67452301);