iPXE
md5.h
Go to the documentation of this file.
00001 #ifndef _IPXE_MD5_H
00002 #define _IPXE_MD5_H
00003 
00004 /** @file
00005  *
00006  * MD5 algorithm
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/crypto.h>
00014 
00015 /** An MD5 digest */
00016 struct md5_digest {
00017         /** Hash output */
00018         uint32_t h[4];
00019 };
00020 
00021 /** An MD5 data block */
00022 union md5_block {
00023         /** Raw bytes */
00024         uint8_t byte[64];
00025         /** Raw dwords */
00026         uint32_t dword[16];
00027         /** Final block structure */
00028         struct {
00029                 /** Padding */
00030                 uint8_t pad[56];
00031                 /** Length in bits */
00032                 uint64_t len;
00033         } final;
00034 };
00035 
00036 /** MD5 digest and data block
00037  *
00038  * The order of fields within this structure is designed to minimise
00039  * code size.
00040  */
00041 struct md5_digest_data {
00042         /** Digest of data already processed */
00043         struct md5_digest digest;
00044         /** Accumulated data */
00045         union md5_block data;
00046 } __attribute__ (( packed ));
00047 
00048 /** MD5 digest and data block */
00049 union md5_digest_data_dwords {
00050         /** Digest and data block */
00051         struct md5_digest_data dd;
00052         /** Raw dwords */
00053         uint32_t dword[ sizeof ( struct md5_digest_data ) /
00054                         sizeof ( uint32_t ) ];
00055 };
00056 
00057 /** An MD5 context */
00058 struct md5_context {
00059         /** Amount of accumulated data */
00060         size_t len;
00061         /** Digest and accumulated data */
00062         union md5_digest_data_dwords ddd;
00063 } __attribute__ (( packed ));
00064 
00065 /** MD5 context size */
00066 #define MD5_CTX_SIZE sizeof ( struct md5_context )
00067 
00068 /** MD5 digest size */
00069 #define MD5_DIGEST_SIZE sizeof ( struct md5_digest )
00070 
00071 extern struct digest_algorithm md5_algorithm;
00072 
00073 #endif /* _IPXE_MD5_H */