Port to C027 (using AppShield and Ethernet)

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

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