summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown2017-11-08 00:20:10 +0100
committerMichael Brown2017-11-12 19:52:03 +0100
commit0077b0933dea01113336f1b0fb5e0cfecbfc212c (patch)
treed1ec5172863ea651de8759154ac836fea7fc6a7c /src/include/ipxe
parent[crypto] Eliminate repetitions in MD5 round constant table (diff)
downloadipxe-0077b0933dea01113336f1b0fb5e0cfecbfc212c.tar.gz
ipxe-0077b0933dea01113336f1b0fb5e0cfecbfc212c.tar.xz
ipxe-0077b0933dea01113336f1b0fb5e0cfecbfc212c.zip
[crypto] Add MD4 message digest algorithm
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/asn1.h6
-rw-r--r--src/include/ipxe/md4.h73
2 files changed, 79 insertions, 0 deletions
diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h
index 847d845b..24caecdc 100644
--- a/src/include/ipxe/asn1.h
+++ b/src/include/ipxe/asn1.h
@@ -161,6 +161,12 @@ struct asn1_builder_header {
ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 1 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 14 )
+/** ASN.1 OID for id-md4 (1.2.840.113549.2.4) */
+#define ASN1_OID_MD4 \
+ ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
+ ASN1_OID_TRIPLE ( 113549 ), ASN1_OID_SINGLE ( 2 ), \
+ ASN1_OID_SINGLE ( 4 )
+
/** ASN.1 OID for id-md5 (1.2.840.113549.2.5) */
#define ASN1_OID_MD5 \
ASN1_OID_INITIAL ( 1, 2 ), ASN1_OID_DOUBLE ( 840 ), \
diff --git a/src/include/ipxe/md4.h b/src/include/ipxe/md4.h
new file mode 100644
index 00000000..8f172e62
--- /dev/null
+++ b/src/include/ipxe/md4.h
@@ -0,0 +1,73 @@
+#ifndef _IPXE_MD4_H
+#define _IPXE_MD4_H
+
+/** @file
+ *
+ * MD4 algorithm
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+#include <ipxe/crypto.h>
+
+/** An MD4 digest */
+struct md4_digest {
+ /** Hash output */
+ uint32_t h[4];
+};
+
+/** An MD4 data block */
+union md4_block {
+ /** Raw bytes */
+ uint8_t byte[64];
+ /** Raw dwords */
+ uint32_t dword[16];
+ /** Final block structure */
+ struct {
+ /** Padding */
+ uint8_t pad[56];
+ /** Length in bits */
+ uint64_t len;
+ } final;
+};
+
+/** MD4 digest and data block
+ *
+ * The order of fields within this structure is designed to minimise
+ * code size.
+ */
+struct md4_digest_data {
+ /** Digest of data already processed */
+ struct md4_digest digest;
+ /** Accumulated data */
+ union md4_block data;
+} __attribute__ (( packed ));
+
+/** MD4 digest and data block */
+union md4_digest_data_dwords {
+ /** Digest and data block */
+ struct md4_digest_data dd;
+ /** Raw dwords */
+ uint32_t dword[ sizeof ( struct md4_digest_data ) /
+ sizeof ( uint32_t ) ];
+};
+
+/** An MD4 context */
+struct md4_context {
+ /** Amount of accumulated data */
+ size_t len;
+ /** Digest and accumulated data */
+ union md4_digest_data_dwords ddd;
+} __attribute__ (( packed ));
+
+/** MD4 context size */
+#define MD4_CTX_SIZE sizeof ( struct md4_context )
+
+/** MD4 digest size */
+#define MD4_DIGEST_SIZE sizeof ( struct md4_digest )
+
+extern struct digest_algorithm md4_algorithm;
+
+#endif /* _IPXE_MD4_H */