Web server based weather station using Sparkfun Weather Meters.
Dependencies: FatFileSystem mbed WeatherMeters SDFileSystem
NetStack/lwip/netif/ppp/md5.c@1:c7958aa34fa1, 2012-02-25 (annotated)
- Committer:
- AdamGreen
- Date:
- Sat Feb 25 03:28:05 2012 +0000
- Revision:
- 1:c7958aa34fa1
- Parent:
- 0:616601bde9fb
Use published libraries where possible.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:616601bde9fb | 1 | /* |
AdamGreen | 0:616601bde9fb | 2 | *********************************************************************** |
AdamGreen | 0:616601bde9fb | 3 | ** md5.c -- the source code for MD5 routines ** |
AdamGreen | 0:616601bde9fb | 4 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** |
AdamGreen | 0:616601bde9fb | 5 | ** Created: 2/17/90 RLR ** |
AdamGreen | 0:616601bde9fb | 6 | ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. ** |
AdamGreen | 0:616601bde9fb | 7 | *********************************************************************** |
AdamGreen | 0:616601bde9fb | 8 | */ |
AdamGreen | 0:616601bde9fb | 9 | |
AdamGreen | 0:616601bde9fb | 10 | /* |
AdamGreen | 0:616601bde9fb | 11 | *********************************************************************** |
AdamGreen | 0:616601bde9fb | 12 | ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** |
AdamGreen | 0:616601bde9fb | 13 | ** ** |
AdamGreen | 0:616601bde9fb | 14 | ** License to copy and use this software is granted provided that ** |
AdamGreen | 0:616601bde9fb | 15 | ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** |
AdamGreen | 0:616601bde9fb | 16 | ** Digest Algorithm" in all material mentioning or referencing this ** |
AdamGreen | 0:616601bde9fb | 17 | ** software or this function. ** |
AdamGreen | 0:616601bde9fb | 18 | ** ** |
AdamGreen | 0:616601bde9fb | 19 | ** License is also granted to make and use derivative works ** |
AdamGreen | 0:616601bde9fb | 20 | ** provided that such works are identified as "derived from the RSA ** |
AdamGreen | 0:616601bde9fb | 21 | ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** |
AdamGreen | 0:616601bde9fb | 22 | ** material mentioning or referencing the derived work. ** |
AdamGreen | 0:616601bde9fb | 23 | ** ** |
AdamGreen | 0:616601bde9fb | 24 | ** RSA Data Security, Inc. makes no representations concerning ** |
AdamGreen | 0:616601bde9fb | 25 | ** either the merchantability of this software or the suitability ** |
AdamGreen | 0:616601bde9fb | 26 | ** of this software for any particular purpose. It is provided "as ** |
AdamGreen | 0:616601bde9fb | 27 | ** is" without express or implied warranty of any kind. ** |
AdamGreen | 0:616601bde9fb | 28 | ** ** |
AdamGreen | 0:616601bde9fb | 29 | ** These notices must be retained in any copies of any part of this ** |
AdamGreen | 0:616601bde9fb | 30 | ** documentation and/or software. ** |
AdamGreen | 0:616601bde9fb | 31 | *********************************************************************** |
AdamGreen | 0:616601bde9fb | 32 | */ |
AdamGreen | 0:616601bde9fb | 33 | |
AdamGreen | 0:616601bde9fb | 34 | #include "lwip/opt.h" |
AdamGreen | 0:616601bde9fb | 35 | |
AdamGreen | 0:616601bde9fb | 36 | #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ |
AdamGreen | 0:616601bde9fb | 37 | |
AdamGreen | 0:616601bde9fb | 38 | #if CHAP_SUPPORT || MD5_SUPPORT |
AdamGreen | 0:616601bde9fb | 39 | |
AdamGreen | 0:616601bde9fb | 40 | #include "ppp.h" |
AdamGreen | 0:616601bde9fb | 41 | #include "pppdebug.h" |
AdamGreen | 0:616601bde9fb | 42 | |
AdamGreen | 0:616601bde9fb | 43 | #include "md5.h" |
AdamGreen | 0:616601bde9fb | 44 | |
AdamGreen | 0:616601bde9fb | 45 | #include <string.h> |
AdamGreen | 0:616601bde9fb | 46 | |
AdamGreen | 0:616601bde9fb | 47 | /* |
AdamGreen | 0:616601bde9fb | 48 | *********************************************************************** |
AdamGreen | 0:616601bde9fb | 49 | ** Message-digest routines: ** |
AdamGreen | 0:616601bde9fb | 50 | ** To form the message digest for a message M ** |
AdamGreen | 0:616601bde9fb | 51 | ** (1) Initialize a context buffer mdContext using MD5Init ** |
AdamGreen | 0:616601bde9fb | 52 | ** (2) Call MD5Update on mdContext and M ** |
AdamGreen | 0:616601bde9fb | 53 | ** (3) Call MD5Final on mdContext ** |
AdamGreen | 0:616601bde9fb | 54 | ** The message digest is now in mdContext->digest[0...15] ** |
AdamGreen | 0:616601bde9fb | 55 | *********************************************************************** |
AdamGreen | 0:616601bde9fb | 56 | */ |
AdamGreen | 0:616601bde9fb | 57 | |
AdamGreen | 0:616601bde9fb | 58 | /* forward declaration */ |
AdamGreen | 0:616601bde9fb | 59 | static void Transform (u32_t *buf, u32_t *in); |
AdamGreen | 0:616601bde9fb | 60 | |
AdamGreen | 0:616601bde9fb | 61 | static unsigned char PADDING[64] = { |
AdamGreen | 0:616601bde9fb | 62 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
AdamGreen | 0:616601bde9fb | 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
AdamGreen | 0:616601bde9fb | 70 | }; |
AdamGreen | 0:616601bde9fb | 71 | |
AdamGreen | 0:616601bde9fb | 72 | /* F, G, H and I are basic MD5 functions */ |
AdamGreen | 0:616601bde9fb | 73 | #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) |
AdamGreen | 0:616601bde9fb | 74 | #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) |
AdamGreen | 0:616601bde9fb | 75 | #define H(x, y, z) ((x) ^ (y) ^ (z)) |
AdamGreen | 0:616601bde9fb | 76 | #define I(x, y, z) ((y) ^ ((x) | (~z))) |
AdamGreen | 0:616601bde9fb | 77 | |
AdamGreen | 0:616601bde9fb | 78 | /* ROTATE_LEFT rotates x left n bits */ |
AdamGreen | 0:616601bde9fb | 79 | #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) |
AdamGreen | 0:616601bde9fb | 80 | |
AdamGreen | 0:616601bde9fb | 81 | /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ |
AdamGreen | 0:616601bde9fb | 82 | /* Rotation is separate from addition to prevent recomputation */ |
AdamGreen | 0:616601bde9fb | 83 | #define FF(a, b, c, d, x, s, ac) \ |
AdamGreen | 0:616601bde9fb | 84 | {(a) += F ((b), (c), (d)) + (x) + (u32_t)(ac); \ |
AdamGreen | 0:616601bde9fb | 85 | (a) = ROTATE_LEFT ((a), (s)); \ |
AdamGreen | 0:616601bde9fb | 86 | (a) += (b); \ |
AdamGreen | 0:616601bde9fb | 87 | } |
AdamGreen | 0:616601bde9fb | 88 | #define GG(a, b, c, d, x, s, ac) \ |
AdamGreen | 0:616601bde9fb | 89 | {(a) += G ((b), (c), (d)) + (x) + (u32_t)(ac); \ |
AdamGreen | 0:616601bde9fb | 90 | (a) = ROTATE_LEFT ((a), (s)); \ |
AdamGreen | 0:616601bde9fb | 91 | (a) += (b); \ |
AdamGreen | 0:616601bde9fb | 92 | } |
AdamGreen | 0:616601bde9fb | 93 | #define HH(a, b, c, d, x, s, ac) \ |
AdamGreen | 0:616601bde9fb | 94 | {(a) += H ((b), (c), (d)) + (x) + (u32_t)(ac); \ |
AdamGreen | 0:616601bde9fb | 95 | (a) = ROTATE_LEFT ((a), (s)); \ |
AdamGreen | 0:616601bde9fb | 96 | (a) += (b); \ |
AdamGreen | 0:616601bde9fb | 97 | } |
AdamGreen | 0:616601bde9fb | 98 | #define II(a, b, c, d, x, s, ac) \ |
AdamGreen | 0:616601bde9fb | 99 | {(a) += I ((b), (c), (d)) + (x) + (u32_t)(ac); \ |
AdamGreen | 0:616601bde9fb | 100 | (a) = ROTATE_LEFT ((a), (s)); \ |
AdamGreen | 0:616601bde9fb | 101 | (a) += (b); \ |
AdamGreen | 0:616601bde9fb | 102 | } |
AdamGreen | 0:616601bde9fb | 103 | |
AdamGreen | 0:616601bde9fb | 104 | #ifdef __STDC__ |
AdamGreen | 0:616601bde9fb | 105 | #define UL(x) x##UL |
AdamGreen | 0:616601bde9fb | 106 | #else |
AdamGreen | 0:616601bde9fb | 107 | #ifdef WIN32 |
AdamGreen | 0:616601bde9fb | 108 | #define UL(x) x##UL |
AdamGreen | 0:616601bde9fb | 109 | #else |
AdamGreen | 0:616601bde9fb | 110 | #define UL(x) x |
AdamGreen | 0:616601bde9fb | 111 | #endif |
AdamGreen | 0:616601bde9fb | 112 | #endif |
AdamGreen | 0:616601bde9fb | 113 | |
AdamGreen | 0:616601bde9fb | 114 | /* The routine MD5Init initializes the message-digest context |
AdamGreen | 0:616601bde9fb | 115 | mdContext. All fields are set to zero. |
AdamGreen | 0:616601bde9fb | 116 | */ |
AdamGreen | 0:616601bde9fb | 117 | void |
AdamGreen | 0:616601bde9fb | 118 | MD5Init (MD5_CTX *mdContext) |
AdamGreen | 0:616601bde9fb | 119 | { |
AdamGreen | 0:616601bde9fb | 120 | mdContext->i[0] = mdContext->i[1] = (u32_t)0; |
AdamGreen | 0:616601bde9fb | 121 | |
AdamGreen | 0:616601bde9fb | 122 | /* Load magic initialization constants. */ |
AdamGreen | 0:616601bde9fb | 123 | mdContext->buf[0] = (u32_t)0x67452301UL; |
AdamGreen | 0:616601bde9fb | 124 | mdContext->buf[1] = (u32_t)0xefcdab89UL; |
AdamGreen | 0:616601bde9fb | 125 | mdContext->buf[2] = (u32_t)0x98badcfeUL; |
AdamGreen | 0:616601bde9fb | 126 | mdContext->buf[3] = (u32_t)0x10325476UL; |
AdamGreen | 0:616601bde9fb | 127 | } |
AdamGreen | 0:616601bde9fb | 128 | |
AdamGreen | 0:616601bde9fb | 129 | /* The routine MD5Update updates the message-digest context to |
AdamGreen | 0:616601bde9fb | 130 | account for the presence of each of the characters inBuf[0..inLen-1] |
AdamGreen | 0:616601bde9fb | 131 | in the message whose digest is being computed. |
AdamGreen | 0:616601bde9fb | 132 | */ |
AdamGreen | 0:616601bde9fb | 133 | void |
AdamGreen | 0:616601bde9fb | 134 | MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) |
AdamGreen | 0:616601bde9fb | 135 | { |
AdamGreen | 0:616601bde9fb | 136 | u32_t in[16]; |
AdamGreen | 0:616601bde9fb | 137 | int mdi; |
AdamGreen | 0:616601bde9fb | 138 | unsigned int i, ii; |
AdamGreen | 0:616601bde9fb | 139 | |
AdamGreen | 0:616601bde9fb | 140 | #if 0 |
AdamGreen | 0:616601bde9fb | 141 | PPPDEBUG(LOG_INFO, ("MD5Update: %u:%.*H\n", inLen, LWIP_MIN(inLen, 20) * 2, inBuf)); |
AdamGreen | 0:616601bde9fb | 142 | PPPDEBUG(LOG_INFO, ("MD5Update: %u:%s\n", inLen, inBuf)); |
AdamGreen | 0:616601bde9fb | 143 | #endif |
AdamGreen | 0:616601bde9fb | 144 | |
AdamGreen | 0:616601bde9fb | 145 | /* compute number of bytes mod 64 */ |
AdamGreen | 0:616601bde9fb | 146 | mdi = (int)((mdContext->i[0] >> 3) & 0x3F); |
AdamGreen | 0:616601bde9fb | 147 | |
AdamGreen | 0:616601bde9fb | 148 | /* update number of bits */ |
AdamGreen | 0:616601bde9fb | 149 | if ((mdContext->i[0] + ((u32_t)inLen << 3)) < mdContext->i[0]) { |
AdamGreen | 0:616601bde9fb | 150 | mdContext->i[1]++; |
AdamGreen | 0:616601bde9fb | 151 | } |
AdamGreen | 0:616601bde9fb | 152 | mdContext->i[0] += ((u32_t)inLen << 3); |
AdamGreen | 0:616601bde9fb | 153 | mdContext->i[1] += ((u32_t)inLen >> 29); |
AdamGreen | 0:616601bde9fb | 154 | |
AdamGreen | 0:616601bde9fb | 155 | while (inLen--) { |
AdamGreen | 0:616601bde9fb | 156 | /* add new character to buffer, increment mdi */ |
AdamGreen | 0:616601bde9fb | 157 | mdContext->in[mdi++] = *inBuf++; |
AdamGreen | 0:616601bde9fb | 158 | |
AdamGreen | 0:616601bde9fb | 159 | /* transform if necessary */ |
AdamGreen | 0:616601bde9fb | 160 | if (mdi == 0x40) { |
AdamGreen | 0:616601bde9fb | 161 | for (i = 0, ii = 0; i < 16; i++, ii += 4) { |
AdamGreen | 0:616601bde9fb | 162 | in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | |
AdamGreen | 0:616601bde9fb | 163 | (((u32_t)mdContext->in[ii+2]) << 16) | |
AdamGreen | 0:616601bde9fb | 164 | (((u32_t)mdContext->in[ii+1]) << 8) | |
AdamGreen | 0:616601bde9fb | 165 | ((u32_t)mdContext->in[ii]); |
AdamGreen | 0:616601bde9fb | 166 | } |
AdamGreen | 0:616601bde9fb | 167 | Transform (mdContext->buf, in); |
AdamGreen | 0:616601bde9fb | 168 | mdi = 0; |
AdamGreen | 0:616601bde9fb | 169 | } |
AdamGreen | 0:616601bde9fb | 170 | } |
AdamGreen | 0:616601bde9fb | 171 | } |
AdamGreen | 0:616601bde9fb | 172 | |
AdamGreen | 0:616601bde9fb | 173 | /* The routine MD5Final terminates the message-digest computation and |
AdamGreen | 0:616601bde9fb | 174 | ends with the desired message digest in mdContext->digest[0...15]. |
AdamGreen | 0:616601bde9fb | 175 | */ |
AdamGreen | 0:616601bde9fb | 176 | void |
AdamGreen | 0:616601bde9fb | 177 | MD5Final (unsigned char hash[], MD5_CTX *mdContext) |
AdamGreen | 0:616601bde9fb | 178 | { |
AdamGreen | 0:616601bde9fb | 179 | u32_t in[16]; |
AdamGreen | 0:616601bde9fb | 180 | int mdi; |
AdamGreen | 0:616601bde9fb | 181 | unsigned int i, ii; |
AdamGreen | 0:616601bde9fb | 182 | unsigned int padLen; |
AdamGreen | 0:616601bde9fb | 183 | |
AdamGreen | 0:616601bde9fb | 184 | /* save number of bits */ |
AdamGreen | 0:616601bde9fb | 185 | in[14] = mdContext->i[0]; |
AdamGreen | 0:616601bde9fb | 186 | in[15] = mdContext->i[1]; |
AdamGreen | 0:616601bde9fb | 187 | |
AdamGreen | 0:616601bde9fb | 188 | /* compute number of bytes mod 64 */ |
AdamGreen | 0:616601bde9fb | 189 | mdi = (int)((mdContext->i[0] >> 3) & 0x3F); |
AdamGreen | 0:616601bde9fb | 190 | |
AdamGreen | 0:616601bde9fb | 191 | /* pad out to 56 mod 64 */ |
AdamGreen | 0:616601bde9fb | 192 | padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); |
AdamGreen | 0:616601bde9fb | 193 | MD5Update (mdContext, PADDING, padLen); |
AdamGreen | 0:616601bde9fb | 194 | |
AdamGreen | 0:616601bde9fb | 195 | /* append length in bits and transform */ |
AdamGreen | 0:616601bde9fb | 196 | for (i = 0, ii = 0; i < 14; i++, ii += 4) { |
AdamGreen | 0:616601bde9fb | 197 | in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | |
AdamGreen | 0:616601bde9fb | 198 | (((u32_t)mdContext->in[ii+2]) << 16) | |
AdamGreen | 0:616601bde9fb | 199 | (((u32_t)mdContext->in[ii+1]) << 8) | |
AdamGreen | 0:616601bde9fb | 200 | ((u32_t)mdContext->in[ii]); |
AdamGreen | 0:616601bde9fb | 201 | } |
AdamGreen | 0:616601bde9fb | 202 | Transform (mdContext->buf, in); |
AdamGreen | 0:616601bde9fb | 203 | |
AdamGreen | 0:616601bde9fb | 204 | /* store buffer in digest */ |
AdamGreen | 0:616601bde9fb | 205 | for (i = 0, ii = 0; i < 4; i++, ii += 4) { |
AdamGreen | 0:616601bde9fb | 206 | mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); |
AdamGreen | 0:616601bde9fb | 207 | mdContext->digest[ii+1] = |
AdamGreen | 0:616601bde9fb | 208 | (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); |
AdamGreen | 0:616601bde9fb | 209 | mdContext->digest[ii+2] = |
AdamGreen | 0:616601bde9fb | 210 | (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); |
AdamGreen | 0:616601bde9fb | 211 | mdContext->digest[ii+3] = |
AdamGreen | 0:616601bde9fb | 212 | (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); |
AdamGreen | 0:616601bde9fb | 213 | } |
AdamGreen | 0:616601bde9fb | 214 | SMEMCPY(hash, mdContext->digest, 16); |
AdamGreen | 0:616601bde9fb | 215 | } |
AdamGreen | 0:616601bde9fb | 216 | |
AdamGreen | 0:616601bde9fb | 217 | /* Basic MD5 step. Transforms buf based on in. |
AdamGreen | 0:616601bde9fb | 218 | */ |
AdamGreen | 0:616601bde9fb | 219 | static void |
AdamGreen | 0:616601bde9fb | 220 | Transform (u32_t *buf, u32_t *in) |
AdamGreen | 0:616601bde9fb | 221 | { |
AdamGreen | 0:616601bde9fb | 222 | u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3]; |
AdamGreen | 0:616601bde9fb | 223 | |
AdamGreen | 0:616601bde9fb | 224 | /* Round 1 */ |
AdamGreen | 0:616601bde9fb | 225 | #define S11 7 |
AdamGreen | 0:616601bde9fb | 226 | #define S12 12 |
AdamGreen | 0:616601bde9fb | 227 | #define S13 17 |
AdamGreen | 0:616601bde9fb | 228 | #define S14 22 |
AdamGreen | 0:616601bde9fb | 229 | FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */ |
AdamGreen | 0:616601bde9fb | 230 | FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */ |
AdamGreen | 0:616601bde9fb | 231 | FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */ |
AdamGreen | 0:616601bde9fb | 232 | FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */ |
AdamGreen | 0:616601bde9fb | 233 | FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */ |
AdamGreen | 0:616601bde9fb | 234 | FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */ |
AdamGreen | 0:616601bde9fb | 235 | FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */ |
AdamGreen | 0:616601bde9fb | 236 | FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */ |
AdamGreen | 0:616601bde9fb | 237 | FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */ |
AdamGreen | 0:616601bde9fb | 238 | FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */ |
AdamGreen | 0:616601bde9fb | 239 | FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */ |
AdamGreen | 0:616601bde9fb | 240 | FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */ |
AdamGreen | 0:616601bde9fb | 241 | FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */ |
AdamGreen | 0:616601bde9fb | 242 | FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */ |
AdamGreen | 0:616601bde9fb | 243 | FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */ |
AdamGreen | 0:616601bde9fb | 244 | FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */ |
AdamGreen | 0:616601bde9fb | 245 | |
AdamGreen | 0:616601bde9fb | 246 | /* Round 2 */ |
AdamGreen | 0:616601bde9fb | 247 | #define S21 5 |
AdamGreen | 0:616601bde9fb | 248 | #define S22 9 |
AdamGreen | 0:616601bde9fb | 249 | #define S23 14 |
AdamGreen | 0:616601bde9fb | 250 | #define S24 20 |
AdamGreen | 0:616601bde9fb | 251 | GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */ |
AdamGreen | 0:616601bde9fb | 252 | GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */ |
AdamGreen | 0:616601bde9fb | 253 | GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */ |
AdamGreen | 0:616601bde9fb | 254 | GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */ |
AdamGreen | 0:616601bde9fb | 255 | GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */ |
AdamGreen | 0:616601bde9fb | 256 | GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */ |
AdamGreen | 0:616601bde9fb | 257 | GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */ |
AdamGreen | 0:616601bde9fb | 258 | GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */ |
AdamGreen | 0:616601bde9fb | 259 | GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */ |
AdamGreen | 0:616601bde9fb | 260 | GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */ |
AdamGreen | 0:616601bde9fb | 261 | GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */ |
AdamGreen | 0:616601bde9fb | 262 | GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */ |
AdamGreen | 0:616601bde9fb | 263 | GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */ |
AdamGreen | 0:616601bde9fb | 264 | GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */ |
AdamGreen | 0:616601bde9fb | 265 | GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */ |
AdamGreen | 0:616601bde9fb | 266 | GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */ |
AdamGreen | 0:616601bde9fb | 267 | |
AdamGreen | 0:616601bde9fb | 268 | /* Round 3 */ |
AdamGreen | 0:616601bde9fb | 269 | #define S31 4 |
AdamGreen | 0:616601bde9fb | 270 | #define S32 11 |
AdamGreen | 0:616601bde9fb | 271 | #define S33 16 |
AdamGreen | 0:616601bde9fb | 272 | #define S34 23 |
AdamGreen | 0:616601bde9fb | 273 | HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */ |
AdamGreen | 0:616601bde9fb | 274 | HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */ |
AdamGreen | 0:616601bde9fb | 275 | HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */ |
AdamGreen | 0:616601bde9fb | 276 | HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */ |
AdamGreen | 0:616601bde9fb | 277 | HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */ |
AdamGreen | 0:616601bde9fb | 278 | HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */ |
AdamGreen | 0:616601bde9fb | 279 | HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */ |
AdamGreen | 0:616601bde9fb | 280 | HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */ |
AdamGreen | 0:616601bde9fb | 281 | HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */ |
AdamGreen | 0:616601bde9fb | 282 | HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */ |
AdamGreen | 0:616601bde9fb | 283 | HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */ |
AdamGreen | 0:616601bde9fb | 284 | HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */ |
AdamGreen | 0:616601bde9fb | 285 | HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */ |
AdamGreen | 0:616601bde9fb | 286 | HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */ |
AdamGreen | 0:616601bde9fb | 287 | HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */ |
AdamGreen | 0:616601bde9fb | 288 | HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */ |
AdamGreen | 0:616601bde9fb | 289 | |
AdamGreen | 0:616601bde9fb | 290 | /* Round 4 */ |
AdamGreen | 0:616601bde9fb | 291 | #define S41 6 |
AdamGreen | 0:616601bde9fb | 292 | #define S42 10 |
AdamGreen | 0:616601bde9fb | 293 | #define S43 15 |
AdamGreen | 0:616601bde9fb | 294 | #define S44 21 |
AdamGreen | 0:616601bde9fb | 295 | II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */ |
AdamGreen | 0:616601bde9fb | 296 | II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */ |
AdamGreen | 0:616601bde9fb | 297 | II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */ |
AdamGreen | 0:616601bde9fb | 298 | II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */ |
AdamGreen | 0:616601bde9fb | 299 | II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */ |
AdamGreen | 0:616601bde9fb | 300 | II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */ |
AdamGreen | 0:616601bde9fb | 301 | II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */ |
AdamGreen | 0:616601bde9fb | 302 | II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */ |
AdamGreen | 0:616601bde9fb | 303 | II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */ |
AdamGreen | 0:616601bde9fb | 304 | II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */ |
AdamGreen | 0:616601bde9fb | 305 | II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */ |
AdamGreen | 0:616601bde9fb | 306 | II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */ |
AdamGreen | 0:616601bde9fb | 307 | II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */ |
AdamGreen | 0:616601bde9fb | 308 | II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */ |
AdamGreen | 0:616601bde9fb | 309 | II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */ |
AdamGreen | 0:616601bde9fb | 310 | II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */ |
AdamGreen | 0:616601bde9fb | 311 | |
AdamGreen | 0:616601bde9fb | 312 | buf[0] += a; |
AdamGreen | 0:616601bde9fb | 313 | buf[1] += b; |
AdamGreen | 0:616601bde9fb | 314 | buf[2] += c; |
AdamGreen | 0:616601bde9fb | 315 | buf[3] += d; |
AdamGreen | 0:616601bde9fb | 316 | } |
AdamGreen | 0:616601bde9fb | 317 | |
AdamGreen | 0:616601bde9fb | 318 | #endif /* CHAP_SUPPORT || MD5_SUPPORT */ |
AdamGreen | 0:616601bde9fb | 319 | |
AdamGreen | 0:616601bde9fb | 320 | #endif /* PPP_SUPPORT */ |