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_sha2_hasher.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libhashsum_init_sha2_hasher.c') diff --git a/libhashsum_init_sha2_hasher.c b/libhashsum_init_sha2_hasher.c index f06c59b..7e5aa38 100644 --- a/libhashsum_init_sha2_hasher.c +++ b/libhashsum_init_sha2_hasher.c @@ -38,9 +38,11 @@ finalise_const(struct libhashsum_hasher *this, const void *data, size_t bytes, u m = &m[r]; bytes -= r; - libsha2_digest(&this->state.sha2.s, data, (bytes << 3) | extra_bits, this->state.sha2.sum); + if (!this->hash_output) + this->hash_output = this->state.sha2.sum; + + libsha2_digest(&this->state.sha2.s, data, (bytes << 3) | extra_bits, this->hash_output); memset(&this->state.sha2.s, 0, sizeof(this->state.sha2.s)); - this->hash_output = this->state.sha2.sum; return 0; } @@ -95,6 +97,7 @@ libhashsum_init_sha2_hasher(struct libhashsum_hasher *this, unsigned algobits, s this->process = &process; this->finalise_const = &finalise_const; this->finalise = &finalise; + this->stretch = NULL; this->destroy = NULL; libsha2_init(&this->state.sha2.s, algo); return 0; -- cgit v1.2.3-70-g09d2