summaryrefslogtreecommitdiffstats
path: root/chksums/md5.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-08-23 19:32:15 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-08-23 19:32:15 -0700
commit10fd98a804097002f9331e48fc6f84f3f3d8f3e2 (patch)
treedf74904a86469a4d2dcde22a890053d0fba6d073 /chksums/md5.h
parent0dd1d1a586fcfcf11e0b1c926c8be9c4c8d525be (diff)
downloadtxr-10fd98a804097002f9331e48fc6f84f3f3d8f3e2.tar.gz
txr-10fd98a804097002f9331e48fc6f84f3f3d8f3e2.tar.bz2
txr-10fd98a804097002f9331e48fc6f84f3f3d8f3e2.zip
New: MD5 digest functions.
* Makefile (OBJS): New object file, chksums/md5.o. * chksum.c (sha256_ensure_buf): Renamed to chksum_ensure_buf and made generic so MD5 code can borrow it. (sha256_stream, sha256): Call chksum_ensure_buf instead of sha256_ensure_buf, passing in new length and hash name parameters. (md5_stream_impl, md5_buf, md5_str): New static functions. (md5_stream, md5): New functions. (chksum_init): Register md5-stream and md5 intrinsics. * chksum.h (md5_stream, md5): Declared. * chksums/md5.c, chksums/md5.h: New files.
Diffstat (limited to 'chksums/md5.h')
-rw-r--r--chksums/md5.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/chksums/md5.h b/chksums/md5.h
new file mode 100644
index 00000000..10d28d73
--- /dev/null
+++ b/chksums/md5.h
@@ -0,0 +1,41 @@
+/*
+ * RSA Data Security, Inc., MD5 message-digest algorithm
+ *
+ * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ * rights reserved.
+ *
+ * Implementations of these message-digest algorithms, including
+ * implementations derived from the reference C code in RFC-1319, RFC-1320, and
+ * RFC-1321, may be made, used, and sold without license from RSA for any
+ * purpose. [https://www.ietf.org/ietf-ftp/ietf/IPR/RSA-MD-all]
+ *
+ * DISCLAIMER: RSA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY
+ * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, VALIDITY OF INTELLECTUAL
+ * PROPERTY RIGHTS, ISSUED OR PENDING, OR THE ABSENCE OF LATENT OR OTHER
+ * DEFECTS, WHETHER OR NOT DISCOVERABLE, IN CONNECTION WITH THE MD2, MD4, OR
+ * MD5 ALGORITHMS. NOTHING IN THIS GRANT OF RIGHTS SHALL BE CONSTRUED AS A
+ * REPRESENTATION OR WARRANTY GIVEN BY RSA THAT THE IMPLEMENTATION OF THE
+ * ALGORITHM WILL NOT INFRINGE THE INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD
+ * PARTY. IN NO EVENT SHALL RSA, ITS TRUSTEES, DIRECTORS, OFFICERS, EMPLOYEES,
+ * PARENTS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF
+ * ANY KIND RESULTING FROM IMPLEMENTATION OF THIS ALGORITHM, INCLUDING ECONOMIC
+ * DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER RSA
+ * SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF
+ * THE POSSIBILITY OF SUCH INJURY OR DAMAGE.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+
+#define MD5_DIGEST_LENGTH 16
+
+typedef struct {
+ u32_t state[4]; /* state (ABCD) */
+ u32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ unsigned char buffer[64]; /* input buffer */
+} MD5_t;
+
+void MD5_init(MD5_t *);
+void MD5_update(MD5_t *, const unsigned char *, size_t);
+void MD5_final(MD5_t *, unsigned char digest[16]);