chiark / gitweb /
hash: Provide and use hash_hash connvenience function
[secnet.git] / util.c
diff --git a/util.c b/util.c
index 5200e18ef3bbb315f9e3a233077883732ff1b3c4..4982c93c58e6ae84fa0d8edc1eefedd59156862a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -484,6 +484,14 @@ int consttime_memeq(const void *s1in, const void *s2in, size_t n)
     return accumulator;
 }
 
+void hash_hash(const struct hash_if *hashi, const void *msg, int32_t len,
+              uint8_t *digest) {
+    uint8_t hst[hashi->slen];
+    hashi->init(hst);
+    hashi->update(hst,msg,len);
+    hashi->final(hst,digest);
+}
+
 void util_module(dict_t *dict)
 {
     add_closure(dict,"sysbuffer",buffer_apply);