aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_init_sha1_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_sha1_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_sha1_hasher.c')
-rw-r--r--libhashsum_init_sha1_hasher.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libhashsum_init_sha1_hasher.c b/libhashsum_init_sha1_hasher.c
index 91bcc15..13020e2 100644
--- a/libhashsum_init_sha1_hasher.c
+++ b/libhashsum_init_sha1_hasher.c
@@ -38,9 +38,11 @@ finalise_const(struct libhashsum_hasher *this, const void *data, size_t bytes, u
m = &m[r];
bytes -= r;
- libsha1_digest(&this->state.sha1.s, m, (bytes << 3) | (size_t)extra_bits, this->state.sha1.sum);
+ if (!this->hash_output)
+ this->hash_output = this->state.sha1.sum;
+
+ libsha1_digest(&this->state.sha1.s, m, (bytes << 3) | (size_t)extra_bits, this->hash_output);
memset(&this->state.sha1.s, 0, sizeof(this->state.sha1.s));
- this->hash_output = this->state.sha1.sum;
return 0;
}
@@ -66,6 +68,7 @@ libhashsum_init_sha1_hasher(struct libhashsum_hasher *this)
this->process = &process;
this->finalise_const = &finalise_const;
this->finalise = &finalise;
+ this->stretch = NULL;
this->destroy = NULL;
libsha1_init(&this->state.sha1.s, LIBSHA1_1);
return 0;