about summary refs log tree commit diff
path: root/src/libutil/sha1.h
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-01-13T17·39+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-01-13T17·39+0000
commit7e8961f72056f53ccf78eba0ee8c240bc2310ab8 (patch)
treef4ae8ee014f3d86aa9ec1706d1aa9e83c2329a73 /src/libutil/sha1.h
parent73992371a3bc16b27b22e53d5f7ae600dea9cf60 (diff)
* Added SHA-1 support. `nix-hash' now has an option `--type sha1' to
  select SHA-1 hashing.

Diffstat (limited to 'src/libutil/sha1.h')
-rw-r--r--src/libutil/sha1.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libutil/sha1.h b/src/libutil/sha1.h
new file mode 100644
index 000000000000..012893bd3b94
--- /dev/null
+++ b/src/libutil/sha1.h
@@ -0,0 +1,28 @@
+#ifndef _SHA_H
+#define _SHA_H
+
+#include <stdint.h>
+
+/* The SHA block size and message digest sizes, in bytes */
+
+#define SHA_DATASIZE    64
+#define SHA_DATALEN     16
+#define SHA_DIGESTSIZE  20
+#define SHA_DIGESTLEN    5
+/* The structure for storing SHA info */
+
+struct sha_ctx {
+  uint32_t digest[SHA_DIGESTLEN];  /* Message digest */
+  uint32_t count_l, count_h;       /* 64-bit block count */
+  uint8_t block[SHA_DATASIZE];     /* SHA data buffer */
+  unsigned int index;            /* index into buffer */
+};
+
+void sha_init(struct sha_ctx *ctx);
+void sha_update(struct sha_ctx *ctx, const unsigned char *buffer, uint32_t len);
+void sha_final(struct sha_ctx *ctx);
+void sha_digest(struct sha_ctx *ctx, unsigned char *s);
+void sha_copy(struct sha_ctx *dest, struct sha_ctx *src);
+
+
+#endif /* !_SHA_H */