From 9c45d9ad13fdf439d44d7443ae75da15ea0223ed Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Mon, 19 Aug 2013 16:39:41 -0400 Subject: Initial checkin Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy. --- sha1/hmac.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 sha1/hmac.c (limited to 'sha1/hmac.c') diff --git a/sha1/hmac.c b/sha1/hmac.c new file mode 100644 index 0000000..12e1833 --- /dev/null +++ b/sha1/hmac.c @@ -0,0 +1,62 @@ +/* +** Copyright 2001-2005 Double Precision, Inc. +** See COPYING for distribution information. +*/ +#define SHA1_INTERNAL +#include "sha1.h" +#include "../libhmac/hmac.h" + + +static void alloc_context_sha1( void (*func)(void *, void *), void *arg) +{ +struct SHA1_CONTEXT c; + + (*func)((void *)&c, arg); +} + +static void alloc_hash_sha1( void (*func)(unsigned char *, void *), void *arg) +{ +unsigned char c[SHA1_DIGEST_SIZE]; + + (*func)(c, arg); +} + +struct hmac_hashinfo hmac_sha1 = { + "sha1", + SHA1_BLOCK_SIZE, + SHA1_DIGEST_SIZE, + sizeof(struct SHA1_CONTEXT), + (void (*)(void *))sha1_context_init, + (void (*)(void *, const void *, unsigned))sha1_context_hashstream, + (void (*)(void *, unsigned long))sha1_context_endstream, + (void (*)(void *, unsigned char *))sha1_context_digest, + (void (*)(void *, const unsigned char *))sha1_context_restore, + alloc_context_sha1, + alloc_hash_sha1}; + +static void alloc_context_sha256( void (*func)(void *, void *), void *arg) +{ +struct SHA256_CONTEXT c; + + (*func)((void *)&c, arg); +} + +static void alloc_hash_sha256( void (*func)(unsigned char *, void *), void *arg) +{ +unsigned char c[SHA256_DIGEST_SIZE]; + + (*func)(c, arg); +} + +struct hmac_hashinfo hmac_sha256 = { + "sha256", + SHA256_BLOCK_SIZE, + SHA256_DIGEST_SIZE, + sizeof(struct SHA256_CONTEXT), + (void (*)(void *))sha256_context_init, + (void (*)(void *, const void *, unsigned))sha256_context_hashstream, + (void (*)(void *, unsigned long))sha256_context_endstream, + (void (*)(void *, unsigned char *))sha256_context_digest, + (void (*)(void *, const unsigned char *))sha256_context_restore, + alloc_context_sha256, + alloc_hash_sha256}; -- cgit v1.2.3