<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GNU libmicrohttpd: src/daemon/md5.c Source File</title> <link href="../../tabs.css" rel="stylesheet" type="text/css"/> <link href="../../doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="../../main.html"><span>Main Page</span></a></li> <li><a href="../../annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="../../files.html"><span>Files</span></a></li> <li><a href="../../dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="../../files.html"><span>File List</span></a></li> <li><a href="../../globals.html"><span>Globals</span></a></li> </ul> </div> <div class="navpath"> <ul> <li><a class="el" href="../../dir_6321990a7c24e6229efad5095602bf4d.html">src</a> </li> <li><a class="el" href="../../dir_db71c89daadcbe4e293122b147fd6eef.html">daemon</a> </li> </ul> </div> </div> <div class="header"> <div class="headertitle"> <h1>md5.c</h1> </div> </div> <div class="contents"> <a href="../../d7/d6c/md5_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * This code implements the MD5 message-digest algorithm.</span> <a name="l00003"></a>00003 <span class="comment"> * The algorithm is due to Ron Rivest. This code was</span> <a name="l00004"></a>00004 <span class="comment"> * written by Colin Plumb in 1993, no copyright is claimed.</span> <a name="l00005"></a>00005 <span class="comment"> * This code is in the public domain; do with it what you wish.</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Equivalent code is available from RSA Data Security, Inc.</span> <a name="l00008"></a>00008 <span class="comment"> * This code has been tested against that, and is equivalent,</span> <a name="l00009"></a>00009 <span class="comment"> * except that you don't need to include two pages of legalese</span> <a name="l00010"></a>00010 <span class="comment"> * with every copy.</span> <a name="l00011"></a>00011 <span class="comment"> *</span> <a name="l00012"></a>00012 <span class="comment"> * To compute the message digest of a chunk of bytes, declare an</span> <a name="l00013"></a>00013 <span class="comment"> * MD5Context structure, pass it to MD5Init, call MD5Update as</span> <a name="l00014"></a>00014 <span class="comment"> * needed on buffers full of bytes, and then call MD5Final, which</span> <a name="l00015"></a>00015 <span class="comment"> * will fill a supplied 16-byte array with the digest.</span> <a name="l00016"></a>00016 <span class="comment"> */</span> <a name="l00017"></a>00017 <a name="l00018"></a>00018 <span class="comment">/* Brutally hacked by John Walker back from ANSI C to K&R (no</span> <a name="l00019"></a>00019 <span class="comment"> prototypes) to maintain the tradition that Netfone will compile</span> <a name="l00020"></a>00020 <span class="comment"> with Sun's original "cc". */</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include <memory.h></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <stdint.h></span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="../../da/db0/md5_8h.html">md5.h</a>"</span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="preprocessor">#ifndef HIGHFIRST</span> <a name="l00027"></a><a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">00027</a> <span class="preprocessor"></span><span class="preprocessor">#define byteReverse(buf, len) </span><span class="comment">/* Nothing */</span> <a name="l00028"></a>00028 <span class="preprocessor">#else</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="comment">/*</span> <a name="l00030"></a>00030 <span class="comment"> * Note: this code is harmless on little-endian machines.</span> <a name="l00031"></a>00031 <span class="comment"> */</span> <a name="l00032"></a>00032 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00033"></a>00033 <a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">byteReverse</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf, <a name="l00034"></a>00034 <span class="keywordtype">unsigned</span> longs) <a name="l00035"></a>00035 { <a name="l00036"></a>00036 uint32_t t; <a name="l00037"></a>00037 <span class="keywordflow">do</span> { <a name="l00038"></a>00038 t = (uint32_t) ((<span class="keywordtype">unsigned</span>) buf[3] << 8 | buf[2]) << 16 | <a name="l00039"></a>00039 ((<span class="keywordtype">unsigned</span>) buf[1] << 8 | buf[0]); <a name="l00040"></a>00040 *(uint32_t *) buf = t; <a name="l00041"></a>00041 buf += 4; <a name="l00042"></a>00042 } <span class="keywordflow">while</span> (--longs); <a name="l00043"></a>00043 } <a name="l00044"></a>00044 <span class="preprocessor">#endif</span> <a name="l00045"></a>00045 <span class="preprocessor"></span> <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="comment">/* The four core functions - F1 is optimized somewhat */</span> <a name="l00048"></a>00048 <a name="l00049"></a>00049 <span class="comment">/* #define F1(x, y, z) (x & y | ~x & z) */</span> <a name="l00050"></a><a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">00050</a> <span class="preprocessor">#define F1(x, y, z) (z ^ (x & (y ^ z)))</span> <a name="l00051"></a><a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">00051</a> <span class="preprocessor"></span><span class="preprocessor">#define F2(x, y, z) F1(z, x, y)</span> <a name="l00052"></a><a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">00052</a> <span class="preprocessor"></span><span class="preprocessor">#define F3(x, y, z) (x ^ y ^ z)</span> <a name="l00053"></a><a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">00053</a> <span class="preprocessor"></span><span class="preprocessor">#define F4(x, y, z) (y ^ (x | ~z))</span> <a name="l00054"></a>00054 <span class="preprocessor"></span> <a name="l00055"></a>00055 <span class="comment">/* This is the central step in the MD5 algorithm. */</span> <a name="l00056"></a><a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">00056</a> <span class="preprocessor">#define MD5STEP(f, w, x, y, z, data, s) \</span> <a name="l00057"></a>00057 <span class="preprocessor"> ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )</span> <a name="l00058"></a>00058 <span class="preprocessor"></span> <a name="l00059"></a>00059 <span class="comment">/*</span> <a name="l00060"></a>00060 <span class="comment"> * The core of the MD5 algorithm, this alters an existing MD5 hash to</span> <a name="l00061"></a>00061 <span class="comment"> * reflect the addition of 16 longwords of new data. MD5Update blocks</span> <a name="l00062"></a>00062 <span class="comment"> * the data and converts bytes into longwords for this routine.</span> <a name="l00063"></a>00063 <span class="comment"> */</span> <a name="l00064"></a>00064 <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="l00065"></a><a class="code" href="../../d7/d6c/md5_8c.html#a5745614eaf51e5ca15158b0417455311">00065</a> <a class="code" href="../../d7/d6c/md5_8c.html#a5745614eaf51e5ca15158b0417455311">MD5Transform</a>(uint32_t buf[4], <a name="l00066"></a>00066 uint32_t in[16]) <a name="l00067"></a>00067 { <a name="l00068"></a>00068 uint32_t a, b, c, d; <a name="l00069"></a>00069 <a name="l00070"></a>00070 a = buf[0]; <a name="l00071"></a>00071 b = buf[1]; <a name="l00072"></a>00072 c = buf[2]; <a name="l00073"></a>00073 d = buf[3]; <a name="l00074"></a>00074 <a name="l00075"></a>00075 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, a, b, c, d, in[0] + 0xd76aa478, 7); <a name="l00076"></a>00076 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, d, a, b, c, in[1] + 0xe8c7b756, 12); <a name="l00077"></a>00077 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, c, d, a, b, in[2] + 0x242070db, 17); <a name="l00078"></a>00078 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, b, c, d, a, in[3] + 0xc1bdceee, 22); <a name="l00079"></a>00079 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, a, b, c, d, in[4] + 0xf57c0faf, 7); <a name="l00080"></a>00080 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, d, a, b, c, in[5] + 0x4787c62a, 12); <a name="l00081"></a>00081 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, c, d, a, b, in[6] + 0xa8304613, 17); <a name="l00082"></a>00082 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, b, c, d, a, in[7] + 0xfd469501, 22); <a name="l00083"></a>00083 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, a, b, c, d, in[8] + 0x698098d8, 7); <a name="l00084"></a>00084 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, d, a, b, c, in[9] + 0x8b44f7af, 12); <a name="l00085"></a>00085 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, c, d, a, b, in[10] + 0xffff5bb1, 17); <a name="l00086"></a>00086 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, b, c, d, a, in[11] + 0x895cd7be, 22); <a name="l00087"></a>00087 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, a, b, c, d, in[12] + 0x6b901122, 7); <a name="l00088"></a>00088 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, d, a, b, c, in[13] + 0xfd987193, 12); <a name="l00089"></a>00089 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, c, d, a, b, in[14] + 0xa679438e, 17); <a name="l00090"></a>00090 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a3c2b6b2959faadfcf644757cb570b734">F1</a>, b, c, d, a, in[15] + 0x49b40821, 22); <a name="l00091"></a>00091 <a name="l00092"></a>00092 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, a, b, c, d, in[1] + 0xf61e2562, 5); <a name="l00093"></a>00093 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, d, a, b, c, in[6] + 0xc040b340, 9); <a name="l00094"></a>00094 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, c, d, a, b, in[11] + 0x265e5a51, 14); <a name="l00095"></a>00095 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, b, c, d, a, in[0] + 0xe9b6c7aa, 20); <a name="l00096"></a>00096 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, a, b, c, d, in[5] + 0xd62f105d, 5); <a name="l00097"></a>00097 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, d, a, b, c, in[10] + 0x02441453, 9); <a name="l00098"></a>00098 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, c, d, a, b, in[15] + 0xd8a1e681, 14); <a name="l00099"></a>00099 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, b, c, d, a, in[4] + 0xe7d3fbc8, 20); <a name="l00100"></a>00100 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, a, b, c, d, in[9] + 0x21e1cde6, 5); <a name="l00101"></a>00101 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, d, a, b, c, in[14] + 0xc33707d6, 9); <a name="l00102"></a>00102 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, c, d, a, b, in[3] + 0xf4d50d87, 14); <a name="l00103"></a>00103 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, b, c, d, a, in[8] + 0x455a14ed, 20); <a name="l00104"></a>00104 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, a, b, c, d, in[13] + 0xa9e3e905, 5); <a name="l00105"></a>00105 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, d, a, b, c, in[2] + 0xfcefa3f8, 9); <a name="l00106"></a>00106 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, c, d, a, b, in[7] + 0x676f02d9, 14); <a name="l00107"></a>00107 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#ae131b09a86bdafd00f48095647e80a00">F2</a>, b, c, d, a, in[12] + 0x8d2a4c8a, 20); <a name="l00108"></a>00108 <a name="l00109"></a>00109 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, a, b, c, d, in[5] + 0xfffa3942, 4); <a name="l00110"></a>00110 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, d, a, b, c, in[8] + 0x8771f681, 11); <a name="l00111"></a>00111 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, c, d, a, b, in[11] + 0x6d9d6122, 16); <a name="l00112"></a>00112 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, b, c, d, a, in[14] + 0xfde5380c, 23); <a name="l00113"></a>00113 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, a, b, c, d, in[1] + 0xa4beea44, 4); <a name="l00114"></a>00114 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, d, a, b, c, in[4] + 0x4bdecfa9, 11); <a name="l00115"></a>00115 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, c, d, a, b, in[7] + 0xf6bb4b60, 16); <a name="l00116"></a>00116 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, b, c, d, a, in[10] + 0xbebfbc70, 23); <a name="l00117"></a>00117 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, a, b, c, d, in[13] + 0x289b7ec6, 4); <a name="l00118"></a>00118 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, d, a, b, c, in[0] + 0xeaa127fa, 11); <a name="l00119"></a>00119 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, c, d, a, b, in[3] + 0xd4ef3085, 16); <a name="l00120"></a>00120 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, b, c, d, a, in[6] + 0x04881d05, 23); <a name="l00121"></a>00121 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, a, b, c, d, in[9] + 0xd9d4d039, 4); <a name="l00122"></a>00122 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, d, a, b, c, in[12] + 0xe6db99e5, 11); <a name="l00123"></a>00123 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, c, d, a, b, in[15] + 0x1fa27cf8, 16); <a name="l00124"></a>00124 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a8f6625b749e5fe36981ee2d149229b98">F3</a>, b, c, d, a, in[2] + 0xc4ac5665, 23); <a name="l00125"></a>00125 <a name="l00126"></a>00126 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, a, b, c, d, in[0] + 0xf4292244, 6); <a name="l00127"></a>00127 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, d, a, b, c, in[7] + 0x432aff97, 10); <a name="l00128"></a>00128 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, c, d, a, b, in[14] + 0xab9423a7, 15); <a name="l00129"></a>00129 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, b, c, d, a, in[5] + 0xfc93a039, 21); <a name="l00130"></a>00130 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, a, b, c, d, in[12] + 0x655b59c3, 6); <a name="l00131"></a>00131 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, d, a, b, c, in[3] + 0x8f0ccc92, 10); <a name="l00132"></a>00132 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, c, d, a, b, in[10] + 0xffeff47d, 15); <a name="l00133"></a>00133 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, b, c, d, a, in[1] + 0x85845dd1, 21); <a name="l00134"></a>00134 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, a, b, c, d, in[8] + 0x6fa87e4f, 6); <a name="l00135"></a>00135 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, d, a, b, c, in[15] + 0xfe2ce6e0, 10); <a name="l00136"></a>00136 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, c, d, a, b, in[6] + 0xa3014314, 15); <a name="l00137"></a>00137 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, b, c, d, a, in[13] + 0x4e0811a1, 21); <a name="l00138"></a>00138 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, a, b, c, d, in[4] + 0xf7537e82, 6); <a name="l00139"></a>00139 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, d, a, b, c, in[11] + 0xbd3af235, 10); <a name="l00140"></a>00140 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, c, d, a, b, in[2] + 0x2ad7d2bb, 15); <a name="l00141"></a>00141 <a class="code" href="../../d7/d6c/md5_8c.html#a05bc633e1c2aa503fdd7802b13ea2bfe">MD5STEP</a>(<a class="code" href="../../d7/d6c/md5_8c.html#a61cdb7eca418cc9b37e33601c1b08868">F4</a>, b, c, d, a, in[9] + 0xeb86d391, 21); <a name="l00142"></a>00142 <a name="l00143"></a>00143 buf[0] += a; <a name="l00144"></a>00144 buf[1] += b; <a name="l00145"></a>00145 buf[2] += c; <a name="l00146"></a>00146 buf[3] += d; <a name="l00147"></a>00147 } <a name="l00148"></a>00148 <a name="l00149"></a>00149 <a name="l00150"></a>00150 <span class="comment">/*</span> <a name="l00151"></a>00151 <span class="comment"> * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious</span> <a name="l00152"></a>00152 <span class="comment"> * initialization constants.</span> <a name="l00153"></a>00153 <span class="comment"> */</span> <a name="l00154"></a><a class="code" href="../../da/db0/md5_8h.html#a2bbee602c0d0da64387e4a15bbf536ac">00154</a> <span class="keywordtype">void</span> <a class="code" href="../../d7/d6c/md5_8c.html#a2bbee602c0d0da64387e4a15bbf536ac">MD5Init</a>(<span class="keyword">struct</span> <a class="code" href="../../d1/d32/structMD5Context.html">MD5Context</a> *ctx) <a name="l00155"></a>00155 { <a name="l00156"></a>00156 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>[0] = 0x67452301; <a name="l00157"></a>00157 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>[1] = 0xefcdab89; <a name="l00158"></a>00158 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>[2] = 0x98badcfe; <a name="l00159"></a>00159 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>[3] = 0x10325476; <a name="l00160"></a>00160 <a name="l00161"></a>00161 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[0] = 0; <a name="l00162"></a>00162 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[1] = 0; <a name="l00163"></a>00163 } <a name="l00164"></a>00164 <a name="l00165"></a>00165 <span class="comment">/*</span> <a name="l00166"></a>00166 <span class="comment"> * Update context to reflect the concatenation of another buffer full</span> <a name="l00167"></a>00167 <span class="comment"> * of bytes.</span> <a name="l00168"></a>00168 <span class="comment"> */</span> <a name="l00169"></a>00169 <span class="keywordtype">void</span> <a name="l00170"></a><a class="code" href="../../da/db0/md5_8h.html#a2276d7d5990d6b545dc39ab6c12b1b0f">00170</a> <a class="code" href="../../d7/d6c/md5_8c.html#adca0f429128f135876a7864813cc2cf6">MD5Update</a>(<span class="keyword">struct</span> <a class="code" href="../../d1/d32/structMD5Context.html">MD5Context</a> *ctx, <a name="l00171"></a>00171 <span class="keyword">const</span> <span class="keywordtype">void</span> *data, <a name="l00172"></a>00172 <span class="keywordtype">unsigned</span> len) <a name="l00173"></a>00173 { <a name="l00174"></a>00174 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *buf = data; <a name="l00175"></a>00175 uint32_t t; <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="comment">/* Update bitcount */</span> <a name="l00178"></a>00178 <a name="l00179"></a>00179 t = ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[0]; <a name="l00180"></a>00180 <span class="keywordflow">if</span> ((ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[0] = t + ((uint32_t) len << 3)) < t) <a name="l00181"></a>00181 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[1]++; <span class="comment">/* Carry from low to high */</span> <a name="l00182"></a>00182 ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[1] += len >> 29; <a name="l00183"></a>00183 <a name="l00184"></a>00184 t = (t >> 3) & 0x3f; <span class="comment">/* Bytes already in shsInfo->data */</span> <a name="l00185"></a>00185 <a name="l00186"></a>00186 <span class="comment">/* Handle any leading odd-sized chunks */</span> <a name="l00187"></a>00187 <a name="l00188"></a>00188 <span class="keywordflow">if</span> (t) { <a name="l00189"></a>00189 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *p = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a> + t; <a name="l00190"></a>00190 <a name="l00191"></a>00191 t = 64 - t; <a name="l00192"></a>00192 if (len < t) { <a name="l00193"></a>00193 memcpy(p, buf, len); <a name="l00194"></a>00194 <span class="keywordflow">return</span>; <a name="l00195"></a>00195 } <a name="l00196"></a>00196 memcpy(p, buf, t); <a name="l00197"></a>00197 <a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">byteReverse</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, 16); <a name="l00198"></a>00198 <a class="code" href="../../d7/d6c/md5_8c.html#a5745614eaf51e5ca15158b0417455311">MD5Transform</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>, (uint32_t *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>); <a name="l00199"></a>00199 buf += t; <a name="l00200"></a>00200 len -= t; <a name="l00201"></a>00201 } <a name="l00202"></a>00202 <span class="comment">/* Process data in 64-byte chunks */</span> <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="keywordflow">while</span> (len >= 64) { <a name="l00205"></a>00205 memcpy(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, buf, 64); <a name="l00206"></a>00206 <a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">byteReverse</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, 16); <a name="l00207"></a>00207 <a class="code" href="../../d7/d6c/md5_8c.html#a5745614eaf51e5ca15158b0417455311">MD5Transform</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>, (uint32_t *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>); <a name="l00208"></a>00208 buf += 64; <a name="l00209"></a>00209 len -= 64; <a name="l00210"></a>00210 } <a name="l00211"></a>00211 <a name="l00212"></a>00212 <span class="comment">/* Handle any remaining bytes of data. */</span> <a name="l00213"></a>00213 <a name="l00214"></a>00214 memcpy(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, buf, len); <a name="l00215"></a>00215 } <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="comment">/*</span> <a name="l00218"></a>00218 <span class="comment"> * Final wrapup - pad to 64-byte boundary with the bit pattern </span> <a name="l00219"></a>00219 <span class="comment"> * 1 0* (64-bit count of bits processed, MSB-first)</span> <a name="l00220"></a>00220 <span class="comment"> */</span> <a name="l00221"></a><a class="code" href="../../d7/d6c/md5_8c.html#a4eeac999f71dc03917b0fab90a4e703a">00221</a> <span class="keywordtype">void</span> <a class="code" href="../../d7/d6c/md5_8c.html#a4eeac999f71dc03917b0fab90a4e703a">MD5Final</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> digest[16], <a name="l00222"></a>00222 <span class="keyword">struct</span> <a class="code" href="../../d1/d32/structMD5Context.html">MD5Context</a> *ctx) <a name="l00223"></a>00223 { <a name="l00224"></a>00224 <span class="keywordtype">unsigned</span> count; <a name="l00225"></a>00225 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *p; <a name="l00226"></a>00226 <a name="l00227"></a>00227 <span class="comment">/* Compute number of bytes mod 64 */</span> <a name="l00228"></a>00228 count = (ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[0] >> 3) & 0x3F; <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="comment">/* Set the first char of padding to 0x80. This is safe since there is</span> <a name="l00231"></a>00231 <span class="comment"> always at least one byte free */</span> <a name="l00232"></a>00232 p = ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a> + count; <a name="l00233"></a>00233 *p++ = 0x80; <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="comment">/* Bytes of padding needed to make 64 bytes */</span> <a name="l00236"></a>00236 count = 64 - 1 - count; <a name="l00237"></a>00237 <a name="l00238"></a>00238 <span class="comment">/* Pad out to 56 mod 64 */</span> <a name="l00239"></a>00239 <span class="keywordflow">if</span> (count < 8) { <a name="l00240"></a>00240 <span class="comment">/* Two lots of padding: Pad the first block to 64 bytes */</span> <a name="l00241"></a>00241 memset(p, 0, count); <a name="l00242"></a>00242 <a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">byteReverse</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, 16); <a name="l00243"></a>00243 <a class="code" href="../../d7/d6c/md5_8c.html#a5745614eaf51e5ca15158b0417455311">MD5Transform</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>, (uint32_t *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>); <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="comment">/* Now fill the next block with 56 bytes */</span> <a name="l00246"></a>00246 memset(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, 0, 56); <a name="l00247"></a>00247 } <span class="keywordflow">else</span> { <a name="l00248"></a>00248 <span class="comment">/* Pad block to 56 bytes */</span> <a name="l00249"></a>00249 memset(p, 0, count - 8); <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">byteReverse</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>, 14); <a name="l00252"></a>00252 <a name="l00253"></a>00253 <span class="comment">/* Append length in bits and transform */</span> <a name="l00254"></a>00254 ((uint32_t *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>)[14] = ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[0]; <a name="l00255"></a>00255 ((uint32_t *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>)[15] = ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a48f837fb64afd013f832e3cdab68e5de">bits</a>[1]; <a name="l00256"></a>00256 <a name="l00257"></a>00257 <a class="code" href="../../d7/d6c/md5_8c.html#a5745614eaf51e5ca15158b0417455311">MD5Transform</a>(ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>, (uint32_t *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#ae8be45f236e5cb12b0ae79da77e5f929">in</a>); <a name="l00258"></a>00258 <a class="code" href="../../d7/d6c/md5_8c.html#a2b4a8791145616dd3add6ae6db3494e3">byteReverse</a>((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *) ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>, 4); <a name="l00259"></a>00259 memcpy(digest, ctx-><a class="code" href="../../d1/d32/structMD5Context.html#a6129b10b90387e1cb1d4cd92e4605c33">buf</a>, 16); <a name="l00260"></a>00260 memset(ctx, 0, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> <a class="code" href="../../d1/d32/structMD5Context.html">MD5Context</a>)); <span class="comment">/* In case it's sensitive */</span> <a name="l00261"></a>00261 } <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="comment">/* end of md5.c */</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Jan 26 2011 for GNU libmicrohttpd by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address> </body> </html>