summaryrefslogtreecommitdiff
path: root/cipher/hash-common.h
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2013-09-18 13:50:35 +0200
committerWerner Koch <wk@gnupg.org>2013-09-18 14:19:53 +0200
commitecde77ad98690540abb21db08e5531297ed72bd0 (patch)
treed90afdb66d99caf5442cc92b0dec838e4f86aa34 /cipher/hash-common.h
parent56b5949f71f501744998f5ebc12488ebf6f1c0b5 (diff)
downloadlibgcrypt-ecde77ad98690540abb21db08e5531297ed72bd0.tar.gz
Separate common md block code
* cipher/hash-common.c (_gcry_md_block_write): New function to handle block md operations. The current implementation is limited to 64 byte buffer and u32 block counter. * cipher/md4.c, cipher/md5.c, cipher/rmd.h, cipher/rmd160.c *cipher/sha1.c, cipher/sha256.c, cipher/tiger.c: Convert to use _gcry_md_block_write. -- Whirlpool and SHA512 are left as before, as SHA512 uses 128 bytes buffer and u64 blocks counter and Whirlpool does not have trivial block handling structure. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Indentation changes, minor edits and adjustment of _gcry_sha1_hash_buffers by wk.
Diffstat (limited to 'cipher/hash-common.h')
-rw-r--r--cipher/hash-common.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/cipher/hash-common.h b/cipher/hash-common.h
index fdebef42..1d1d4ec5 100644
--- a/cipher/hash-common.h
+++ b/cipher/hash-common.h
@@ -26,8 +26,21 @@ const char * _gcry_hash_selftest_check_one
int datamode, const void *data, size_t datalen,
const void *expect, size_t expectlen);
-
-
-
+/* Type for the md_write helper function. */
+typedef void (*_gcry_md_block_write_t) (void *c, const unsigned char *buf);
+
+typedef struct gcry_md_block_ctx
+{
+ u32 nblocks;
+ int count;
+ byte buf[64];
+ size_t blocksize;
+ _gcry_md_block_write_t bwrite;
+ size_t stack_burn;
+} gcry_md_block_ctx_t;
+
+
+void
+_gcry_md_block_write( void *context, const void *inbuf_arg, size_t inlen);
#endif /*GCRY_HASH_COMMON_H*/