From 1e951a9f3b3c35cc108d45acd73147a8dda36f6c Mon Sep 17 00:00:00 2001 From: Tharre <tharre3@gmail.com> Date: Sun, 24 Aug 2014 00:24:54 +0200 Subject: Replace openssl SHA1 functions with custom version --- src/sha1.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/sha1.h (limited to 'src/sha1.h') diff --git a/src/sha1.h b/src/sha1.h new file mode 100644 index 0000000..ee59229 --- /dev/null +++ b/src/sha1.h @@ -0,0 +1,25 @@ +/* + * Secure Hash Algorith SHA-1, as published in FIPS PUB 180-2. + * + * This implementation is in the public domain. Copyright abandoned. + * You may do anything you like with it, including evil things. + * + * This is a rewrite from scratch, based on Linus Torvalds' "block-sha1" + * from the git mailing list (August, 2009). Additional optimization + * ideas cribbed from + * - Artur Skawina (x86, particularly P4, and much benchmarking) + * - Nicolas Pitre (ARM) + */ + +#include <stddef.h> /* For size_t */ +#include <stdint.h> /* For uint32_t, uint64_t */ + +typedef struct SHA_context { + uint64_t len; /* May be shrunk to uint32_t */ + uint32_t iv[5]; + unsigned char buf[64]; /* Must be 32-bit aligned */ +} SHA_CTX; + +void SHA1_Init(struct SHA_context *c); +void SHA1_Update(struct SHA_context *c, void const *p, size_t n); +void SHA1_Final(unsigned char hash[20], struct SHA_context *c); -- cgit v1.2.3-70-g09d2