about summary refs log tree commit diff
path: root/src/libutil/sha256.h
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-01-14T12·03+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-01-14T12·03+0000
commit63791eb05b236afcea510d769a8943f8be3dbc9c (patch)
tree48b25ce1d2336bc41ab838475d915a7d01134e98 /src/libutil/sha256.h
parent37b51a9aa6d5d0fb97bad0d1a27d27304da277c2 (diff)
* Add SHA-256.
* Tests for the various hashes.

Diffstat (limited to 'src/libutil/sha256.h')
-rw-r--r--src/libutil/sha256.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libutil/sha256.h b/src/libutil/sha256.h
new file mode 100644
index 000000000000..39b301342f42
--- /dev/null
+++ b/src/libutil/sha256.h
@@ -0,0 +1,35 @@
+#ifndef _SHA256_H
+#define _SHA256_H 1
+
+#include <stdint.h>
+
+#define SHA_LBLOCK	16
+#define SHA_CBLOCK	(SHA_LBLOCK*4)	/* SHA treats input data as a
+					 * contiguous array of 32 bit
+					 * wide big-endian values. */
+
+#define SHA256_CBLOCK	(SHA_LBLOCK*4)	/* SHA-256 treats input data as a
+					 * contiguous array of 32 bit
+					 * wide big-endian values. */
+#define SHA224_DIGEST_LENGTH	28
+#define SHA256_DIGEST_LENGTH	32
+
+typedef struct SHA256state_st
+	{
+	uint32_t h[8];
+	uint32_t Nl,Nh;
+	uint32_t data[SHA_LBLOCK];
+	unsigned int num,md_len;
+	} SHA256_CTX;
+
+int SHA224_Init(SHA256_CTX *c);
+int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
+int SHA224_Final(unsigned char *md, SHA256_CTX *c);
+unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md);
+int SHA256_Init(SHA256_CTX *c);
+int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
+int SHA256_Final(unsigned char *md, SHA256_CTX *c);
+unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md);
+void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
+
+#endif