1 /* $FreeBSD: src/sys/crypto/md5.h,v 1.4 2002/03/20 05:13:50 alfred Exp $ */
2 /* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include "../config.h"
37 #ifndef _NETINET6_MD5_H_
38 #define _NETINET6_MD5_H_
43 #define LITTLE_ENDIAN 1
49 #ifdef WORDS_BIGENDIAN
50 #define BYTE_ORDER BIG_ENDIAN
52 #define BYTE_ORDER LITTLE_ENDIAN
56 typedef long unsigned int u_int32_t;
57 typedef long long unsigned int u_int64_t;
58 typedef unsigned char u_int8_t;
59 typedef unsigned int u_int;
60 typedef unsigned long u_long;
61 typedef unsigned char u_char;
65 u_int32_t md5_state32[4];
66 u_int8_t md5_state8[16];
69 #define md5_sta md5_st.md5_state32[0]
70 #define md5_stb md5_st.md5_state32[1]
71 #define md5_stc md5_st.md5_state32[2]
72 #define md5_std md5_st.md5_state32[3]
73 #define md5_st8 md5_st.md5_state8
76 u_int64_t md5_count64;
77 u_int8_t md5_count8[8];
79 #define md5_n md5_count.md5_count64
80 #define md5_n8 md5_count.md5_count8
83 u_int8_t md5_buf[MD5_BUFLEN];
86 static void md5_init(md5_ctxt *);
87 static void md5_loop(md5_ctxt *, const u_int8_t *, u_int);
88 static void md5_pad(md5_ctxt *);
89 static void md5_result(u_int8_t *, md5_ctxt *);
92 #define MD5_CTX md5_ctxt
93 #define MD5Init(x) md5_init((x))
94 #define MD5Update(x, y, z) md5_loop((x), (y), (z))
95 #define MD5Final(x, y) \
98 md5_result((x), (y)); \
101 #endif /* ! _NETINET6_MD5_H_*/
104 * Copyright (c) 2003 Poul-Henning Kamp
106 * University of California. All rights reserved.
107 * All rights reserved.
109 * Redistribution and use in source and binary forms, with or without
110 * modification, are permitted provided that the following conditions
112 * 1. Redistributions of source code must retain the above copyright
113 * notice, this list of conditions and the following disclaimer.
114 * 2. Redistributions in binary form must reproduce the above copyright
115 * notice, this list of conditions and the following disclaimer in the
116 * documentation and/or other materials provided with the distribution.
117 * 3. Neither the name of the author nor the names of any co-contributors
118 * may be used to endorse or promote products derived from this software
119 * without specific prior written permission.
121 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
122 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
123 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
124 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
125 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
126 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
127 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
128 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
129 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
130 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
140 void bcopy(const void*src, void*dest, int len)
142 memcpy(dest, src, len);
147 void bzero(void*mem, int len)
156 static char itoa64[] = /* 0 ... 63 => ascii - 64 */
157 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
160 _crypt_to64(char *s, u_long v, int n)
163 *s++ = itoa64[v&0x3f];
168 void hash_md5(const unsigned char*buf, int len, unsigned char*dest)
170 u_char final[MD5_SIZE];
174 MD5Update(&ctx, buf, len);
175 MD5Final(dest, &ctx);
178 char * crypt_md5(const char *pw, const char *salt)
184 u_char final[MD5_SIZE];
185 static const char *sp, *ep;
186 static char passwd[120], *p;
187 static const char *magic = "$1$";
189 /* Refine the Salt first */
192 /* If it starts with the magic string, then skip that */
193 if(!strncmp(sp, magic, strlen(magic)))
196 /* It stops at the first '$', max 8 chars */
197 for(ep = sp; *ep && *ep != '$' && ep < (sp + 8); ep++)
200 /* get the length of the true salt */
205 /* The password first, since that is what is most unknown */
206 MD5Update(&ctx, (const u_char *)pw, strlen(pw));
208 /* Then our magic string */
209 MD5Update(&ctx, (const u_char *)magic, strlen(magic));
211 /* Then the raw salt */
212 MD5Update(&ctx, (const u_char *)sp, (u_int)sl);
214 /* Then just as many characters of the MD5(pw,salt,pw) */
216 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
217 MD5Update(&ctx1, (const u_char *)sp, (u_int)sl);
218 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
219 MD5Final(final, &ctx1);
220 for(pl = (int)strlen(pw); pl > 0; pl -= MD5_SIZE)
221 MD5Update(&ctx, (const u_char *)final,
222 (u_int)(pl > MD5_SIZE ? MD5_SIZE : pl));
224 /* Don't leave anything around in vm they could use. */
225 memset(final, 0, sizeof(final));
227 /* Then something really weird... */
228 for (i = strlen(pw); i; i >>= 1)
230 MD5Update(&ctx, (const u_char *)final, 1);
232 MD5Update(&ctx, (const u_char *)pw, 1);
234 /* Now make the output string */
235 strcpy(passwd, magic);
236 strncat(passwd, sp, (u_int)sl);
239 MD5Final(final, &ctx);
242 * and now, just to make sure things don't run too fast
243 * On a 60 Mhz Pentium this takes 34 msec, so you would
244 * need 30 seconds to build a 1000 entry dictionary...
246 for(i = 0; i < 1000; i++) {
249 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
251 MD5Update(&ctx1, (const u_char *)final, MD5_SIZE);
254 MD5Update(&ctx1, (const u_char *)sp, (u_int)sl);
257 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
260 MD5Update(&ctx1, (const u_char *)final, MD5_SIZE);
262 MD5Update(&ctx1, (const u_char *)pw, strlen(pw));
263 MD5Final(final, &ctx1);
266 p = passwd + strlen(passwd);
268 l = (final[ 0]<<16) | (final[ 6]<<8) | final[12];
269 _crypt_to64(p, l, 4); p += 4;
270 l = (final[ 1]<<16) | (final[ 7]<<8) | final[13];
271 _crypt_to64(p, l, 4); p += 4;
272 l = (final[ 2]<<16) | (final[ 8]<<8) | final[14];
273 _crypt_to64(p, l, 4); p += 4;
274 l = (final[ 3]<<16) | (final[ 9]<<8) | final[15];
275 _crypt_to64(p, l, 4); p += 4;
276 l = (final[ 4]<<16) | (final[10]<<8) | final[ 5];
277 _crypt_to64(p, l, 4); p += 4;
279 _crypt_to64(p, l, 2); p += 2;
282 /* Don't leave anything around in vm they could use. */
283 memset(final, 0, sizeof(final));
288 /* $KAME: md5.c,v 1.5 2000/11/08 06:13:08 itojun Exp $ */
290 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
291 * All rights reserved.
293 * Redistribution and use in source and binary forms, with or without
294 * modification, are permitted provided that the following conditions
296 * 1. Redistributions of source code must retain the above copyright
297 * notice, this list of conditions and the following disclaimer.
298 * 2. Redistributions in binary form must reproduce the above copyright
299 * notice, this list of conditions and the following disclaimer in the
300 * documentation and/or other materials provided with the distribution.
301 * 3. Neither the name of the project nor the names of its contributors
302 * may be used to endorse or promote products derived from this software
303 * without specific prior written permission.
305 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
306 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
307 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
308 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
309 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
310 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
311 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
312 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
313 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
318 #define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s))))
320 #define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z)))
321 #define G(X, Y, Z) (((X) & (Z)) | ((Y) & (~Z)))
322 #define H(X, Y, Z) ((X) ^ (Y) ^ (Z))
323 #define I(X, Y, Z) ((Y) ^ ((X) | (~Z)))
325 #define ROUND1(a, b, c, d, k, s, i) { \
326 (a) = (a) + F((b), (c), (d)) + X[(k)] + T[(i)]; \
327 (a) = SHIFT((a), (s)); \
331 #define ROUND2(a, b, c, d, k, s, i) { \
332 (a) = (a) + G((b), (c), (d)) + X[(k)] + T[(i)]; \
333 (a) = SHIFT((a), (s)); \
337 #define ROUND3(a, b, c, d, k, s, i) { \
338 (a) = (a) + H((b), (c), (d)) + X[(k)] + T[(i)]; \
339 (a) = SHIFT((a), (s)); \
343 #define ROUND4(a, b, c, d, k, s, i) { \
344 (a) = (a) + I((b), (c), (d)) + X[(k)] + T[(i)]; \
345 (a) = SHIFT((a), (s)); \
369 #define MD5_A0 0x67452301
370 #define MD5_B0 0xefcdab89
371 #define MD5_C0 0x98badcfe
372 #define MD5_D0 0x10325476
374 /* Integer part of 4294967296 times abs(sin(i)), where i is in radians. */
375 static const u_int32_t T[65] = {
377 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
378 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
379 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
380 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
382 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
383 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
384 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
385 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
387 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
388 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
389 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
390 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
392 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
393 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
394 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
395 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
398 static const u_int8_t md5_paddat[MD5_BUFLEN] = {
399 0x80, 0, 0, 0, 0, 0, 0, 0,
400 0, 0, 0, 0, 0, 0, 0, 0,
401 0, 0, 0, 0, 0, 0, 0, 0,
402 0, 0, 0, 0, 0, 0, 0, 0,
403 0, 0, 0, 0, 0, 0, 0, 0,
404 0, 0, 0, 0, 0, 0, 0, 0,
405 0, 0, 0, 0, 0, 0, 0, 0,
406 0, 0, 0, 0, 0, 0, 0, 0,
409 static void md5_calc(u_int8_t *, md5_ctxt *);
411 static void md5_init(ctxt)
416 ctxt->md5_sta = MD5_A0;
417 ctxt->md5_stb = MD5_B0;
418 ctxt->md5_stc = MD5_C0;
419 ctxt->md5_std = MD5_D0;
420 bzero(ctxt->md5_buf, sizeof(ctxt->md5_buf));
423 static void md5_loop(ctxt, input, len)
425 const u_int8_t *input;
426 u_int len; /* number of bytes */
430 ctxt->md5_n += len * 8; /* byte to bit */
431 gap = MD5_BUFLEN - ctxt->md5_i;
434 bcopy((void *)input, (void *)(ctxt->md5_buf + ctxt->md5_i),
436 md5_calc(ctxt->md5_buf, ctxt);
438 for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) {
439 md5_calc((u_int8_t *)(input + i), ctxt);
442 ctxt->md5_i = len - i;
443 bcopy((void *)(input + i), (void *)ctxt->md5_buf, ctxt->md5_i);
445 bcopy((void *)input, (void *)(ctxt->md5_buf + ctxt->md5_i),
451 static void md5_pad(ctxt)
456 /* Don't count up padding. Keep md5_n. */
457 gap = MD5_BUFLEN - ctxt->md5_i;
460 (void *)(ctxt->md5_buf + ctxt->md5_i),
461 gap - sizeof(ctxt->md5_n));
463 /* including gap == 8 */
464 bcopy(md5_paddat, (void *)(ctxt->md5_buf + ctxt->md5_i),
466 md5_calc(ctxt->md5_buf, ctxt);
467 bcopy((md5_paddat + gap),
468 (void *)ctxt->md5_buf,
469 MD5_BUFLEN - sizeof(ctxt->md5_n));
473 #if BYTE_ORDER == LITTLE_ENDIAN
474 bcopy(&ctxt->md5_n8[0], &ctxt->md5_buf[56], 8);
476 #if BYTE_ORDER == BIG_ENDIAN
477 ctxt->md5_buf[56] = ctxt->md5_n8[7];
478 ctxt->md5_buf[57] = ctxt->md5_n8[6];
479 ctxt->md5_buf[58] = ctxt->md5_n8[5];
480 ctxt->md5_buf[59] = ctxt->md5_n8[4];
481 ctxt->md5_buf[60] = ctxt->md5_n8[3];
482 ctxt->md5_buf[61] = ctxt->md5_n8[2];
483 ctxt->md5_buf[62] = ctxt->md5_n8[1];
484 ctxt->md5_buf[63] = ctxt->md5_n8[0];
487 md5_calc(ctxt->md5_buf, ctxt);
490 static void md5_result(digest, ctxt)
495 #if BYTE_ORDER == LITTLE_ENDIAN
496 bcopy(&ctxt->md5_st8[0], digest, 16);
498 #if BYTE_ORDER == BIG_ENDIAN
499 digest[ 0] = ctxt->md5_st8[ 3]; digest[ 1] = ctxt->md5_st8[ 2];
500 digest[ 2] = ctxt->md5_st8[ 1]; digest[ 3] = ctxt->md5_st8[ 0];
501 digest[ 4] = ctxt->md5_st8[ 7]; digest[ 5] = ctxt->md5_st8[ 6];
502 digest[ 6] = ctxt->md5_st8[ 5]; digest[ 7] = ctxt->md5_st8[ 4];
503 digest[ 8] = ctxt->md5_st8[11]; digest[ 9] = ctxt->md5_st8[10];
504 digest[10] = ctxt->md5_st8[ 9]; digest[11] = ctxt->md5_st8[ 8];
505 digest[12] = ctxt->md5_st8[15]; digest[13] = ctxt->md5_st8[14];
506 digest[14] = ctxt->md5_st8[13]; digest[15] = ctxt->md5_st8[12];
510 static void md5_calc(b64, ctxt)
514 u_int32_t A = ctxt->md5_sta;
515 u_int32_t B = ctxt->md5_stb;
516 u_int32_t C = ctxt->md5_stc;
517 u_int32_t D = ctxt->md5_std;
518 #if BYTE_ORDER == LITTLE_ENDIAN
519 u_int32_t *X = (u_int32_t *)b64;
521 #if BYTE_ORDER == BIG_ENDIAN
524 /* what a brute force but fast! */
525 u_int8_t *y = (u_int8_t *)X;
526 y[ 0] = b64[ 3]; y[ 1] = b64[ 2]; y[ 2] = b64[ 1]; y[ 3] = b64[ 0];
527 y[ 4] = b64[ 7]; y[ 5] = b64[ 6]; y[ 6] = b64[ 5]; y[ 7] = b64[ 4];
528 y[ 8] = b64[11]; y[ 9] = b64[10]; y[10] = b64[ 9]; y[11] = b64[ 8];
529 y[12] = b64[15]; y[13] = b64[14]; y[14] = b64[13]; y[15] = b64[12];
530 y[16] = b64[19]; y[17] = b64[18]; y[18] = b64[17]; y[19] = b64[16];
531 y[20] = b64[23]; y[21] = b64[22]; y[22] = b64[21]; y[23] = b64[20];
532 y[24] = b64[27]; y[25] = b64[26]; y[26] = b64[25]; y[27] = b64[24];
533 y[28] = b64[31]; y[29] = b64[30]; y[30] = b64[29]; y[31] = b64[28];
534 y[32] = b64[35]; y[33] = b64[34]; y[34] = b64[33]; y[35] = b64[32];
535 y[36] = b64[39]; y[37] = b64[38]; y[38] = b64[37]; y[39] = b64[36];
536 y[40] = b64[43]; y[41] = b64[42]; y[42] = b64[41]; y[43] = b64[40];
537 y[44] = b64[47]; y[45] = b64[46]; y[46] = b64[45]; y[47] = b64[44];
538 y[48] = b64[51]; y[49] = b64[50]; y[50] = b64[49]; y[51] = b64[48];
539 y[52] = b64[55]; y[53] = b64[54]; y[54] = b64[53]; y[55] = b64[52];
540 y[56] = b64[59]; y[57] = b64[58]; y[58] = b64[57]; y[59] = b64[56];
541 y[60] = b64[63]; y[61] = b64[62]; y[62] = b64[61]; y[63] = b64[60];
544 ROUND1(A, B, C, D, 0, Sa, 1); ROUND1(D, A, B, C, 1, Sb, 2);
545 ROUND1(C, D, A, B, 2, Sc, 3); ROUND1(B, C, D, A, 3, Sd, 4);
546 ROUND1(A, B, C, D, 4, Sa, 5); ROUND1(D, A, B, C, 5, Sb, 6);
547 ROUND1(C, D, A, B, 6, Sc, 7); ROUND1(B, C, D, A, 7, Sd, 8);
548 ROUND1(A, B, C, D, 8, Sa, 9); ROUND1(D, A, B, C, 9, Sb, 10);
549 ROUND1(C, D, A, B, 10, Sc, 11); ROUND1(B, C, D, A, 11, Sd, 12);
550 ROUND1(A, B, C, D, 12, Sa, 13); ROUND1(D, A, B, C, 13, Sb, 14);
551 ROUND1(C, D, A, B, 14, Sc, 15); ROUND1(B, C, D, A, 15, Sd, 16);
553 ROUND2(A, B, C, D, 1, Se, 17); ROUND2(D, A, B, C, 6, Sf, 18);
554 ROUND2(C, D, A, B, 11, Sg, 19); ROUND2(B, C, D, A, 0, Sh, 20);
555 ROUND2(A, B, C, D, 5, Se, 21); ROUND2(D, A, B, C, 10, Sf, 22);
556 ROUND2(C, D, A, B, 15, Sg, 23); ROUND2(B, C, D, A, 4, Sh, 24);
557 ROUND2(A, B, C, D, 9, Se, 25); ROUND2(D, A, B, C, 14, Sf, 26);
558 ROUND2(C, D, A, B, 3, Sg, 27); ROUND2(B, C, D, A, 8, Sh, 28);
559 ROUND2(A, B, C, D, 13, Se, 29); ROUND2(D, A, B, C, 2, Sf, 30);
560 ROUND2(C, D, A, B, 7, Sg, 31); ROUND2(B, C, D, A, 12, Sh, 32);
562 ROUND3(A, B, C, D, 5, Si, 33); ROUND3(D, A, B, C, 8, Sj, 34);
563 ROUND3(C, D, A, B, 11, Sk, 35); ROUND3(B, C, D, A, 14, Sl, 36);
564 ROUND3(A, B, C, D, 1, Si, 37); ROUND3(D, A, B, C, 4, Sj, 38);
565 ROUND3(C, D, A, B, 7, Sk, 39); ROUND3(B, C, D, A, 10, Sl, 40);
566 ROUND3(A, B, C, D, 13, Si, 41); ROUND3(D, A, B, C, 0, Sj, 42);
567 ROUND3(C, D, A, B, 3, Sk, 43); ROUND3(B, C, D, A, 6, Sl, 44);
568 ROUND3(A, B, C, D, 9, Si, 45); ROUND3(D, A, B, C, 12, Sj, 46);
569 ROUND3(C, D, A, B, 15, Sk, 47); ROUND3(B, C, D, A, 2, Sl, 48);
571 ROUND4(A, B, C, D, 0, Sm, 49); ROUND4(D, A, B, C, 7, Sn, 50);
572 ROUND4(C, D, A, B, 14, So, 51); ROUND4(B, C, D, A, 5, Sp, 52);
573 ROUND4(A, B, C, D, 12, Sm, 53); ROUND4(D, A, B, C, 3, Sn, 54);
574 ROUND4(C, D, A, B, 10, So, 55); ROUND4(B, C, D, A, 1, Sp, 56);
575 ROUND4(A, B, C, D, 8, Sm, 57); ROUND4(D, A, B, C, 15, Sn, 58);
576 ROUND4(C, D, A, B, 6, So, 59); ROUND4(B, C, D, A, 13, Sp, 60);
577 ROUND4(A, B, C, D, 4, Sm, 61); ROUND4(D, A, B, C, 11, Sn, 62);
578 ROUND4(C, D, A, B, 2, So, 63); ROUND4(B, C, D, A, 9, Sp, 64);