Signed-off-by: Dmitry Eremin-Solenikov <dbarysh...@gmail.com>
---
 nettle-meta.h  | 28 ++++++++++++++++++++++++++++
 nettle-types.h | 15 +++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/nettle-meta.h b/nettle-meta.h
index e3db0e9d63aa..f21dcd9b344d 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -107,6 +107,24 @@ struct nettle_hash
   nettle_hash_digest_func *digest;
 };
 
+struct nettle_bctx_hash
+{
+  const char *name;
+
+  /* Size of the context state struct */
+  unsigned state_size;
+
+  /* Size of digests */
+  unsigned digest_size;
+
+  /* Internal block size */
+  unsigned block_size;
+
+  nettle_hash_block_init_func *block_init;
+  nettle_hash_block_update_func *block_update;
+  nettle_hash_block_digest_func *block_digest;
+};
+
 #define _NETTLE_HASH(name, NAME) {             \
  #name,                                                \
  sizeof(struct name##_ctx),                    \
@@ -127,6 +145,16 @@ struct nettle_hash
  (nettle_hash_digest_func *) name_us##_digest  \
 }
 
+#define _NETTLE_BLOCK_HASH(name, NAME) {       \
+ #name,                                                \
+ sizeof(struct name##_state),                  \
+ NAME##_DIGEST_SIZE,                           \
+ NAME##_BLOCK_SIZE,                            \
+ (nettle_hash_block_init_func *) name##_block_init,    \
+ (nettle_hash_block_update_func *) name##_block_update,        \
+ (nettle_hash_block_digest_func *) name##_block_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/nettle-types.h b/nettle-types.h
index 87292ac69730..ecb56cbba39c 100644
--- a/nettle-types.h
+++ b/nettle-types.h
@@ -65,6 +65,14 @@ union nettle_block16
   uint64_t u64[2];
 };
 
+#define BLOCK_CTX(size) struct { unsigned index; uint8_t buffer[size]; } block
+
+/* Simple block context without actual buffer length */
+struct block_ctx {
+       unsigned index;
+       uint8_t buffer[0];
+};
+
 /* Randomness. Used by key generation and dsa signature creation. */
 typedef void nettle_random_func(void *ctx,
                                size_t length, uint8_t *dst);
@@ -97,6 +105,13 @@ typedef void nettle_hash_update_func(void *ctx,
                                     const uint8_t *src);
 typedef void nettle_hash_digest_func(void *ctx,
                                     size_t length, uint8_t *dst);
+typedef void nettle_hash_block_init_func(void *ctx, struct block_ctx *bctx);
+typedef void nettle_hash_block_update_func(void *ctx,
+                                          struct block_ctx *bctx,
+                                          size_t length,
+                                          const uint8_t *src);
+typedef void nettle_hash_block_digest_func(void *ctx, struct block_ctx *bctx,
+                                          size_t length, uint8_t *dst);
 
 /* ASCII armor codecs. NOTE: Experimental and subject to change. */
 
-- 
2.20.1

_______________________________________________
nettle-bugs mailing list
nettle-bugs@lists.lysator.liu.se
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to