From 1ec6890c3ada332d82a33492beb36df5748c1824 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 13 Feb 2020 16:55:51 +0000 Subject: [PATCH] sha1: Provide sha1_hash_if This will be useful in a moment. As a side effect, the sha1 st is statically allocated now. Signed-off-by: Ian Jackson --- secnet.h | 2 ++ sha1.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/secnet.h b/secnet.h index 5c351af..ffe8360 100644 --- a/secnet.h +++ b/secnet.h @@ -786,6 +786,8 @@ struct hash_if { hash_final_fn *final; }; +extern struct hash_if *const sha1_hash_if; /* for where this is hardcoded */ + /* BUFFER interface */ struct buffer_if { diff --git a/sha1.c b/sha1.c index f442e08..a78345a 100644 --- a/sha1.c +++ b/sha1.c @@ -314,9 +314,11 @@ struct sha1 { struct hash_if ops; }; +static struct sha1 st[1]; +struct hash_if *const sha1_hash_if = &st->ops; + void sha1_module(dict_t *dict) { - struct sha1 *st; cstring_t testinput="abcdbcdecdefdefgefghfghigh" "ijhijkijkljklmklmnlmnomnopnopq"; uint8_t expected[20]= @@ -328,7 +330,6 @@ void sha1_module(dict_t *dict) uint8_t digest[20]; int i; - NEW(st); st->cl.description="sha1"; st->cl.type=CL_HASH; st->cl.apply=NULL; -- 2.30.2