3 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6 // Implementation of MD5 hash function. Originally written by Alexander Peslyak. Modified by WaterJuice retaining
7 // Public Domain license.
9 // This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
10 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
14 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
21 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25 // Md5Context - This must be initialised using Md5Initialised. Do not modify the contents of this structure directly.
38 #define MD5_HASH_SIZE ( 128 / 8 )
42 uint8_t bytes [MD5_HASH_SIZE];
45 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
47 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
49 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 // Initialises an MD5 Context. Use this to initialise/reset a context.
53 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 Md5Context* Context // [out]
60 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
63 // Adds data to the MD5 context. This will process the data and update the internal state of the context. Keep on
64 // calling this function until all the data has been added. Then call Md5Finalise to calculate the hash.
65 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
69 Md5Context* Context, // [in out]
70 void const* Buffer, // [in]
71 uint32_t BufferSize // [in]
74 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
77 // Performs the final calculation of the hash and returns the digest (16 byte buffer containing 128bit hash). After
78 // calling this, Md5Initialised must be used to reuse the context.
79 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83 Md5Context* Context, // [in out]
84 MD5_HASH* Digest // [in]
87 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
90 // Combines Md5Initialise, Md5Update, and Md5Finalise into one function. Calculates the MD5 hash of the buffer.
91 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
95 void const* Buffer, // [in]
96 uint32_t BufferSize, // [in]
97 MD5_HASH* Digest // [in]
99 #endif /* __MD5_H__ */