From: Niels Möller Date: Wed, 30 Oct 2024 13:20:30 +0000 (+0100) Subject: Tweak HMAC_CTX macro. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f467044caa8194b272bece3949d1fce5e4eb7ac;p=thirdparty%2Fnettle.git Tweak HMAC_CTX macro. --- diff --git a/hmac.h b/hmac.h index 892b07aa..f7823758 100644 --- a/hmac.h +++ b/hmac.h @@ -104,10 +104,13 @@ hmac_digest(const void *outer, const void *inner, void *state, uint8_t *digest); -#define HMAC_CTX(type, size) \ -{ char outer[size]; char inner[size]; type state; } +#define _NETTLE_HMAC_CTX(type) { \ + char outer[offsetof (type, index)]; \ + char inner[offsetof (type, index)]; \ + type state; \ + } -#define OLD_HMAC_CTX(type) \ +#define HMAC_CTX(type) \ { type outer; type inner; type state; } #define HMAC_SET_KEY(ctx, hash, length, key) \ @@ -121,7 +124,7 @@ hmac_digest(const void *outer, const void *inner, void *state, /* HMAC using specific hash functions */ /* hmac-md5 */ -struct hmac_md5_ctx HMAC_CTX(struct md5_ctx, offsetof (struct md5_ctx, index)); +struct hmac_md5_ctx _NETTLE_HMAC_CTX (struct md5_ctx); void hmac_md5_set_key(struct hmac_md5_ctx *ctx, @@ -137,7 +140,7 @@ hmac_md5_digest(struct hmac_md5_ctx *ctx, /* hmac-ripemd160 */ -struct hmac_ripemd160_ctx HMAC_CTX(struct ripemd160_ctx, offsetof (struct ripemd160_ctx, index)); +struct hmac_ripemd160_ctx _NETTLE_HMAC_CTX (struct ripemd160_ctx); void hmac_ripemd160_set_key(struct hmac_ripemd160_ctx *ctx, @@ -153,7 +156,7 @@ hmac_ripemd160_digest(struct hmac_ripemd160_ctx *ctx, /* hmac-sha1 */ -struct hmac_sha1_ctx HMAC_CTX (struct sha1_ctx, offsetof (struct sha1_ctx, index)); +struct hmac_sha1_ctx _NETTLE_HMAC_CTX (struct sha1_ctx); void hmac_sha1_set_key(struct hmac_sha1_ctx *ctx, @@ -168,7 +171,7 @@ hmac_sha1_digest(struct hmac_sha1_ctx *ctx, uint8_t *digest); /* hmac-sha256 */ -struct hmac_sha256_ctx HMAC_CTX (struct sha256_ctx, offsetof(struct sha256_ctx, index)); +struct hmac_sha256_ctx _NETTLE_HMAC_CTX (struct sha256_ctx); void hmac_sha256_set_key(struct hmac_sha256_ctx *ctx, @@ -196,7 +199,7 @@ hmac_sha224_digest(struct hmac_sha224_ctx *ctx, uint8_t *digest); /* hmac-sha512 */ -struct hmac_sha512_ctx HMAC_CTX (struct sha512_ctx, offsetof (struct sha512_ctx, index)); +struct hmac_sha512_ctx _NETTLE_HMAC_CTX (struct sha512_ctx); void hmac_sha512_set_key(struct hmac_sha512_ctx *ctx, @@ -224,7 +227,7 @@ hmac_sha384_digest(struct hmac_sha512_ctx *ctx, uint8_t *digest); /* hmac-gosthash94 */ -struct hmac_gosthash94_ctx HMAC_CTX (struct gosthash94_ctx, offsetof (struct gosthash94_ctx,index)); +struct hmac_gosthash94_ctx _NETTLE_HMAC_CTX (struct gosthash94_ctx); void hmac_gosthash94_set_key(struct hmac_gosthash94_ctx *ctx, @@ -254,7 +257,7 @@ hmac_gosthash94cp_digest(struct hmac_gosthash94cp_ctx *ctx, /* hmac-streebog */ -struct hmac_streebog512_ctx HMAC_CTX (struct streebog512_ctx, offsetof (struct streebog512_ctx, index)); +struct hmac_streebog512_ctx _NETTLE_HMAC_CTX (struct streebog512_ctx); void hmac_streebog512_set_key(struct hmac_streebog512_ctx *ctx, @@ -281,7 +284,7 @@ hmac_streebog256_digest(struct hmac_streebog256_ctx *ctx, uint8_t *digest); /* hmac-sm3 */ -struct hmac_sm3_ctx HMAC_CTX (struct sm3_ctx, offsetof (struct sm3_ctx, index)); +struct hmac_sm3_ctx _NETTLE_HMAC_CTX (struct sm3_ctx); void hmac_sm3_set_key(struct hmac_sm3_ctx *ctx,