Signed-off-by: Dmitry Eremin-Solenikov <[email protected]>
---
nettle-meta.h | 10 ++++++++++
sha512-224-meta.c | 12 ++----------
sha512-256-meta.c | 12 ++----------
3 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/nettle-meta.h b/nettle-meta.h
index 74e50e59cd2e..e3db0e9d63aa 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -117,6 +117,16 @@ struct nettle_hash
(nettle_hash_digest_func *) name##_digest \
}
+#define _NETTLE_HASH_US(name, name_us, NAME) { \
+ #name, \
+ sizeof(struct name_us##_ctx), \
+ NAME##_DIGEST_SIZE, \
+ NAME##_BLOCK_SIZE, \
+ (nettle_hash_init_func *) name_us##_init, \
+ (nettle_hash_update_func *) name_us##_update, \
+ (nettle_hash_digest_func *) name_us##_digest \
+}
+
/* null-terminated list of digests implemented by this version of nettle */
const struct nettle_hash * const * _NETTLE_ATTRIBUTE_PURE
nettle_get_hashes (void);
diff --git a/sha512-224-meta.c b/sha512-224-meta.c
index 24c42bfc23d9..ce07362f3ad0 100644
--- a/sha512-224-meta.c
+++ b/sha512-224-meta.c
@@ -37,13 +37,5 @@
#include "sha2.h"
-const struct nettle_hash nettle_sha512_224 =
- {
- "sha512-224", sizeof(struct sha512_ctx),
- SHA512_224_DIGEST_SIZE,
- SHA512_224_BLOCK_SIZE,
- (nettle_hash_init_func *) sha512_224_init,
- (nettle_hash_update_func *) sha512_224_update,
- (nettle_hash_digest_func *) sha512_224_digest
- };
-
+const struct nettle_hash nettle_sha512_224
+= _NETTLE_HASH_US(sha512-224, sha512_224, SHA512_224);
diff --git a/sha512-256-meta.c b/sha512-256-meta.c
index 37d17c351878..fbaece84b998 100644
--- a/sha512-256-meta.c
+++ b/sha512-256-meta.c
@@ -37,13 +37,5 @@
#include "sha2.h"
-const struct nettle_hash nettle_sha512_256 =
- {
- "sha512-256", sizeof(struct sha512_ctx),
- SHA512_256_DIGEST_SIZE,
- SHA512_256_BLOCK_SIZE,
- (nettle_hash_init_func *) sha512_256_init,
- (nettle_hash_update_func *) sha512_256_update,
- (nettle_hash_digest_func *) sha512_256_digest
- };
-
+const struct nettle_hash nettle_sha512_256
+= _NETTLE_HASH_US(sha512-256, sha512_256, SHA512_256);
--
2.20.1
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs