From d1acc40f9361cf5d1f0e92a0a2569b518b29b1cf Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 31 Aug 2024 07:41:27 +0200 Subject: Add support for extended hash + add support for output hash to custom buffer when supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libhashsum_init_ripemd_320_hasher.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libhashsum_init_ripemd_320_hasher.c') diff --git a/libhashsum_init_ripemd_320_hasher.c b/libhashsum_init_ripemd_320_hasher.c index d5af69a..80e4e23 100644 --- a/libhashsum_init_ripemd_320_hasher.c +++ b/libhashsum_init_ripemd_320_hasher.c @@ -175,15 +175,17 @@ finalise_common(struct libhashsum_hasher *this, uint8_t *m, size_t bytes, unsign memset(this->state.ripemd_320.w2, 0, sizeof(this->state.ripemd_320.w2)); this->state.ripemd_320.count = 0; + if (!this->hash_output) + this->hash_output = this->state.ripemd_320.h.sum; + for (i = 0; i < 10U; i++) { hi = this->state.ripemd_320.h.h32[i]; - this->state.ripemd_320.h.sum[i * 4U + 0U] = (uint8_t)(hi >> 0); - this->state.ripemd_320.h.sum[i * 4U + 1U] = (uint8_t)(hi >> 8); - this->state.ripemd_320.h.sum[i * 4U + 2U] = (uint8_t)(hi >> 16); - this->state.ripemd_320.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.ripemd_320.h.sum; return 0; } @@ -238,6 +240,7 @@ libhashsum_init_ripemd_320_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.ripemd_320, 0, sizeof(this->state.ripemd_320)); this->state.ripemd_320.h.h32[0] = UINT32_C(0x67452301); -- cgit v1.2.3-70-g09d2