summaryrefslogtreecommitdiffstats
path: root/chksums/sha256.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-23 21:36:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-23 21:36:16 -0700
commitfc0b68f105a191c7cd4dbb85251ada870119d470 (patch)
tree614de7d54761c4e3c12b386cd2b0f9bfbea342c3 /chksums/sha256.h
parent5fc1472e9ce7ebf3d3d25898f0e6288ffe87d08e (diff)
downloadtxr-fc0b68f105a191c7cd4dbb85251ada870119d470.tar.gz
txr-fc0b68f105a191c7cd4dbb85251ada870119d470.tar.bz2
txr-fc0b68f105a191c7cd4dbb85251ada870119d470.zip
* Makefile (OBJS): New objects chksum.o and chksums/sha256.o.
* chksum.c, chksum.h, chksums/sha256.c, chksums/sha256.h: New files. * lib.c (init): Call chksum_init. * txr.1: Documented. * LICENSE: Add SHA-256 copyright notice.
Diffstat (limited to 'chksums/sha256.h')
-rw-r--r--chksums/sha256.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/chksums/sha256.h b/chksums/sha256.h
new file mode 100644
index 00000000..3cd57a4e
--- /dev/null
+++ b/chksums/sha256.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright 2005 Colin Percival
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define SHA256_BLOCK_LENGTH 64
+#define SHA256_DIGEST_LENGTH 32
+#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
+
+typedef struct SHA256 {
+ u32_t state[8];
+ u64_t count;
+ u8_t buf[SHA256_BLOCK_LENGTH];
+} SHA256_t;
+
+void SHA256_init(SHA256_t *);
+void SHA256_update(SHA256_t *, const void *, size_t);
+void SHA256_final(SHA256_t *, unsigned char *);