]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
nettle: use Nettle provided function types
authorDaiki Ueno <ueno@gnu.org>
Thu, 26 Feb 2026 21:57:16 +0000 (06:57 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 26 Feb 2026 23:38:42 +0000 (08:38 +0900)
Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/accelerated/aarch64/sha-aarch64.c
lib/accelerated/x86/sha-padlock.c
lib/accelerated/x86/sha-x86-ssse3.c
lib/nettle/mac.c

index 42adf283ca3a38a453d48b31674da76bc17eff0c..d84ec186a2daac2287a2bd8fe73c1f7bfd3ed243 100644 (file)
@@ -36,10 +36,8 @@ void sha1_block_data_order(void *c, const void *p, size_t len);
 void sha256_block_data_order(void *c, const void *p, size_t len);
 void sha512_block_data_order(void *c, const void *p, size_t len);
 
-typedef void (*update_func)(void *, size_t, const uint8_t *);
-typedef void (*digest_func)(void *, size_t, uint8_t *);
+/* Can't use nettle_set_key_func as it doesn't have the second argument */
 typedef void (*set_key_func)(void *, size_t, const uint8_t *);
-typedef void (*init_func)(void *);
 
 struct aarch64_hash_ctx {
        union {
@@ -52,9 +50,9 @@ struct aarch64_hash_ctx {
        void *ctx_ptr;
        gnutls_digest_algorithm_t algo;
        size_t length;
-       update_func update;
-       digest_func digest;
-       init_func init;
+       nettle_hash_update_func *update;
+       nettle_hash_digest_func *digest;
+       nettle_hash_init_func *init;
 };
 
 static int wrap_aarch64_hash_update(void *_ctx, const void *text,
@@ -234,41 +232,41 @@ static int _ctx_init(gnutls_digest_algorithm_t algo,
        switch (algo) {
        case GNUTLS_DIG_SHA1:
                sha1_init(&ctx->ctx.sha1);
-               ctx->update = (update_func)aarch64_sha1_update;
-               ctx->digest = (digest_func)sha1_digest;
-               ctx->init = (init_func)sha1_init;
+               ctx->update = (nettle_hash_update_func *)aarch64_sha1_update;
+               ctx->digest = (nettle_hash_digest_func *)sha1_digest;
+               ctx->init = (nettle_hash_init_func *)sha1_init;
                ctx->ctx_ptr = &ctx->ctx.sha1;
                ctx->length = SHA1_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA224:
                sha224_init(&ctx->ctx.sha224);
-               ctx->update = (update_func)aarch64_sha256_update;
-               ctx->digest = (digest_func)sha224_digest;
-               ctx->init = (init_func)sha224_init;
+               ctx->update = (nettle_hash_update_func *)aarch64_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha224_digest;
+               ctx->init = (nettle_hash_init_func *)sha224_init;
                ctx->ctx_ptr = &ctx->ctx.sha224;
                ctx->length = SHA224_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA256:
                sha256_init(&ctx->ctx.sha256);
-               ctx->update = (update_func)aarch64_sha256_update;
-               ctx->digest = (digest_func)sha256_digest;
-               ctx->init = (init_func)sha256_init;
+               ctx->update = (nettle_hash_update_func *)aarch64_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha256_digest;
+               ctx->init = (nettle_hash_init_func *)sha256_init;
                ctx->ctx_ptr = &ctx->ctx.sha256;
                ctx->length = SHA256_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA384:
                sha384_init(&ctx->ctx.sha384);
-               ctx->update = (update_func)aarch64_sha512_update;
-               ctx->digest = (digest_func)sha384_digest;
-               ctx->init = (init_func)sha384_init;
+               ctx->update = (nettle_hash_update_func *)aarch64_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)sha384_digest;
+               ctx->init = (nettle_hash_init_func *)sha384_init;
                ctx->ctx_ptr = &ctx->ctx.sha384;
                ctx->length = SHA384_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA512:
                sha512_init(&ctx->ctx.sha512);
-               ctx->update = (update_func)aarch64_sha512_update;
-               ctx->digest = (digest_func)sha512_digest;
-               ctx->init = (init_func)sha512_init;
+               ctx->update = (nettle_hash_update_func *)aarch64_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)sha512_digest;
+               ctx->init = (nettle_hash_init_func *)sha512_init;
                ctx->ctx_ptr = &ctx->ctx.sha512;
                ctx->length = SHA512_DIGEST_SIZE;
                break;
index b2c4f095ecc8970c8f9bc93cf870243915e4558f..6bd84b483468c1b0411066121f8a3249b6564610 100644 (file)
 
 #ifdef HAVE_LIBNETTLE
 
-typedef void (*update_func)(void *, size_t, const uint8_t *);
-typedef void (*digest_func)(void *, size_t, uint8_t *);
+/* Can't use nettle_set_key_func as it doesn't have the second argument */
 typedef void (*set_key_func)(void *, size_t, const uint8_t *);
-typedef void (*init_func)(void *);
 
 struct padlock_hash_ctx {
        union {
@@ -51,9 +49,9 @@ struct padlock_hash_ctx {
        void *ctx_ptr;
        gnutls_digest_algorithm_t algo;
        size_t length;
-       update_func update;
-       digest_func digest;
-       init_func init;
+       nettle_hash_update_func *update;
+       nettle_hash_digest_func *digest;
+       nettle_hash_init_func *init;
 };
 
 static int wrap_padlock_hash_update(void *_ctx, const void *text,
@@ -217,41 +215,41 @@ static int _ctx_init(gnutls_digest_algorithm_t algo,
        switch (algo) {
        case GNUTLS_DIG_SHA1:
                sha1_init(&ctx->ctx.sha1);
-               ctx->update = (update_func)padlock_sha1_update;
-               ctx->digest = (digest_func)padlock_sha1_digest;
-               ctx->init = (init_func)sha1_init;
+               ctx->update = (nettle_hash_update_func *)padlock_sha1_update;
+               ctx->digest = (nettle_hash_digest_func *)padlock_sha1_digest;
+               ctx->init = (nettle_hash_init_func *)sha1_init;
                ctx->ctx_ptr = &ctx->ctx.sha1;
                ctx->length = SHA1_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA224:
                sha224_init(&ctx->ctx.sha224);
-               ctx->update = (update_func)padlock_sha256_update;
-               ctx->digest = (digest_func)padlock_sha256_digest;
-               ctx->init = (init_func)sha224_init;
+               ctx->update = (nettle_hash_update_func *)padlock_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)padlock_sha256_digest;
+               ctx->init = (nettle_hash_init_func *)sha224_init;
                ctx->ctx_ptr = &ctx->ctx.sha224;
                ctx->length = SHA224_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA256:
                sha256_init(&ctx->ctx.sha256);
-               ctx->update = (update_func)padlock_sha256_update;
-               ctx->digest = (digest_func)padlock_sha256_digest;
-               ctx->init = (init_func)sha256_init;
+               ctx->update = (nettle_hash_update_func *)padlock_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)padlock_sha256_digest;
+               ctx->init = (nettle_hash_init_func *)sha256_init;
                ctx->ctx_ptr = &ctx->ctx.sha256;
                ctx->length = SHA256_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA384:
                sha384_init(&ctx->ctx.sha384);
-               ctx->update = (update_func)padlock_sha512_update;
-               ctx->digest = (digest_func)padlock_sha512_digest;
-               ctx->init = (init_func)sha384_init;
+               ctx->update = (nettle_hash_update_func *)padlock_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)padlock_sha512_digest;
+               ctx->init = (nettle_hash_init_func *)sha384_init;
                ctx->ctx_ptr = &ctx->ctx.sha384;
                ctx->length = SHA384_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA512:
                sha512_init(&ctx->ctx.sha512);
-               ctx->update = (update_func)padlock_sha512_update;
-               ctx->digest = (digest_func)padlock_sha512_digest;
-               ctx->init = (init_func)sha512_init;
+               ctx->update = (nettle_hash_update_func *)padlock_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)padlock_sha512_digest;
+               ctx->init = (nettle_hash_init_func *)sha512_init;
                ctx->ctx_ptr = &ctx->ctx.sha512;
                ctx->length = SHA512_DIGEST_SIZE;
                break;
index c0dbce62ef1f7ff39e9549bcb67d0c1b78faea7f..9e8135801af4c6305eb2d8c269c61fdb7adef6a3 100644 (file)
@@ -36,10 +36,8 @@ void sha1_block_data_order(void *c, const void *p, size_t len);
 void sha256_block_data_order(void *c, const void *p, size_t len);
 void sha512_block_data_order(void *c, const void *p, size_t len);
 
-typedef void (*update_func)(void *, size_t, const uint8_t *);
-typedef void (*digest_func)(void *, size_t, uint8_t *);
+/* Can't use nettle_set_key_func as it doesn't have the second argument */
 typedef void (*set_key_func)(void *, size_t, const uint8_t *);
-typedef void (*init_func)(void *);
 
 struct x86_hash_ctx {
        union {
@@ -52,9 +50,9 @@ struct x86_hash_ctx {
        void *ctx_ptr;
        gnutls_digest_algorithm_t algo;
        size_t length;
-       update_func update;
-       digest_func digest;
-       init_func init;
+       nettle_hash_update_func *update;
+       nettle_hash_digest_func *digest;
+       nettle_hash_init_func *init;
 };
 
 static int wrap_x86_hash_update(void *_ctx, const void *text, size_t textsize)
@@ -231,41 +229,41 @@ static int _ctx_init(gnutls_digest_algorithm_t algo, struct x86_hash_ctx *ctx)
        switch (algo) {
        case GNUTLS_DIG_SHA1:
                sha1_init(&ctx->ctx.sha1);
-               ctx->update = (update_func)x86_sha1_update;
-               ctx->digest = (digest_func)sha1_digest;
-               ctx->init = (init_func)sha1_init;
+               ctx->update = (nettle_hash_update_func *)x86_sha1_update;
+               ctx->digest = (nettle_hash_digest_func *)sha1_digest;
+               ctx->init = (nettle_hash_init_func *)sha1_init;
                ctx->ctx_ptr = &ctx->ctx.sha1;
                ctx->length = SHA1_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA224:
                sha224_init(&ctx->ctx.sha224);
-               ctx->update = (update_func)x86_sha256_update;
-               ctx->digest = (digest_func)sha224_digest;
-               ctx->init = (init_func)sha224_init;
+               ctx->update = (nettle_hash_update_func *)x86_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha224_digest;
+               ctx->init = (nettle_hash_init_func *)sha224_init;
                ctx->ctx_ptr = &ctx->ctx.sha224;
                ctx->length = SHA224_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA256:
                sha256_init(&ctx->ctx.sha256);
-               ctx->update = (update_func)x86_sha256_update;
-               ctx->digest = (digest_func)sha256_digest;
-               ctx->init = (init_func)sha256_init;
+               ctx->update = (nettle_hash_update_func *)x86_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha256_digest;
+               ctx->init = (nettle_hash_init_func *)sha256_init;
                ctx->ctx_ptr = &ctx->ctx.sha256;
                ctx->length = SHA256_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA384:
                sha384_init(&ctx->ctx.sha384);
-               ctx->update = (update_func)x86_sha512_update;
-               ctx->digest = (digest_func)sha384_digest;
-               ctx->init = (init_func)sha384_init;
+               ctx->update = (nettle_hash_update_func *)x86_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)sha384_digest;
+               ctx->init = (nettle_hash_init_func *)sha384_init;
                ctx->ctx_ptr = &ctx->ctx.sha384;
                ctx->length = SHA384_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA512:
                sha512_init(&ctx->ctx.sha512);
-               ctx->update = (update_func)x86_sha512_update;
-               ctx->digest = (digest_func)sha512_digest;
-               ctx->init = (init_func)sha512_init;
+               ctx->update = (nettle_hash_update_func *)x86_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)sha512_digest;
+               ctx->init = (nettle_hash_init_func *)sha512_init;
                ctx->ctx_ptr = &ctx->ctx.sha512;
                ctx->length = SHA512_DIGEST_SIZE;
                break;
index 2c76fb56aefec8e11d6bedee225c8b6a87949764..495856cefcba99421e0d35dd33bbeddf8e3df7f0 100644 (file)
 #endif
 #include <nettle/gcm.h>
 
-typedef void (*update_func)(void *, size_t, const uint8_t *);
-typedef void (*digest_func)(void *, size_t, uint8_t *);
+/* Can't use nettle_set_key_func as it doesn't have the second argument */
 typedef void (*set_key_func)(void *, size_t, const uint8_t *);
 typedef void (*set_nonce_func)(void *, size_t, const uint8_t *);
-typedef void (*init_func)(void *);
 typedef bool (*finished_func)(void *);
 
 static int wrap_nettle_hash_init(gnutls_digest_algorithm_t algo, void **_ctx);
@@ -101,9 +99,9 @@ struct nettle_hash_ctx {
        void *ctx_ptr;
        gnutls_digest_algorithm_t algo;
        size_t length;
-       update_func update;
-       digest_func digest;
-       init_func init;
+       nettle_hash_update_func *update;
+       nettle_hash_digest_func *digest;
+       nettle_hash_init_func *init;
        finished_func finished;
 };
 
@@ -153,8 +151,8 @@ struct nettle_mac_ctx {
        void *ctx_ptr;
        gnutls_mac_algorithm_t algo;
        size_t length;
-       update_func update;
-       digest_func digest;
+       nettle_hash_update_func *update;
+       nettle_hash_digest_func *digest;
        set_key_func set_key;
        set_nonce_func set_nonce;
 };
@@ -299,117 +297,123 @@ static int _mac_ctx_init(gnutls_mac_algorithm_t algo,
        ctx->set_nonce = NULL;
        switch (algo) {
        case GNUTLS_MAC_MD5:
-               ctx->update = (update_func)hmac_md5_update;
-               ctx->digest = (digest_func)hmac_md5_digest;
+               ctx->update = (nettle_hash_update_func *)hmac_md5_update;
+               ctx->digest = (nettle_hash_digest_func *)hmac_md5_digest;
                ctx->set_key = (set_key_func)hmac_md5_set_key;
                ctx->ctx_ptr = &ctx->ctx.md5;
                ctx->length = MD5_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_SHA1:
-               ctx->update = (update_func)hmac_sha1_update;
-               ctx->digest = (digest_func)hmac_sha1_digest;
+               ctx->update = (nettle_hash_update_func *)hmac_sha1_update;
+               ctx->digest = (nettle_hash_digest_func *)hmac_sha1_digest;
                ctx->set_key = (set_key_func)hmac_sha1_set_key;
                ctx->ctx_ptr = &ctx->ctx.sha1;
                ctx->length = SHA1_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_SHA224:
-               ctx->update = (update_func)hmac_sha224_update;
-               ctx->digest = (digest_func)hmac_sha224_digest;
+               ctx->update = (nettle_hash_update_func *)hmac_sha224_update;
+               ctx->digest = (nettle_hash_digest_func *)hmac_sha224_digest;
                ctx->set_key = (set_key_func)hmac_sha224_set_key;
                ctx->ctx_ptr = &ctx->ctx.sha224;
                ctx->length = SHA224_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_SHA256:
-               ctx->update = (update_func)hmac_sha256_update;
-               ctx->digest = (digest_func)hmac_sha256_digest;
+               ctx->update = (nettle_hash_update_func *)hmac_sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)hmac_sha256_digest;
                ctx->set_key = (set_key_func)hmac_sha256_set_key;
                ctx->ctx_ptr = &ctx->ctx.sha256;
                ctx->length = SHA256_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_SHA384:
-               ctx->update = (update_func)hmac_sha384_update;
-               ctx->digest = (digest_func)hmac_sha384_digest;
+               ctx->update = (nettle_hash_update_func *)hmac_sha384_update;
+               ctx->digest = (nettle_hash_digest_func *)hmac_sha384_digest;
                ctx->set_key = (set_key_func)hmac_sha384_set_key;
                ctx->ctx_ptr = &ctx->ctx.sha384;
                ctx->length = SHA384_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_SHA512:
-               ctx->update = (update_func)hmac_sha512_update;
-               ctx->digest = (digest_func)hmac_sha512_digest;
+               ctx->update = (nettle_hash_update_func *)hmac_sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)hmac_sha512_digest;
                ctx->set_key = (set_key_func)hmac_sha512_set_key;
                ctx->ctx_ptr = &ctx->ctx.sha512;
                ctx->length = SHA512_DIGEST_SIZE;
                break;
 #if ENABLE_GOST
        case GNUTLS_MAC_GOSTR_94:
-               ctx->update = (update_func)hmac_gosthash94cp_update;
-               ctx->digest = (digest_func)hmac_gosthash94cp_digest;
+               ctx->update =
+                       (nettle_hash_update_func *)hmac_gosthash94cp_update;
+               ctx->digest =
+                       (nettle_hash_digest_func *)hmac_gosthash94cp_digest;
                ctx->set_key = (set_key_func)hmac_gosthash94cp_set_key;
                ctx->ctx_ptr = &ctx->ctx.gosthash94cp;
                ctx->length = GOSTHASH94CP_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_STREEBOG_256:
-               ctx->update = (update_func)hmac_streebog256_update;
-               ctx->digest = (digest_func)hmac_streebog256_digest;
+               ctx->update =
+                       (nettle_hash_update_func *)hmac_streebog256_update;
+               ctx->digest =
+                       (nettle_hash_digest_func *)hmac_streebog256_digest;
                ctx->set_key = (set_key_func)hmac_streebog256_set_key;
                ctx->ctx_ptr = &ctx->ctx.streebog256;
                ctx->length = STREEBOG256_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_STREEBOG_512:
-               ctx->update = (update_func)hmac_streebog512_update;
-               ctx->digest = (digest_func)hmac_streebog512_digest;
+               ctx->update =
+                       (nettle_hash_update_func *)hmac_streebog512_update;
+               ctx->digest =
+                       (nettle_hash_digest_func *)hmac_streebog512_digest;
                ctx->set_key = (set_key_func)hmac_streebog512_set_key;
                ctx->ctx_ptr = &ctx->ctx.streebog512;
                ctx->length = STREEBOG512_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_GOST28147_TC26Z_IMIT:
-               ctx->update = (update_func)gost28147_imit_update;
-               ctx->digest = (digest_func)gost28147_imit_digest;
+               ctx->update = (nettle_hash_update_func *)gost28147_imit_update;
+               ctx->digest = (nettle_hash_digest_func *)gost28147_imit_digest;
                ctx->set_key = _wrap_gost28147_imit_set_key_tc26z;
                ctx->ctx_ptr = &ctx->ctx.gost28147_imit;
                ctx->length = GOST28147_IMIT_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_MAGMA_OMAC:
-               ctx->update = (update_func)cmac_magma_update;
-               ctx->digest = (digest_func)cmac_magma_digest;
+               ctx->update = (nettle_hash_update_func *)cmac_magma_update;
+               ctx->digest = (nettle_hash_digest_func *)cmac_magma_digest;
                ctx->set_key = _wrap_cmac_magma_set_key;
                ctx->ctx_ptr = &ctx->ctx.magma;
                ctx->length = CMAC64_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_KUZNYECHIK_OMAC:
-               ctx->update = (update_func)cmac_kuznyechik_update;
-               ctx->digest = (digest_func)cmac_kuznyechik_digest;
+               ctx->update = (nettle_hash_update_func *)cmac_kuznyechik_update;
+               ctx->digest = (nettle_hash_digest_func *)cmac_kuznyechik_digest;
                ctx->set_key = _wrap_cmac_kuznyechik_set_key;
                ctx->ctx_ptr = &ctx->ctx.kuznyechik;
                ctx->length = CMAC128_DIGEST_SIZE;
                break;
 #endif
        case GNUTLS_MAC_UMAC_96:
-               ctx->update = (update_func)umac96_update;
-               ctx->digest = (digest_func)umac96_digest;
+               ctx->update = (nettle_hash_update_func *)umac96_update;
+               ctx->digest = (nettle_hash_digest_func *)umac96_digest;
                ctx->set_key = _wrap_umac96_set_key;
                ctx->set_nonce = (set_nonce_func)umac96_set_nonce;
                ctx->ctx_ptr = &ctx->ctx.umac96;
                ctx->length = 12;
                break;
        case GNUTLS_MAC_UMAC_128:
-               ctx->update = (update_func)umac128_update;
-               ctx->digest = (digest_func)umac128_digest;
+               ctx->update = (nettle_hash_update_func *)umac128_update;
+               ctx->digest = (nettle_hash_digest_func *)umac128_digest;
                ctx->set_key = _wrap_umac128_set_key;
                ctx->set_nonce = (set_nonce_func)umac128_set_nonce;
                ctx->ctx_ptr = &ctx->ctx.umac128;
                ctx->length = 16;
                break;
        case GNUTLS_MAC_AES_CMAC_128:
-               ctx->update = (update_func)cmac_aes128_update;
-               ctx->digest = (digest_func)cmac_aes128_digest;
+               ctx->update = (nettle_hash_update_func *)cmac_aes128_update;
+               ctx->digest = (nettle_hash_digest_func *)cmac_aes128_digest;
                ctx->set_key = _wrap_cmac128_set_key;
                ctx->ctx_ptr = &ctx->ctx.cmac128;
                ctx->length = CMAC128_DIGEST_SIZE;
                break;
        case GNUTLS_MAC_AES_CMAC_256:
-               ctx->update = (update_func)cmac_aes256_update;
-               ctx->digest = (digest_func)cmac_aes256_digest;
+               ctx->update = (nettle_hash_update_func *)cmac_aes256_update;
+               ctx->digest = (nettle_hash_digest_func *)cmac_aes256_digest;
                ctx->set_key = _wrap_cmac256_set_key;
                ctx->ctx_ptr = &ctx->ctx.cmac256;
                ctx->length = CMAC128_DIGEST_SIZE;
@@ -695,134 +699,134 @@ static int _ctx_init(gnutls_digest_algorithm_t algo,
        ctx->finished = NULL;
        switch (algo) {
        case GNUTLS_DIG_MD5:
-               ctx->init = (init_func)md5_init;
-               ctx->update = (update_func)md5_update;
-               ctx->digest = (digest_func)md5_digest;
+               ctx->init = (nettle_hash_init_func *)md5_init;
+               ctx->update = (nettle_hash_update_func *)md5_update;
+               ctx->digest = (nettle_hash_digest_func *)md5_digest;
                ctx->ctx_ptr = &ctx->ctx.md5;
                ctx->length = MD5_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA1:
-               ctx->init = (init_func)sha1_init;
-               ctx->update = (update_func)sha1_update;
-               ctx->digest = (digest_func)sha1_digest;
+               ctx->init = (nettle_hash_init_func *)sha1_init;
+               ctx->update = (nettle_hash_update_func *)sha1_update;
+               ctx->digest = (nettle_hash_digest_func *)sha1_digest;
                ctx->ctx_ptr = &ctx->ctx.sha1;
                ctx->length = SHA1_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_MD5_SHA1:
-               ctx->init = (init_func)_md5_sha1_init;
-               ctx->update = (update_func)_md5_sha1_update;
-               ctx->digest = (digest_func)_md5_sha1_digest;
+               ctx->init = (nettle_hash_init_func *)_md5_sha1_init;
+               ctx->update = (nettle_hash_update_func *)_md5_sha1_update;
+               ctx->digest = (nettle_hash_digest_func *)_md5_sha1_digest;
                ctx->ctx_ptr = &ctx->ctx.md5_sha1;
                ctx->length = MD5_DIGEST_SIZE + SHA1_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA224:
-               ctx->init = (init_func)sha224_init;
-               ctx->update = (update_func)sha224_update;
-               ctx->digest = (digest_func)sha224_digest;
+               ctx->init = (nettle_hash_init_func *)sha224_init;
+               ctx->update = (nettle_hash_update_func *)sha224_update;
+               ctx->digest = (nettle_hash_digest_func *)sha224_digest;
                ctx->ctx_ptr = &ctx->ctx.sha224;
                ctx->length = SHA224_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA256:
-               ctx->init = (init_func)sha256_init;
-               ctx->update = (update_func)sha256_update;
-               ctx->digest = (digest_func)sha256_digest;
+               ctx->init = (nettle_hash_init_func *)sha256_init;
+               ctx->update = (nettle_hash_update_func *)sha256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha256_digest;
                ctx->ctx_ptr = &ctx->ctx.sha256;
                ctx->length = SHA256_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA384:
-               ctx->init = (init_func)sha384_init;
-               ctx->update = (update_func)sha384_update;
-               ctx->digest = (digest_func)sha384_digest;
+               ctx->init = (nettle_hash_init_func *)sha384_init;
+               ctx->update = (nettle_hash_update_func *)sha384_update;
+               ctx->digest = (nettle_hash_digest_func *)sha384_digest;
                ctx->ctx_ptr = &ctx->ctx.sha384;
                ctx->length = SHA384_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA512:
-               ctx->init = (init_func)sha512_init;
-               ctx->update = (update_func)sha512_update;
-               ctx->digest = (digest_func)sha512_digest;
+               ctx->init = (nettle_hash_init_func *)sha512_init;
+               ctx->update = (nettle_hash_update_func *)sha512_update;
+               ctx->digest = (nettle_hash_digest_func *)sha512_digest;
                ctx->ctx_ptr = &ctx->ctx.sha512;
                ctx->length = SHA512_DIGEST_SIZE;
                break;
 #ifdef NETTLE_SHA3_FIPS202
        case GNUTLS_DIG_SHA3_224:
-               ctx->init = (init_func)sha3_224_init;
-               ctx->update = (update_func)sha3_224_update;
-               ctx->digest = (digest_func)sha3_224_digest;
+               ctx->init = (nettle_hash_init_func *)sha3_224_init;
+               ctx->update = (nettle_hash_update_func *)sha3_224_update;
+               ctx->digest = (nettle_hash_digest_func *)sha3_224_digest;
                ctx->ctx_ptr = &ctx->ctx.sha3_224;
                ctx->length = SHA3_224_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA3_256:
-               ctx->init = (init_func)sha3_256_init;
-               ctx->update = (update_func)sha3_256_update;
-               ctx->digest = (digest_func)sha3_256_digest;
+               ctx->init = (nettle_hash_init_func *)sha3_256_init;
+               ctx->update = (nettle_hash_update_func *)sha3_256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha3_256_digest;
                ctx->ctx_ptr = &ctx->ctx.sha3_256;
                ctx->length = SHA3_256_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA3_384:
-               ctx->init = (init_func)sha3_384_init;
-               ctx->update = (update_func)sha3_384_update;
-               ctx->digest = (digest_func)sha3_384_digest;
+               ctx->init = (nettle_hash_init_func *)sha3_384_init;
+               ctx->update = (nettle_hash_update_func *)sha3_384_update;
+               ctx->digest = (nettle_hash_digest_func *)sha3_384_digest;
                ctx->ctx_ptr = &ctx->ctx.sha3_384;
                ctx->length = SHA3_384_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHA3_512:
-               ctx->init = (init_func)sha3_512_init;
-               ctx->update = (update_func)sha3_512_update;
-               ctx->digest = (digest_func)sha3_512_digest;
+               ctx->init = (nettle_hash_init_func *)sha3_512_init;
+               ctx->update = (nettle_hash_update_func *)sha3_512_update;
+               ctx->digest = (nettle_hash_digest_func *)sha3_512_digest;
                ctx->ctx_ptr = &ctx->ctx.sha3_512;
                ctx->length = SHA3_512_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_SHAKE_128:
-               ctx->init = (init_func)sha3_128_init;
-               ctx->update = (update_func)sha3_128_update;
-               ctx->digest = (digest_func)sha3_128_shake_output;
+               ctx->init = (nettle_hash_init_func *)sha3_128_init;
+               ctx->update = (nettle_hash_update_func *)sha3_128_update;
+               ctx->digest = (nettle_hash_digest_func *)sha3_128_shake_output;
                ctx->finished = _wrap_sha3_128_shake_finished;
                ctx->ctx_ptr = &ctx->ctx.sha3_128;
                ctx->length = 0; /* unused */
                break;
        case GNUTLS_DIG_SHAKE_256:
-               ctx->init = (init_func)sha3_256_init;
-               ctx->update = (update_func)sha3_256_update;
-               ctx->digest = (digest_func)sha3_256_shake_output;
+               ctx->init = (nettle_hash_init_func *)sha3_256_init;
+               ctx->update = (nettle_hash_update_func *)sha3_256_update;
+               ctx->digest = (nettle_hash_digest_func *)sha3_256_shake_output;
                ctx->finished = _wrap_sha3_256_shake_finished;
                ctx->ctx_ptr = &ctx->ctx.sha3_256;
                ctx->length = 0; /* unused */
                break;
 #endif
        case GNUTLS_DIG_MD2:
-               ctx->init = (init_func)md2_init;
-               ctx->update = (update_func)md2_update;
-               ctx->digest = (digest_func)md2_digest;
+               ctx->init = (nettle_hash_init_func *)md2_init;
+               ctx->update = (nettle_hash_update_func *)md2_update;
+               ctx->digest = (nettle_hash_digest_func *)md2_digest;
                ctx->ctx_ptr = &ctx->ctx.md2;
                ctx->length = MD2_DIGEST_SIZE;
                break;
 
        case GNUTLS_DIG_RMD160:
-               ctx->init = (init_func)ripemd160_init;
-               ctx->update = (update_func)ripemd160_update;
-               ctx->digest = (digest_func)ripemd160_digest;
+               ctx->init = (nettle_hash_init_func *)ripemd160_init;
+               ctx->update = (nettle_hash_update_func *)ripemd160_update;
+               ctx->digest = (nettle_hash_digest_func *)ripemd160_digest;
                ctx->ctx_ptr = &ctx->ctx.ripemd160;
                ctx->length = RIPEMD160_DIGEST_SIZE;
                break;
 #if ENABLE_GOST
        case GNUTLS_DIG_GOSTR_94:
-               ctx->init = (init_func)gosthash94cp_init;
-               ctx->update = (update_func)gosthash94cp_update;
-               ctx->digest = (digest_func)gosthash94cp_digest;
+               ctx->init = (nettle_hash_init_func *)gosthash94cp_init;
+               ctx->update = (nettle_hash_update_func *)gosthash94cp_update;
+               ctx->digest = (nettle_hash_digest_func *)gosthash94cp_digest;
                ctx->ctx_ptr = &ctx->ctx.gosthash94cp;
                ctx->length = GOSTHASH94_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_STREEBOG_256:
-               ctx->init = (init_func)streebog256_init;
-               ctx->update = (update_func)streebog256_update;
-               ctx->digest = (digest_func)streebog256_digest;
+               ctx->init = (nettle_hash_init_func *)streebog256_init;
+               ctx->update = (nettle_hash_update_func *)streebog256_update;
+               ctx->digest = (nettle_hash_digest_func *)streebog256_digest;
                ctx->ctx_ptr = &ctx->ctx.streebog256;
                ctx->length = STREEBOG256_DIGEST_SIZE;
                break;
        case GNUTLS_DIG_STREEBOG_512:
-               ctx->init = (init_func)streebog512_init;
-               ctx->update = (update_func)streebog512_update;
-               ctx->digest = (digest_func)streebog512_digest;
+               ctx->init = (nettle_hash_init_func *)streebog512_init;
+               ctx->update = (nettle_hash_update_func *)streebog512_update;
+               ctx->digest = (nettle_hash_digest_func *)streebog512_digest;
                ctx->ctx_ptr = &ctx->ctx.streebog512;
                ctx->length = STREEBOG512_DIGEST_SIZE;
                break;