changeset 2874:7a0ed5f35bc6

*** empty log message ***
author Jim Meyering <jim@meyering.net>
date Wed, 20 Sep 2000 08:05:39 +0000
parents 78320da59080
children 2d1962949083
files lib/ChangeLog lib/sha.h
diffstat 2 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog	Wed Sep 20 08:05:24 2000 +0000
+++ b/lib/ChangeLog	Wed Sep 20 08:05:39 2000 +0000
@@ -1,3 +1,9 @@
+2000-09-20  Jim Meyering  <meyering@lucent.com>
+
+	* Makefile.am (libfetish_a_SOURCES): Add sha.c.
+	(noinst_HEADERS): Add sha.h.
+	Based on code from Scott G. Miller and from GnuPG.
+
 2000-09-15  Jim Meyering  <meyering@lucent.com>
 
 	* regex.c: Update from libc.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/sha.h	Wed Sep 20 08:05:39 2000 +0000
@@ -0,0 +1,75 @@
+/* sha.h - Declaration of functions and datatypes for SHA1 sum computing
+   library functions.
+
+   Copyright (C) 1999, Scott G. Miller
+*/
+
+#ifndef _SHA_H
+# define _SHA_H 1
+
+# include <stdio.h>
+# include "md5.h"
+
+/* Structure to save state of computation between the single steps.  */
+struct sha_ctx
+{
+  md5_uint32 A;
+  md5_uint32 B;
+  md5_uint32 C;
+  md5_uint32 D;
+  md5_uint32 E;
+
+  md5_uint32 total[2];
+  md5_uint32 buflen;
+  char buffer[128];
+};
+
+
+/* Starting with the result of former calls of this function (or the
+   initialization function update the context for the next LEN bytes
+   starting at BUFFER.
+   It is necessary that LEN is a multiple of 64!!! */
+extern void sha_process_block __P ((const void *buffer, size_t len,
+                            struct sha_ctx *ctx));
+
+/* Starting with the result of former calls of this function (or the
+   initialization function update the context for the next LEN bytes
+   starting at BUFFER.
+   It is NOT required that LEN is a multiple of 64.  */
+extern void sha_process_bytes __P((const void *buffer, size_t len,
+				    struct sha_ctx *ctx));
+
+/* Initialize structure containing state of computation. */
+extern void sha_init_ctx __P ((struct sha_ctx *ctx));
+
+/* Process the remaining bytes in the buffer and put result from CTX
+   in first 16 bytes following RESBUF.  The result is always in little
+   endian byte order, so that a byte-wise output yields to the wanted
+   ASCII representation of the message digest.
+
+   IMPORTANT: On some systems it is required that RESBUF is correctly
+   aligned for a 32 bits value.  */
+extern void *sha_finish_ctx __P ((struct sha_ctx *ctx, void *resbuf));
+
+
+/* Put result from CTX in first 16 bytes following RESBUF.  The result is
+   always in little endian byte order, so that a byte-wise output yields
+   to the wanted ASCII representation of the message digest.
+
+   IMPORTANT: On some systems it is required that RESBUF is correctly
+   aligned for a 32 bits value.  */
+extern void *sha_read_ctx __P ((const struct sha_ctx *ctx, void *resbuf));
+
+
+/* Compute MD5 message digest for bytes read from STREAM.  The
+   resulting message digest number will be written into the 16 bytes
+   beginning at RESBLOCK.  */
+extern int sha_stream __P ((FILE *stream, void *resblock));
+
+/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
+   result is always in little endian byte order, so that a byte-wise
+   output yields to the wanted ASCII representation of the message
+   digest.  */
+extern void *sha_buffer __P ((const char *buffer, size_t len, void *resblock));
+
+#endif