-static void alg_md5_init(void *state) { MD5Init(state); }
-static void alg_md5_update(void *state, const Byte *data, int len) {
- MD5Update(state, data, len);
-}
-static void alg_md5_final(void *state, Byte *digest) {
- MD5Final(digest, state);
-}
-static void alg_md5_oneshot(Byte *digest, const Byte *data, int len) {
- struct MD5Context ctx;
- MD5Init(&ctx);
- MD5Update(&ctx,data,len);
- MD5Final(digest,&ctx);
-}
+#define NETTLE_DIGESTS \
+ DO(sha1, SHA1) \
+ DO(sha256, SHA256) \
+ DO(md5, MD5)
+
+#define DO(name,NAME) \
+ static void alg_##name##_init(void *state) { \
+ name##_init(state); \
+ } \
+ static void alg_##name##_update(void *state, const void *data, int len) { \
+ name##_update(state, len, data); \
+ } \
+ static void alg_##name##_final(void *state, void *digest) { \
+ name##_digest(state,NAME##_DIGEST_SIZE,digest); \
+ } \
+ static void alg_##name##_oneshot(void *digest, const void *data, int len) { \
+ struct name##_ctx ctx; \
+ name##_init(&ctx); \
+ name##_update(&ctx, len, data); \
+ name##_digest(&ctx,NAME##_DIGEST_SIZE,digest); \
+ }
+ NETTLE_DIGESTS
+#undef DO
+
+const HashAlgPropInfo hashalgpropinfos[]= {
+ { "hashlen", offsetof(HashAlgInfo, hashsize) },
+ { "blocklen", offsetof(HashAlgInfo, blocksize) },
+ { 0 }
+};