we used to have cpu specific _sha1block() and _md5block() functions for 386, but every other arch just copied the portable c version. md5() and sha1() are not really on the critical path as we use chacha20/poly1305 over TLS for communication with the cpu server. so just get rid of the noise.
Unified · Split
| @@ -11,7 +11,7 @@ OFILES=\ · 10 unmodified lines | ||
| 11 | 11 | hmac.$O hkdf.$O pbkdf2.$O\ |
| 12 | 12 | rsaalloc.$O rsadecrypt.$O rsaencrypt.$O\ |
| 13 | 13 | dh.$O\ |
| 14 | − rc4.$O md5.$O\ | |
| 14 | + rc4.$O md5.$O md5block.$O\ | |
| 15 | 15 | sha1.$O sha2_128.$O sha2_64.$O\ |
| 16 | 16 | sha1block.$O sha2block128.$O sha2block64.$O\ |
| 17 | 17 | tlshand.$O x509.$O\ |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -18,10 +16,3 @@ $(LIB): $(OFILES) · 6 unmodified lines | ||
| 18 | 16 | |
| 19 | 17 | %.$O: %.s |
| 20 | 18 | $(AS) -o $*.$O $*.s |
| 21 | − | |
| 22 | −md5block.s: md5block.spp | |
| 23 | − gcc -E - < md5block.spp >md5block.s | |
| 24 | − | |
| 25 | −sha1block.s: sha1block.spp | |
| 26 | − gcc -E - < sha1block.spp >sha1block.s | |
| 27 | − | |
| @@ -1,248 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 3 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 4 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 5 | − * | |
| 6 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 7 | − * rights reserved. | |
| 8 | − * | |
| 9 | − * License to copy and use this software is granted provided that it | |
| 10 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 11 | − * Algorithm" in all material mentioning or referencing this software | |
| 12 | − * or this function. | |
| 13 | − * | |
| 14 | − * License is also granted to make and use derivative works provided | |
| 15 | − * that such works are identified as "derived from the RSA Data | |
| 16 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 17 | − * mentioning or referencing the derived work. | |
| 18 | − * | |
| 19 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 20 | − * the merchantability of this software or the suitability of this | |
| 21 | − * software forany particular purpose. It is provided "as is" | |
| 22 | − * without express or implied warranty of any kind. | |
| 23 | − * These notices must be retained in any copies of any part of this | |
| 24 | − * documentation and/or software. | |
| 25 | − */ | |
| 26 | −#define S11 7 | |
| 27 | −#define S12 12 | |
| 28 | −#define S13 17 | |
| 29 | −#define S14 22 | |
| 30 | − | |
| 31 | −#define S21 5 | |
| 32 | −#define S22 9 | |
| 33 | −#define S23 14 | |
| 34 | −#define S24 20 | |
| 35 | − | |
| 36 | −#define S31 4 | |
| 37 | −#define S32 11 | |
| 38 | −#define S33 16 | |
| 39 | −#define S34 23 | |
| 40 | − | |
| 41 | −#define S41 6 | |
| 42 | −#define S42 10 | |
| 43 | −#define S43 15 | |
| 44 | −#define S44 21 | |
| 45 | − | |
| 46 | −#define PAYME(x) $##x | |
| 47 | − | |
| 48 | −/* | |
| 49 | − * SI is data | |
| 50 | − * a += FN(B,C,D); | |
| 51 | − * a += x[sh] + t[sh]; | |
| 52 | − * a = (a << S11) | (a >> (32 - S11)); | |
| 53 | − * a += b; | |
| 54 | − */ | |
| 55 | − | |
| 56 | −#define BODY1(off,V,FN,SH,A,B,C,D)\ | |
| 57 | − FN(B,C,D)\ | |
| 58 | − leal V(A, %edi, 1), A;\ | |
| 59 | − addl off(%ebp), A;\ | |
| 60 | − roll PAYME(SH), A;\ | |
| 61 | − addl B, A;\ | |
| 62 | − | |
| 63 | −#define BODY(off,V,FN,SH,A,B,C,D)\ | |
| 64 | − FN(B,C,D)\ | |
| 65 | − leal V(A, %edi, 1), A;\ | |
| 66 | − addl (off)(%ebp), A;\ | |
| 67 | − roll PAYME(SH), A;\ | |
| 68 | − addl B,A;\ | |
| 69 | − | |
| 70 | −/* | |
| 71 | − * fn1 = ((c ^ d) & b) ^ d | |
| 72 | − */ | |
| 73 | −#define FN1(B,C,D)\ | |
| 74 | − movl C, %edi;\ | |
| 75 | − xorl D, %edi;\ | |
| 76 | − andl B, %edi;\ | |
| 77 | − xorl D, %edi;\ | |
| 78 | − | |
| 79 | −/* | |
| 80 | − * fn2 = ((b ^ c) & d) ^ c; | |
| 81 | − */ | |
| 82 | −#define FN2(B,C,D)\ | |
| 83 | − movl B, %edi;\ | |
| 84 | − xorl C, %edi;\ | |
| 85 | − andl D, %edi;\ | |
| 86 | − xorl C, %edi;\ | |
| 87 | − | |
| 88 | −/* | |
| 89 | − * fn3 = b ^ c ^ d; | |
| 90 | − */ | |
| 91 | −#define FN3(B,C,D)\ | |
| 92 | − movl B, %edi;\ | |
| 93 | − xorl C, %edi;\ | |
| 94 | − xorl D, %edi;\ | |
| 95 | − | |
| 96 | −/* | |
| 97 | − * fn4 = c ^ (b | ~d); | |
| 98 | − */ | |
| 99 | −#define FN4(B,C,D)\ | |
| 100 | − movl D, %edi;\ | |
| 101 | − xorl $-1, %edi;\ | |
| 102 | − orl B, %edi;\ | |
| 103 | − xorl C, %edi;\ | |
| 104 | − | |
| 105 | −#define STACKSIZE 20 | |
| 106 | − | |
| 107 | −#define DATA (STACKSIZE+8) | |
| 108 | −#define LEN (STACKSIZE+12) | |
| 109 | −#define STATE (STACKSIZE+16) | |
| 110 | − | |
| 111 | −#define EDATA (STACKSIZE-4) | |
| 112 | −#define OLDEBX (STACKSIZE-8) | |
| 113 | −#define OLDESI (STACKSIZE-12) | |
| 114 | −#define OLDEDI (STACKSIZE-16) | |
| 115 | − | |
| 116 | − .text | |
| 117 | − | |
| 118 | − .p2align 2,0x90 | |
| 119 | −#ifdef __APPLE__ | |
| 120 | − .globl __md5block | |
| 121 | − __md5block: | |
| 122 | −#else | |
| 123 | − .globl _md5block | |
| 124 | − _md5block: | |
| 125 | −#endif | |
| 126 | − | |
| 127 | − /* Prelude */ | |
| 128 | − pushl %ebp | |
| 129 | − subl $(STACKSIZE), %esp | |
| 130 | − movl %ebx, OLDEBX(%esp) | |
| 131 | − movl %esi, OLDESI(%esp) | |
| 132 | − movl %edi, OLDEDI(%esp) | |
| 133 | − | |
| 134 | − movl DATA(%esp), %eax | |
| 135 | − addl LEN(%esp), %eax | |
| 136 | − movl %eax, EDATA(%esp) | |
| 137 | − | |
| 138 | − movl DATA(%esp), %ebp | |
| 139 | − | |
| 140 | −0: | |
| 141 | − movl STATE(%esp), %esi | |
| 142 | − movl (%esi), %eax | |
| 143 | − movl 4(%esi), %ebx | |
| 144 | − movl 8(%esi), %ecx | |
| 145 | − movl 12(%esi), %edx | |
| 146 | − | |
| 147 | − BODY1( 0*4,0xd76aa478,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 148 | − BODY1( 1*4,0xe8c7b756,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 149 | − BODY1( 2*4,0x242070db,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 150 | − BODY1( 3*4,0xc1bdceee,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 151 | − | |
| 152 | − BODY1( 4*4,0xf57c0faf,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 153 | − BODY1( 5*4,0x4787c62a,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 154 | − BODY1( 6*4,0xa8304613,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 155 | − BODY1( 7*4,0xfd469501,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 156 | − | |
| 157 | − BODY1( 8*4,0x698098d8,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 158 | − BODY1( 9*4,0x8b44f7af,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 159 | − BODY1(10*4,0xffff5bb1,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 160 | − BODY1(11*4,0x895cd7be,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 161 | − | |
| 162 | − BODY1(12*4,0x6b901122,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 163 | − BODY1(13*4,0xfd987193,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 164 | − BODY1(14*4,0xa679438e,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 165 | − BODY1(15*4,0x49b40821,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 166 | − | |
| 167 | − | |
| 168 | − BODY( 1*4,0xf61e2562,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 169 | − BODY( 6*4,0xc040b340,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 170 | − BODY(11*4,0x265e5a51,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 171 | − BODY( 0*4,0xe9b6c7aa,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 172 | − | |
| 173 | − BODY( 5*4,0xd62f105d,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 174 | − BODY(10*4,0x02441453,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 175 | − BODY(15*4,0xd8a1e681,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 176 | − BODY( 4*4,0xe7d3fbc8,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 177 | − | |
| 178 | − BODY( 9*4,0x21e1cde6,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 179 | − BODY(14*4,0xc33707d6,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 180 | − BODY( 3*4,0xf4d50d87,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 181 | − BODY( 8*4,0x455a14ed,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 182 | − | |
| 183 | − BODY(13*4,0xa9e3e905,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 184 | − BODY( 2*4,0xfcefa3f8,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 185 | − BODY( 7*4,0x676f02d9,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 186 | − BODY(12*4,0x8d2a4c8a,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 187 | − | |
| 188 | − | |
| 189 | − BODY( 5*4,0xfffa3942,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 190 | − BODY( 8*4,0x8771f681,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 191 | − BODY(11*4,0x6d9d6122,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 192 | − BODY(14*4,0xfde5380c,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 193 | − | |
| 194 | − BODY( 1*4,0xa4beea44,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 195 | − BODY( 4*4,0x4bdecfa9,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 196 | − BODY( 7*4,0xf6bb4b60,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 197 | − BODY(10*4,0xbebfbc70,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 198 | − | |
| 199 | − BODY(13*4,0x289b7ec6,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 200 | − BODY( 0*4,0xeaa127fa,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 201 | − BODY( 3*4,0xd4ef3085,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 202 | − BODY( 6*4,0x04881d05,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 203 | − | |
| 204 | − BODY( 9*4,0xd9d4d039,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 205 | − BODY(12*4,0xe6db99e5,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 206 | − BODY(15*4,0x1fa27cf8,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 207 | − BODY( 2*4,0xc4ac5665,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 208 | − | |
| 209 | − | |
| 210 | − BODY( 0*4,0xf4292244,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 211 | − BODY( 7*4,0x432aff97,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 212 | − BODY(14*4,0xab9423a7,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 213 | − BODY( 5*4,0xfc93a039,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 214 | − | |
| 215 | − BODY(12*4,0x655b59c3,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 216 | − BODY( 3*4,0x8f0ccc92,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 217 | − BODY(10*4,0xffeff47d,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 218 | − BODY( 1*4,0x85845dd1,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 219 | − | |
| 220 | − BODY( 8*4,0x6fa87e4f,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 221 | − BODY(15*4,0xfe2ce6e0,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 222 | − BODY( 6*4,0xa3014314,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 223 | − BODY(13*4,0x4e0811a1,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 224 | − | |
| 225 | − BODY( 4*4,0xf7537e82,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 226 | − BODY(11*4,0xbd3af235,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 227 | − BODY( 2*4,0x2ad7d2bb,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 228 | − BODY( 9*4,0xeb86d391,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 229 | − | |
| 230 | − addl $(16*4), %ebp | |
| 231 | − movl STATE(%esp), %edi | |
| 232 | − addl %eax,0(%edi) | |
| 233 | − addl %ebx,4(%edi) | |
| 234 | − addl %ecx,8(%edi) | |
| 235 | − addl %edx,12(%edi) | |
| 236 | − | |
| 237 | − movl EDATA(%esp), %edi | |
| 238 | − cmpl %edi, %ebp | |
| 239 | − jb 0b | |
| 240 | − | |
| 241 | − /* Postlude */ | |
| 242 | − movl OLDEBX(%esp), %ebx | |
| 243 | − movl OLDESI(%esp), %esi | |
| 244 | − movl OLDEDI(%esp), %edi | |
| 245 | − addl $(STACKSIZE), %esp | |
| 246 | − popl %ebp | |
| 247 | − ret | |
| 248 | − | |
| @@ -1,221 +0,0 @@ | ||
| 1 | −.text | |
| 2 | − | |
| 3 | −.p2align 2,0x90 | |
| 4 | −#ifdef __APPLE__ | |
| 5 | −.globl __sha1block | |
| 6 | −__sha1block: | |
| 7 | −#else | |
| 8 | −.globl _sha1block | |
| 9 | −_sha1block: | |
| 10 | −#endif | |
| 11 | − | |
| 12 | −/* x = (wp[off-f] ^ wp[off-8] ^ wp[off-14] ^ wp[off-16]) <<< 1; | |
| 13 | − * wp[off] = x; | |
| 14 | − * x += A <<< 5; | |
| 15 | − * E += 0xca62c1d6 + x; | |
| 16 | − * x = FN(B,C,D); | |
| 17 | − * E += x; | |
| 18 | − * B >>> 2 | |
| 19 | − */ | |
| 20 | −#define BSWAPDI BYTE $0x0f; BYTE $0xcf; | |
| 21 | − | |
| 22 | −#define BODY(off,FN,V,A,B,C,D,E)\ | |
| 23 | − movl (off-64)(%ebp), %edi;\ | |
| 24 | − xorl (off-56)(%ebp), %edi;\ | |
| 25 | − xorl (off-32)(%ebp), %edi;\ | |
| 26 | − xorl (off-12)(%ebp), %edi;\ | |
| 27 | − roll $1, %edi;\ | |
| 28 | − movl %edi, off(%ebp);\ | |
| 29 | − leal V(%edi, E, 1), E;\ | |
| 30 | − movl A, %edi;\ | |
| 31 | − roll $5, %edi;\ | |
| 32 | − addl %edi, E;\ | |
| 33 | − FN(B,C,D)\ | |
| 34 | − addl %edi, E;\ | |
| 35 | − rorl $2, B;\ | |
| 36 | − | |
| 37 | −#define BODY0(off,FN,V,A,B,C,D,E)\ | |
| 38 | − movl off(%ebx), %edi;\ | |
| 39 | − bswap %edi;\ | |
| 40 | − movl %edi, off(%ebp);\ | |
| 41 | − leal V(%edi,E,1), E;\ | |
| 42 | − movl A, %edi;\ | |
| 43 | − roll $5,%edi;\ | |
| 44 | − addl %edi,E;\ | |
| 45 | − FN(B,C,D)\ | |
| 46 | − addl %edi,E;\ | |
| 47 | − rorl $2,B;\ | |
| 48 | − | |
| 49 | −/* | |
| 50 | − * fn1 = (((C^D)&B)^D); | |
| 51 | − */ | |
| 52 | −#define FN1(B,C,D)\ | |
| 53 | − movl C, %edi;\ | |
| 54 | − xorl D, %edi;\ | |
| 55 | − andl B, %edi;\ | |
| 56 | − xorl D, %edi;\ | |
| 57 | − | |
| 58 | −/* | |
| 59 | − * fn24 = B ^ C ^ D | |
| 60 | − */ | |
| 61 | −#define FN24(B,C,D)\ | |
| 62 | − movl B, %edi;\ | |
| 63 | − xorl C, %edi;\ | |
| 64 | − xorl D, %edi;\ | |
| 65 | − | |
| 66 | −/* | |
| 67 | − * fn3 = ((B ^ C) & (D ^= B)) ^ B | |
| 68 | − * D ^= B to restore D | |
| 69 | − */ | |
| 70 | −#define FN3(B,C,D)\ | |
| 71 | − movl B, %edi;\ | |
| 72 | − xorl C, %edi;\ | |
| 73 | − xorl B, D;\ | |
| 74 | − andl D, %edi;\ | |
| 75 | − xorl B, %edi;\ | |
| 76 | − xorl B, D;\ | |
| 77 | − | |
| 78 | −/* | |
| 79 | − * stack offsets | |
| 80 | − * void sha1block(uchar *DATA, int LEN, ulong *STATE) | |
| 81 | − */ | |
| 82 | −#define STACKSIZE (48+80*4) | |
| 83 | −#define DATA (STACKSIZE+8) | |
| 84 | −#define LEN (STACKSIZE+12) | |
| 85 | −#define STATE (STACKSIZE+16) | |
| 86 | − | |
| 87 | −/* | |
| 88 | − * stack offsets for locals | |
| 89 | − * ulong w[80]; | |
| 90 | − * uchar *edata; | |
| 91 | − * ulong *w15, *w40, *w60, *w80; | |
| 92 | − * register local | |
| 93 | − * ulong *wp = %ebp | |
| 94 | − * ulong a = eax, b = ebx, c = ecx, d = edx, e = esi | |
| 95 | − * ulong tmp = edi | |
| 96 | − */ | |
| 97 | −#define WARRAY (STACKSIZE-4-(80*4)) | |
| 98 | −#define TMP1 (STACKSIZE-8-(80*4)) | |
| 99 | −#define TMP2 (STACKSIZE-12-(80*4)) | |
| 100 | −#define W15 (STACKSIZE-16-(80*4)) | |
| 101 | −#define W40 (STACKSIZE-20-(80*4)) | |
| 102 | −#define W60 (STACKSIZE-24-(80*4)) | |
| 103 | −#define W80 (STACKSIZE-28-(80*4)) | |
| 104 | −#define EDATA (STACKSIZE-32-(80*4)) | |
| 105 | −#define OLDEBX (STACKSIZE-36-(80*4)) | |
| 106 | −#define OLDESI (STACKSIZE-40-(80*4)) | |
| 107 | −#define OLDEDI (STACKSIZE-44-(80*4)) | |
| 108 | − | |
| 109 | − /* Prelude */ | |
| 110 | − pushl %ebp | |
| 111 | − subl $(STACKSIZE), %esp | |
| 112 | − | |
| 113 | − mov %ebx, OLDEBX(%esp) | |
| 114 | − mov %esi, OLDESI(%esp) | |
| 115 | − mov %edi, OLDEDI(%esp) | |
| 116 | − | |
| 117 | − movl DATA(%esp), %eax | |
| 118 | − addl LEN(%esp), %eax | |
| 119 | − movl %eax, EDATA(%esp) | |
| 120 | − | |
| 121 | − leal (WARRAY+15*4)(%esp), %edi /* aw15 */ | |
| 122 | − movl %edi, W15(%esp) | |
| 123 | − leal (WARRAY+40*4)(%esp), %edx /* aw40 */ | |
| 124 | − movl %edx, W40(%esp) | |
| 125 | − leal (WARRAY+60*4)(%esp), %ecx /* aw60 */ | |
| 126 | − movl %ecx, W60(%esp) | |
| 127 | − leal (WARRAY+80*4)(%esp), %edi /* aw80 */ | |
| 128 | − movl %edi, W80(%esp) | |
| 129 | − | |
| 130 | −0: | |
| 131 | − leal WARRAY(%esp), %ebp /* warray */ | |
| 132 | − | |
| 133 | − movl STATE(%esp), %edi /* state */ | |
| 134 | − movl (%edi),%eax | |
| 135 | − movl 4(%edi),%ebx | |
| 136 | − movl %ebx, TMP1(%esp) /* tmp1 */ | |
| 137 | − movl 8(%edi), %ecx | |
| 138 | − movl 12(%edi), %edx | |
| 139 | − movl 16(%edi), %esi | |
| 140 | − | |
| 141 | − movl DATA(%esp), %ebx /* data */ | |
| 142 | − | |
| 143 | −1: | |
| 144 | − BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi) | |
| 145 | − movl %esi,TMP2(%esp) | |
| 146 | − BODY0(4,FN1,0x5a827999,%esi,%eax,TMP1(%esp),%ecx,%edx) | |
| 147 | − movl TMP1(%esp),%esi | |
| 148 | − BODY0(8,FN1,0x5a827999,%edx,TMP2(%esp),%eax,%esi,%ecx) | |
| 149 | − BODY0(12,FN1,0x5a827999,%ecx,%edx,TMP2(%esp),%eax,%esi) | |
| 150 | − movl %esi,TMP1(%esp) | |
| 151 | − BODY0(16,FN1,0x5a827999,%esi,%ecx,%edx,TMP2(%esp),%eax) | |
| 152 | − movl TMP2(%esp),%esi | |
| 153 | − | |
| 154 | − addl $20, %ebx | |
| 155 | − addl $20, %ebp | |
| 156 | − cmpl W15(%esp), %ebp /* w15 */ | |
| 157 | − jb 1b | |
| 158 | − | |
| 159 | − BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi) | |
| 160 | − addl $4, %ebx | |
| 161 | − MOVL %ebx, DATA(%esp) /* data */ | |
| 162 | − MOVL TMP1(%esp),%ebx | |
| 163 | − | |
| 164 | − BODY(4,FN1,0x5a827999,%esi,%eax,%ebx,%ecx,%edx) | |
| 165 | − BODY(8,FN1,0x5a827999,%edx,%esi,%eax,%ebx,%ecx) | |
| 166 | − BODY(12,FN1,0x5a827999,%ecx,%edx,%esi,%eax,%ebx) | |
| 167 | − BODY(16,FN1,0x5a827999,%ebx,%ecx,%edx,%esi,%eax) | |
| 168 | − | |
| 169 | − addl $20, %ebp | |
| 170 | − | |
| 171 | −2: | |
| 172 | − BODY(0,FN24,0x6ed9eba1,%eax,%ebx,%ecx,%edx,%esi) | |
| 173 | − BODY(4,FN24,0x6ed9eba1,%esi,%eax,%ebx,%ecx,%edx) | |
| 174 | − BODY(8,FN24,0x6ed9eba1,%edx,%esi,%eax,%ebx,%ecx) | |
| 175 | − BODY(12,FN24,0x6ed9eba1,%ecx,%edx,%esi,%eax,%ebx) | |
| 176 | − BODY(16,FN24,0x6ed9eba1,%ebx,%ecx,%edx,%esi,%eax) | |
| 177 | − | |
| 178 | − addl $20,%ebp | |
| 179 | − cmpl W40(%esp), %ebp | |
| 180 | − jb 2b | |
| 181 | − | |
| 182 | −3: | |
| 183 | − BODY(0,FN3,0x8f1bbcdc,%eax,%ebx,%ecx,%edx,%esi) | |
| 184 | − BODY(4,FN3,0x8f1bbcdc,%esi,%eax,%ebx,%ecx,%edx) | |
| 185 | − BODY(8,FN3,0x8f1bbcdc,%edx,%esi,%eax,%ebx,%ecx) | |
| 186 | − BODY(12,FN3,0x8f1bbcdc,%ecx,%edx,%esi,%eax,%ebx) | |
| 187 | − BODY(16,FN3,0x8f1bbcdc,%ebx,%ecx,%edx,%esi,%eax) | |
| 188 | − | |
| 189 | − addl $20, %ebp | |
| 190 | − cmpl W60(%esp), %ebp /* w60 */ | |
| 191 | − jb 3b | |
| 192 | − | |
| 193 | −4: | |
| 194 | − BODY(0,FN24,0xca62c1d6,%eax,%ebx,%ecx,%edx,%esi) | |
| 195 | − BODY(4,FN24,0xca62c1d6,%esi,%eax,%ebx,%ecx,%edx) | |
| 196 | − BODY(8,FN24,0xca62c1d6,%edx,%esi,%eax,%ebx,%ecx) | |
| 197 | − BODY(12,FN24,0xca62c1d6,%ecx,%edx,%esi,%eax,%ebx) | |
| 198 | − BODY(16,FN24,0xca62c1d6,%ebx,%ecx,%edx,%esi,%eax) | |
| 199 | − | |
| 200 | − addl $20, %ebp | |
| 201 | − cmpl W80(%esp), %ebp /* w80 */ | |
| 202 | − jb 4b | |
| 203 | − | |
| 204 | − movl STATE(%esp), %edi /* state */ | |
| 205 | − addl %eax, 0(%edi) | |
| 206 | − addl %ebx, 4(%edi) | |
| 207 | − addl %ecx, 8(%edi) | |
| 208 | − addl %edx, 12(%edi) | |
| 209 | − addl %esi, 16(%edi) | |
| 210 | − | |
| 211 | − movl EDATA(%esp), %edi /* edata */ | |
| 212 | − cmpl %edi, DATA(%esp) /* data */ | |
| 213 | − jb 0b | |
| 214 | − | |
| 215 | − /* Postlude */ | |
| 216 | − mov OLDEBX(%esp), %ebx | |
| 217 | − mov OLDESI(%esp), %esi | |
| 218 | − mov OLDEDI(%esp), %edi | |
| 219 | − addl $(STACKSIZE), %esp | |
| 220 | − popl %ebp | |
| 221 | − ret | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | |
| 10 | 8 | default: $(LIB) |
| 11 | 9 | $(LIB): $(OFILES) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -6,8 +6,6 @@ CFLAGS+= -Wa,-mregnames · 5 unmodified lines | ||
| 6 | 6 | |
| 7 | 7 | OFILES=\ |
| 8 | 8 | getcallerpc.$O\ |
| 9 | − md5block.$O\ | |
| 10 | − sha1block.$O\ | |
| 11 | 9 | tas.$O |
| 12 | 10 | |
| 13 | 11 | default: $(LIB) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -1,268 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −/* | |
| 6 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 7 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 8 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 9 | − * | |
| 10 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 11 | − * rights reserved. | |
| 12 | − * | |
| 13 | − * License to copy and use this software is granted provided that it | |
| 14 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 15 | − * Algorithm" in all material mentioning or referencing this software | |
| 16 | − * or this function. | |
| 17 | − * | |
| 18 | − * License is also granted to make and use derivative works provided | |
| 19 | − * that such works are identified as "derived from the RSA Data | |
| 20 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 21 | − * mentioning or referencing the derived work. | |
| 22 | − * | |
| 23 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 24 | − * the merchantability of this software or the suitability of this | |
| 25 | − * software forany particular purpose. It is provided "as is" | |
| 26 | − * without express or implied warranty of any kind. | |
| 27 | − * These notices must be retained in any copies of any part of this | |
| 28 | − * documentation and/or software. | |
| 29 | − */ | |
| 30 | − | |
| 31 | −/* | |
| 32 | − * Rotate ammounts used in the algorithm | |
| 33 | − */ | |
| 34 | −enum | |
| 35 | −{ | |
| 36 | − S11= 7, | |
| 37 | − S12= 12, | |
| 38 | − S13= 17, | |
| 39 | − S14= 22, | |
| 40 | − | |
| 41 | − S21= 5, | |
| 42 | − S22= 9, | |
| 43 | − S23= 14, | |
| 44 | − S24= 20, | |
| 45 | − | |
| 46 | − S31= 4, | |
| 47 | − S32= 11, | |
| 48 | − S33= 16, | |
| 49 | − S34= 23, | |
| 50 | − | |
| 51 | − S41= 6, | |
| 52 | − S42= 10, | |
| 53 | − S43= 15, | |
| 54 | − S44= 21, | |
| 55 | −}; | |
| 56 | − | |
| 57 | −static u32int md5tab[] = | |
| 58 | −{ | |
| 59 | − /* round 1 */ | |
| 60 | −/*[0]*/ 0xd76aa478, | |
| 61 | − 0xe8c7b756, | |
| 62 | − 0x242070db, | |
| 63 | − 0xc1bdceee, | |
| 64 | − 0xf57c0faf, | |
| 65 | − 0x4787c62a, | |
| 66 | − 0xa8304613, | |
| 67 | − 0xfd469501, | |
| 68 | − 0x698098d8, | |
| 69 | − 0x8b44f7af, | |
| 70 | − 0xffff5bb1, | |
| 71 | − 0x895cd7be, | |
| 72 | − 0x6b901122, | |
| 73 | − 0xfd987193, | |
| 74 | − 0xa679438e, | |
| 75 | − 0x49b40821, | |
| 76 | − | |
| 77 | − /* round 2 */ | |
| 78 | −/*[16]*/0xf61e2562, | |
| 79 | − 0xc040b340, | |
| 80 | − 0x265e5a51, | |
| 81 | − 0xe9b6c7aa, | |
| 82 | − 0xd62f105d, | |
| 83 | − 0x2441453, | |
| 84 | − 0xd8a1e681, | |
| 85 | − 0xe7d3fbc8, | |
| 86 | − 0x21e1cde6, | |
| 87 | − 0xc33707d6, | |
| 88 | − 0xf4d50d87, | |
| 89 | − 0x455a14ed, | |
| 90 | − 0xa9e3e905, | |
| 91 | − 0xfcefa3f8, | |
| 92 | − 0x676f02d9, | |
| 93 | − 0x8d2a4c8a, | |
| 94 | − | |
| 95 | − /* round 3 */ | |
| 96 | −/*[32]*/0xfffa3942, | |
| 97 | − 0x8771f681, | |
| 98 | − 0x6d9d6122, | |
| 99 | − 0xfde5380c, | |
| 100 | − 0xa4beea44, | |
| 101 | − 0x4bdecfa9, | |
| 102 | − 0xf6bb4b60, | |
| 103 | − 0xbebfbc70, | |
| 104 | − 0x289b7ec6, | |
| 105 | − 0xeaa127fa, | |
| 106 | − 0xd4ef3085, | |
| 107 | − 0x4881d05, | |
| 108 | − 0xd9d4d039, | |
| 109 | − 0xe6db99e5, | |
| 110 | − 0x1fa27cf8, | |
| 111 | − 0xc4ac5665, | |
| 112 | − | |
| 113 | − /* round 4 */ | |
| 114 | −/*[48]*/0xf4292244, | |
| 115 | − 0x432aff97, | |
| 116 | − 0xab9423a7, | |
| 117 | − 0xfc93a039, | |
| 118 | − 0x655b59c3, | |
| 119 | − 0x8f0ccc92, | |
| 120 | − 0xffeff47d, | |
| 121 | − 0x85845dd1, | |
| 122 | − 0x6fa87e4f, | |
| 123 | − 0xfe2ce6e0, | |
| 124 | − 0xa3014314, | |
| 125 | − 0x4e0811a1, | |
| 126 | − 0xf7537e82, | |
| 127 | − 0xbd3af235, | |
| 128 | − 0x2ad7d2bb, | |
| 129 | − 0xeb86d391, | |
| 130 | −}; | |
| 131 | − | |
| 132 | −static void decode(u32int*, uchar*, ulong); | |
| 133 | −extern void _md5block(uchar *p, ulong len, u32int *s); | |
| 134 | − | |
| 135 | −void | |
| 136 | −_md5block(uchar *p, ulong len, u32int *s) | |
| 137 | −{ | |
| 138 | − u32int a, b, c, d, sh; | |
| 139 | − u32int *t; | |
| 140 | − uchar *end; | |
| 141 | − u32int x[16]; | |
| 142 | − | |
| 143 | − for(end = p+len; p < end; p += 64){ | |
| 144 | − a = s[0]; | |
| 145 | − b = s[1]; | |
| 146 | − c = s[2]; | |
| 147 | − d = s[3]; | |
| 148 | − | |
| 149 | − decode(x, p, 64); | |
| 150 | − | |
| 151 | − t = md5tab; | |
| 152 | − sh = 0; | |
| 153 | − for(; sh != 16; t += 4){ | |
| 154 | − a += ((c ^ d) & b) ^ d; | |
| 155 | − a += x[sh] + t[0]; | |
| 156 | − a = (a << S11) | (a >> (32 - S11)); | |
| 157 | − a += b; | |
| 158 | − | |
| 159 | − d += ((b ^ c) & a) ^ c; | |
| 160 | − d += x[sh + 1] + t[1]; | |
| 161 | − d = (d << S12) | (d >> (32 - S12)); | |
| 162 | − d += a; | |
| 163 | − | |
| 164 | − c += ((a ^ b) & d) ^ b; | |
| 165 | − c += x[sh + 2] + t[2]; | |
| 166 | − c = (c << S13) | (c >> (32 - S13)); | |
| 167 | − c += d; | |
| 168 | − | |
| 169 | − b += ((d ^ a) & c) ^ a; | |
| 170 | − b += x[sh + 3] + t[3]; | |
| 171 | − b = (b << S14) | (b >> (32 - S14)); | |
| 172 | − b += c; | |
| 173 | − | |
| 174 | − sh += 4; | |
| 175 | − } | |
| 176 | − sh = 1; | |
| 177 | − for(; sh != 1+20*4; t += 4){ | |
| 178 | − a += ((b ^ c) & d) ^ c; | |
| 179 | − a += x[sh & 0xf] + t[0]; | |
| 180 | − a = (a << S21) | (a >> (32 - S21)); | |
| 181 | − a += b; | |
| 182 | − | |
| 183 | − d += ((a ^ b) & c) ^ b; | |
| 184 | − d += x[(sh + 5) & 0xf] + t[1]; | |
| 185 | − d = (d << S22) | (d >> (32 - S22)); | |
| 186 | − d += a; | |
| 187 | − | |
| 188 | − c += ((d ^ a) & b) ^ a; | |
| 189 | − c += x[(sh + 10) & 0xf] + t[2]; | |
| 190 | − c = (c << S23) | (c >> (32 - S23)); | |
| 191 | − c += d; | |
| 192 | − | |
| 193 | − b += ((c ^ d) & a) ^ d; | |
| 194 | − b += x[(sh + 15) & 0xf] + t[3]; | |
| 195 | − b = (b << S24) | (b >> (32 - S24)); | |
| 196 | − b += c; | |
| 197 | − | |
| 198 | − sh += 20; | |
| 199 | − } | |
| 200 | − sh = 5; | |
| 201 | − for(; sh != 5+12*4; t += 4){ | |
| 202 | − a += b ^ c ^ d; | |
| 203 | − a += x[sh & 0xf] + t[0]; | |
| 204 | − a = (a << S31) | (a >> (32 - S31)); | |
| 205 | − a += b; | |
| 206 | − | |
| 207 | − d += a ^ b ^ c; | |
| 208 | − d += x[(sh + 3) & 0xf] + t[1]; | |
| 209 | − d = (d << S32) | (d >> (32 - S32)); | |
| 210 | − d += a; | |
| 211 | − | |
| 212 | − c += d ^ a ^ b; | |
| 213 | − c += x[(sh + 6) & 0xf] + t[2]; | |
| 214 | − c = (c << S33) | (c >> (32 - S33)); | |
| 215 | − c += d; | |
| 216 | − | |
| 217 | − b += c ^ d ^ a; | |
| 218 | − b += x[(sh + 9) & 0xf] + t[3]; | |
| 219 | − b = (b << S34) | (b >> (32 - S34)); | |
| 220 | − b += c; | |
| 221 | − | |
| 222 | − sh += 12; | |
| 223 | − } | |
| 224 | − sh = 0; | |
| 225 | − for(; sh != 28*4; t += 4){ | |
| 226 | − a += c ^ (b | ~d); | |
| 227 | − a += x[sh & 0xf] + t[0]; | |
| 228 | − a = (a << S41) | (a >> (32 - S41)); | |
| 229 | − a += b; | |
| 230 | − | |
| 231 | − d += b ^ (a | ~c); | |
| 232 | − d += x[(sh + 7) & 0xf] + t[1]; | |
| 233 | − d = (d << S42) | (d >> (32 - S42)); | |
| 234 | − d += a; | |
| 235 | − | |
| 236 | − c += a ^ (d | ~b); | |
| 237 | − c += x[(sh + 14) & 0xf] + t[2]; | |
| 238 | − c = (c << S43) | (c >> (32 - S43)); | |
| 239 | − c += d; | |
| 240 | − | |
| 241 | − b += d ^ (c | ~a); | |
| 242 | − b += x[(sh + 21) & 0xf] + t[3]; | |
| 243 | − b = (b << S44) | (b >> (32 - S44)); | |
| 244 | − b += c; | |
| 245 | − | |
| 246 | − sh += 28; | |
| 247 | − } | |
| 248 | − | |
| 249 | − s[0] += a; | |
| 250 | − s[1] += b; | |
| 251 | − s[2] += c; | |
| 252 | − s[3] += d; | |
| 253 | − } | |
| 254 | −} | |
| 255 | − | |
| 256 | −/* | |
| 257 | − * decodes input (uchar) into output (u32int). Assumes len is | |
| 258 | − * a multiple of 4. | |
| 259 | − */ | |
| 260 | −static void | |
| 261 | −decode(u32int *output, uchar *input, ulong len) | |
| 262 | −{ | |
| 263 | − uchar *e; | |
| 264 | − | |
| 265 | − for(e = input+len; input < e; input += 4) | |
| 266 | − *output++ = input[0] | (input[1] << 8) | | |
| 267 | − (input[2] << 16) | (input[3] << 24); | |
| 268 | −} | |
| @@ -1,189 +0,0 @@ | ||
| 1 | −#include <u.h> | |
| 2 | −#include <libc.h> | |
| 3 | −#include <libsec.h> | |
| 4 | − | |
| 5 | −void | |
| 6 | −_sha1block(uchar *p, ulong len, u32int *s) | |
| 7 | −{ | |
| 8 | − u32int a, b, c, d, e, x; | |
| 9 | − uchar *end; | |
| 10 | − u32int *wp, *wend; | |
| 11 | − u32int w[80]; | |
| 12 | − | |
| 13 | − /* at this point, we have a multiple of 64 bytes */ | |
| 14 | − for(end = p+len; p < end;){ | |
| 15 | − a = s[0]; | |
| 16 | − b = s[1]; | |
| 17 | − c = s[2]; | |
| 18 | − d = s[3]; | |
| 19 | − e = s[4]; | |
| 20 | − | |
| 21 | − wend = w + 15; | |
| 22 | − for(wp = w; wp < wend; wp += 5){ | |
| 23 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 24 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 25 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 26 | − b = (b<<30)|(b>>2); | |
| 27 | − | |
| 28 | − wp[1] = (p[4]<<24) | (p[5]<<16) | (p[6]<<8) | p[7]; | |
| 29 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 30 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 31 | − a = (a<<30)|(a>>2); | |
| 32 | − | |
| 33 | − wp[2] = (p[8]<<24) | (p[9]<<16) | (p[10]<<8) | p[11]; | |
| 34 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 35 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 36 | − e = (e<<30)|(e>>2); | |
| 37 | − | |
| 38 | − wp[3] = (p[12]<<24) | (p[13]<<16) | (p[14]<<8) | p[15]; | |
| 39 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 40 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 41 | − d = (d<<30)|(d>>2); | |
| 42 | − | |
| 43 | − wp[4] = (p[16]<<24) | (p[17]<<16) | (p[18]<<8) | p[19]; | |
| 44 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 45 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 46 | − c = (c<<30)|(c>>2); | |
| 47 | − | |
| 48 | − p += 20; | |
| 49 | − } | |
| 50 | − | |
| 51 | − wp[0] = (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 52 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 53 | − e += 0x5a827999 + (((c^d)&b)^d); | |
| 54 | − b = (b<<30)|(b>>2); | |
| 55 | − | |
| 56 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 57 | − wp[1] = (x<<1) | (x>>31); | |
| 58 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 59 | − d += 0x5a827999 + (((b^c)&a)^c); | |
| 60 | − a = (a<<30)|(a>>2); | |
| 61 | − | |
| 62 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 63 | − wp[2] = (x<<1) | (x>>31); | |
| 64 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 65 | − c += 0x5a827999 + (((a^b)&e)^b); | |
| 66 | − e = (e<<30)|(e>>2); | |
| 67 | − | |
| 68 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 69 | − wp[3] = (x<<1) | (x>>31); | |
| 70 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 71 | − b += 0x5a827999 + (((e^a)&d)^a); | |
| 72 | − d = (d<<30)|(d>>2); | |
| 73 | − | |
| 74 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 75 | − wp[4] = (x<<1) | (x>>31); | |
| 76 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 77 | − a += 0x5a827999 + (((d^e)&c)^e); | |
| 78 | − c = (c<<30)|(c>>2); | |
| 79 | − | |
| 80 | − wp += 5; | |
| 81 | − p += 4; | |
| 82 | − | |
| 83 | − wend = w + 40; | |
| 84 | − for(; wp < wend; wp += 5){ | |
| 85 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 86 | − wp[0] = (x<<1) | (x>>31); | |
| 87 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 88 | − e += 0x6ed9eba1 + (b^c^d); | |
| 89 | − b = (b<<30)|(b>>2); | |
| 90 | − | |
| 91 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 92 | − wp[1] = (x<<1) | (x>>31); | |
| 93 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 94 | − d += 0x6ed9eba1 + (a^b^c); | |
| 95 | − a = (a<<30)|(a>>2); | |
| 96 | − | |
| 97 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 98 | − wp[2] = (x<<1) | (x>>31); | |
| 99 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 100 | − c += 0x6ed9eba1 + (e^a^b); | |
| 101 | − e = (e<<30)|(e>>2); | |
| 102 | − | |
| 103 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 104 | − wp[3] = (x<<1) | (x>>31); | |
| 105 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 106 | − b += 0x6ed9eba1 + (d^e^a); | |
| 107 | − d = (d<<30)|(d>>2); | |
| 108 | − | |
| 109 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 110 | − wp[4] = (x<<1) | (x>>31); | |
| 111 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 112 | − a += 0x6ed9eba1 + (c^d^e); | |
| 113 | − c = (c<<30)|(c>>2); | |
| 114 | − } | |
| 115 | − | |
| 116 | − wend = w + 60; | |
| 117 | − for(; wp < wend; wp += 5){ | |
| 118 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 119 | − wp[0] = (x<<1) | (x>>31); | |
| 120 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 121 | − e += 0x8f1bbcdc + ((b&c)|((b|c)&d)); | |
| 122 | − b = (b<<30)|(b>>2); | |
| 123 | − | |
| 124 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 125 | − wp[1] = (x<<1) | (x>>31); | |
| 126 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 127 | − d += 0x8f1bbcdc + ((a&b)|((a|b)&c)); | |
| 128 | − a = (a<<30)|(a>>2); | |
| 129 | − | |
| 130 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 131 | − wp[2] = (x<<1) | (x>>31); | |
| 132 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 133 | − c += 0x8f1bbcdc + ((e&a)|((e|a)&b)); | |
| 134 | − e = (e<<30)|(e>>2); | |
| 135 | − | |
| 136 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 137 | − wp[3] = (x<<1) | (x>>31); | |
| 138 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 139 | − b += 0x8f1bbcdc + ((d&e)|((d|e)&a)); | |
| 140 | − d = (d<<30)|(d>>2); | |
| 141 | − | |
| 142 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 143 | − wp[4] = (x<<1) | (x>>31); | |
| 144 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 145 | − a += 0x8f1bbcdc + ((c&d)|((c|d)&e)); | |
| 146 | − c = (c<<30)|(c>>2); | |
| 147 | − } | |
| 148 | − | |
| 149 | − wend = w + 80; | |
| 150 | − for(; wp < wend; wp += 5){ | |
| 151 | − x = wp[-3] ^ wp[-8] ^ wp[-14] ^ wp[-16]; | |
| 152 | − wp[0] = (x<<1) | (x>>31); | |
| 153 | − e += ((a<<5) | (a>>27)) + wp[0]; | |
| 154 | − e += 0xca62c1d6 + (b^c^d); | |
| 155 | − b = (b<<30)|(b>>2); | |
| 156 | − | |
| 157 | − x = wp[-2] ^ wp[-7] ^ wp[-13] ^ wp[-15]; | |
| 158 | − wp[1] = (x<<1) | (x>>31); | |
| 159 | − d += ((e<<5) | (e>>27)) + wp[1]; | |
| 160 | − d += 0xca62c1d6 + (a^b^c); | |
| 161 | − a = (a<<30)|(a>>2); | |
| 162 | − | |
| 163 | − x = wp[-1] ^ wp[-6] ^ wp[-12] ^ wp[-14]; | |
| 164 | − wp[2] = (x<<1) | (x>>31); | |
| 165 | − c += ((d<<5) | (d>>27)) + wp[2]; | |
| 166 | − c += 0xca62c1d6 + (e^a^b); | |
| 167 | − e = (e<<30)|(e>>2); | |
| 168 | − | |
| 169 | − x = wp[0] ^ wp[-5] ^ wp[-11] ^ wp[-13]; | |
| 170 | − wp[3] = (x<<1) | (x>>31); | |
| 171 | − b += ((c<<5) | (c>>27)) + wp[3]; | |
| 172 | − b += 0xca62c1d6 + (d^e^a); | |
| 173 | − d = (d<<30)|(d>>2); | |
| 174 | − | |
| 175 | − x = wp[1] ^ wp[-4] ^ wp[-10] ^ wp[-12]; | |
| 176 | − wp[4] = (x<<1) | (x>>31); | |
| 177 | − a += ((b<<5) | (b>>27)) + wp[4]; | |
| 178 | − a += 0xca62c1d6 + (c^d^e); | |
| 179 | − c = (c<<30)|(c>>2); | |
| 180 | − } | |
| 181 | − | |
| 182 | − /* save state */ | |
| 183 | − s[0] += a; | |
| 184 | − s[1] += b; | |
| 185 | − s[2] += c; | |
| 186 | − s[3] += d; | |
| 187 | − s[4] += e; | |
| 188 | − } | |
| 189 | −} | |
| @@ -4,8 +4,6 @@ LIB=../libmachdep.a · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | OFILES=\ |
| 6 | 6 | getcallerpc.$O\ |
| 7 | − md5block.$O\ | |
| 8 | − sha1block.$O\ | |
| 9 | 7 | tas.$O |
| 10 | 8 | |
| 11 | 9 | default: $(LIB) |
| @@ -1,255 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * rfc1321 requires that I include this. The code is new. The constants | |
| 3 | − * all come from the rfc (hence the copyright). We trade a table for the | |
| 4 | − * macros in rfc. The total size is a lot less. -- presotto | |
| 5 | − * | |
| 6 | − * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
| 7 | − * rights reserved. | |
| 8 | − * | |
| 9 | − * License to copy and use this software is granted provided that it | |
| 10 | − * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
| 11 | − * Algorithm" in all material mentioning or referencing this software | |
| 12 | − * or this function. | |
| 13 | − * | |
| 14 | − * License is also granted to make and use derivative works provided | |
| 15 | − * that such works are identified as "derived from the RSA Data | |
| 16 | − * Security, Inc. MD5 Message-Digest Algorithm" in all material | |
| 17 | − * mentioning or referencing the derived work. | |
| 18 | − * | |
| 19 | − * RSA Data Security, Inc. makes no representations concerning either | |
| 20 | − * the merchantability of this software or the suitability of this | |
| 21 | − * software forany particular purpose. It is provided "as is" | |
| 22 | − * without express or implied warranty of any kind. | |
| 23 | − * These notices must be retained in any copies of any part of this | |
| 24 | − * documentation and/or software. | |
| 25 | − */ | |
| 26 | −#define S11 7 | |
| 27 | −#define S12 12 | |
| 28 | −#define S13 17 | |
| 29 | −#define S14 22 | |
| 30 | − | |
| 31 | −#define S21 5 | |
| 32 | −#define S22 9 | |
| 33 | −#define S23 14 | |
| 34 | −#define S24 20 | |
| 35 | − | |
| 36 | −#define S31 4 | |
| 37 | −#define S32 11 | |
| 38 | −#define S33 16 | |
| 39 | −#define S34 23 | |
| 40 | − | |
| 41 | −#define S41 6 | |
| 42 | −#define S42 10 | |
| 43 | −#define S43 15 | |
| 44 | −#define S44 21 | |
| 45 | − | |
| 46 | −#define PAYME(x) $ ## x | |
| 47 | − | |
| 48 | −/* | |
| 49 | − * SI is data | |
| 50 | − * a += FN(B,C,D); | |
| 51 | − * a += x[sh] + t[sh]; | |
| 52 | − * a = (a << S11) | (a >> (32 - S11)); | |
| 53 | − * a += b; | |
| 54 | − */ | |
| 55 | − | |
| 56 | −#define BODY1(off,V,FN,SH,A,B,C,D)\ | |
| 57 | − FN(B,C,D)\ | |
| 58 | − leal V(A, %edi, 1), A;\ | |
| 59 | − addl off(%ebp), A;\ | |
| 60 | − roll PAYME(SH), A;\ | |
| 61 | − addl B, A;\ | |
| 62 | − | |
| 63 | −#define BODY(off,V,FN,SH,A,B,C,D)\ | |
| 64 | − FN(B,C,D)\ | |
| 65 | − leal V(A, %edi, 1), A;\ | |
| 66 | − addl (off)(%ebp), A;\ | |
| 67 | − roll PAYME(SH), A;\ | |
| 68 | − addl B,A;\ | |
| 69 | − | |
| 70 | −/* | |
| 71 | − * fn1 = ((c ^ d) & b) ^ d | |
| 72 | − */ | |
| 73 | −#define FN1(B,C,D)\ | |
| 74 | − movl C, %edi;\ | |
| 75 | − xorl D, %edi;\ | |
| 76 | − andl B, %edi;\ | |
| 77 | − xorl D, %edi;\ | |
| 78 | − | |
| 79 | −/* | |
| 80 | − * fn2 = ((b ^ c) & d) ^ c; | |
| 81 | − */ | |
| 82 | −#define FN2(B,C,D)\ | |
| 83 | − movl B, %edi;\ | |
| 84 | − xorl C, %edi;\ | |
| 85 | − andl D, %edi;\ | |
| 86 | − xorl C, %edi;\ | |
| 87 | − | |
| 88 | −/* | |
| 89 | − * fn3 = b ^ c ^ d; | |
| 90 | − */ | |
| 91 | −#define FN3(B,C,D)\ | |
| 92 | − movl B, %edi;\ | |
| 93 | − xorl C, %edi;\ | |
| 94 | − xorl D, %edi;\ | |
| 95 | − | |
| 96 | −/* | |
| 97 | − * fn4 = c ^ (b | ~d); | |
| 98 | − */ | |
| 99 | −#define FN4(B,C,D)\ | |
| 100 | − movl D, %edi;\ | |
| 101 | − xorl $-1, %edi;\ | |
| 102 | − orl B, %edi;\ | |
| 103 | − xorl C, %edi;\ | |
| 104 | − | |
| 105 | −#define STACKSIZE 20 | |
| 106 | − | |
| 107 | −#define DATA (STACKSIZE+8) | |
| 108 | −#define LEN (STACKSIZE+12) | |
| 109 | −#define STATE (STACKSIZE+16) | |
| 110 | − | |
| 111 | −#define EDATA (STACKSIZE-4) | |
| 112 | −#define OLDEBX (STACKSIZE-8) | |
| 113 | −#define OLDESI (STACKSIZE-12) | |
| 114 | −#define OLDEDI (STACKSIZE-16) | |
| 115 | − | |
| 116 | − .text | |
| 117 | − | |
| 118 | − .p2align 2,0x90 | |
| 119 | − .globl ___md5block | |
| 120 | − ___md5block: | |
| 121 | − | |
| 122 | − .p2align 2,0x90 | |
| 123 | − .globl __md5block | |
| 124 | − __md5block: | |
| 125 | − | |
| 126 | − .p2align 2,0x90 | |
| 127 | − .globl _md5block | |
| 128 | − _md5block: | |
| 129 | − | |
| 130 | − .p2align 2,0x90 | |
| 131 | − .globl md5block | |
| 132 | − md5block: | |
| 133 | − | |
| 134 | − /* Prelude */ | |
| 135 | − pushl %ebp | |
| 136 | − subl $(STACKSIZE), %esp | |
| 137 | − movl %ebx, OLDEBX(%esp) | |
| 138 | − movl %esi, OLDESI(%esp) | |
| 139 | − movl %edi, OLDEDI(%esp) | |
| 140 | − | |
| 141 | − movl DATA(%esp), %eax | |
| 142 | − addl LEN(%esp), %eax | |
| 143 | − movl %eax, EDATA(%esp) | |
| 144 | − | |
| 145 | − movl DATA(%esp), %ebp | |
| 146 | − | |
| 147 | −0: | |
| 148 | − movl STATE(%esp), %esi | |
| 149 | − movl (%esi), %eax | |
| 150 | − movl 4(%esi), %ebx | |
| 151 | − movl 8(%esi), %ecx | |
| 152 | − movl 12(%esi), %edx | |
| 153 | − | |
| 154 | − BODY1( 0*4,0xd76aa478,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 155 | − BODY1( 1*4,0xe8c7b756,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 156 | − BODY1( 2*4,0x242070db,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 157 | − BODY1( 3*4,0xc1bdceee,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 158 | − | |
| 159 | − BODY1( 4*4,0xf57c0faf,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 160 | − BODY1( 5*4,0x4787c62a,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 161 | − BODY1( 6*4,0xa8304613,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 162 | − BODY1( 7*4,0xfd469501,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 163 | − | |
| 164 | − BODY1( 8*4,0x698098d8,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 165 | − BODY1( 9*4,0x8b44f7af,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 166 | − BODY1(10*4,0xffff5bb1,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 167 | − BODY1(11*4,0x895cd7be,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 168 | − | |
| 169 | − BODY1(12*4,0x6b901122,FN1,S11,%eax,%ebx,%ecx,%edx) | |
| 170 | − BODY1(13*4,0xfd987193,FN1,S12,%edx,%eax,%ebx,%ecx) | |
| 171 | − BODY1(14*4,0xa679438e,FN1,S13,%ecx,%edx,%eax,%ebx) | |
| 172 | − BODY1(15*4,0x49b40821,FN1,S14,%ebx,%ecx,%edx,%eax) | |
| 173 | − | |
| 174 | − | |
| 175 | − BODY( 1*4,0xf61e2562,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 176 | − BODY( 6*4,0xc040b340,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 177 | − BODY(11*4,0x265e5a51,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 178 | − BODY( 0*4,0xe9b6c7aa,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 179 | − | |
| 180 | − BODY( 5*4,0xd62f105d,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 181 | − BODY(10*4,0x02441453,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 182 | − BODY(15*4,0xd8a1e681,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 183 | − BODY( 4*4,0xe7d3fbc8,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 184 | − | |
| 185 | − BODY( 9*4,0x21e1cde6,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 186 | − BODY(14*4,0xc33707d6,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 187 | − BODY( 3*4,0xf4d50d87,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 188 | − BODY( 8*4,0x455a14ed,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 189 | − | |
| 190 | − BODY(13*4,0xa9e3e905,FN2,S21,%eax,%ebx,%ecx,%edx) | |
| 191 | − BODY( 2*4,0xfcefa3f8,FN2,S22,%edx,%eax,%ebx,%ecx) | |
| 192 | − BODY( 7*4,0x676f02d9,FN2,S23,%ecx,%edx,%eax,%ebx) | |
| 193 | − BODY(12*4,0x8d2a4c8a,FN2,S24,%ebx,%ecx,%edx,%eax) | |
| 194 | − | |
| 195 | − | |
| 196 | − BODY( 5*4,0xfffa3942,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 197 | − BODY( 8*4,0x8771f681,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 198 | − BODY(11*4,0x6d9d6122,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 199 | − BODY(14*4,0xfde5380c,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 200 | − | |
| 201 | − BODY( 1*4,0xa4beea44,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 202 | − BODY( 4*4,0x4bdecfa9,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 203 | − BODY( 7*4,0xf6bb4b60,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 204 | − BODY(10*4,0xbebfbc70,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 205 | − | |
| 206 | − BODY(13*4,0x289b7ec6,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 207 | − BODY( 0*4,0xeaa127fa,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 208 | − BODY( 3*4,0xd4ef3085,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 209 | − BODY( 6*4,0x04881d05,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 210 | − | |
| 211 | − BODY( 9*4,0xd9d4d039,FN3,S31,%eax,%ebx,%ecx,%edx) | |
| 212 | − BODY(12*4,0xe6db99e5,FN3,S32,%edx,%eax,%ebx,%ecx) | |
| 213 | − BODY(15*4,0x1fa27cf8,FN3,S33,%ecx,%edx,%eax,%ebx) | |
| 214 | − BODY( 2*4,0xc4ac5665,FN3,S34,%ebx,%ecx,%edx,%eax) | |
| 215 | − | |
| 216 | − | |
| 217 | − BODY( 0*4,0xf4292244,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 218 | − BODY( 7*4,0x432aff97,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 219 | − BODY(14*4,0xab9423a7,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 220 | − BODY( 5*4,0xfc93a039,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 221 | − | |
| 222 | − BODY(12*4,0x655b59c3,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 223 | − BODY( 3*4,0x8f0ccc92,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 224 | − BODY(10*4,0xffeff47d,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 225 | − BODY( 1*4,0x85845dd1,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 226 | − | |
| 227 | − BODY( 8*4,0x6fa87e4f,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 228 | − BODY(15*4,0xfe2ce6e0,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 229 | − BODY( 6*4,0xa3014314,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 230 | − BODY(13*4,0x4e0811a1,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 231 | − | |
| 232 | − BODY( 4*4,0xf7537e82,FN4,S41,%eax,%ebx,%ecx,%edx) | |
| 233 | − BODY(11*4,0xbd3af235,FN4,S42,%edx,%eax,%ebx,%ecx) | |
| 234 | − BODY( 2*4,0x2ad7d2bb,FN4,S43,%ecx,%edx,%eax,%ebx) | |
| 235 | − BODY( 9*4,0xeb86d391,FN4,S44,%ebx,%ecx,%edx,%eax) | |
| 236 | − | |
| 237 | − addl $(16*4), %ebp | |
| 238 | − movl STATE(%esp), %edi | |
| 239 | − addl %eax,0(%edi) | |
| 240 | − addl %ebx,4(%edi) | |
| 241 | − addl %ecx,8(%edi) | |
| 242 | − addl %edx,12(%edi) | |
| 243 | − | |
| 244 | − movl EDATA(%esp), %edi | |
| 245 | − cmpl %edi, %ebp | |
| 246 | − jb 0b | |
| 247 | − | |
| 248 | − /* Postlude */ | |
| 249 | − movl OLDEBX(%esp), %ebx | |
| 250 | − movl OLDESI(%esp), %esi | |
| 251 | − movl OLDEDI(%esp), %edi | |
| 252 | − addl $(STACKSIZE), %esp | |
| 253 | − popl %ebp | |
| 254 | − ret | |
| 255 | − | |
| @@ -1,231 +0,0 @@ | ||
| 1 | −.text | |
| 2 | − | |
| 3 | −.p2align 2,0x90 | |
| 4 | −.globl ___sha1block | |
| 5 | −___sha1block: | |
| 6 | − jmp sha1block | |
| 7 | − | |
| 8 | −.p2align 2,0x90 | |
| 9 | −.globl __sha1block | |
| 10 | −__sha1block: | |
| 11 | − jmp sha1block | |
| 12 | − | |
| 13 | −.p2align 2,0x90 | |
| 14 | −.globl _sha1block | |
| 15 | −_sha1block: | |
| 16 | − jmp sha1block | |
| 17 | − | |
| 18 | −.p2align 2,0x90 | |
| 19 | −.globl sha1block | |
| 20 | −sha1block: | |
| 21 | − | |
| 22 | −/* x = (wp[off-f] ^ wp[off-8] ^ wp[off-14] ^ wp[off-16]) <<< 1; | |
| 23 | − * wp[off] = x; | |
| 24 | − * x += A <<< 5; | |
| 25 | − * E += 0xca62c1d6 + x; | |
| 26 | − * x = FN(B,C,D); | |
| 27 | − * E += x; | |
| 28 | − * B >>> 2 | |
| 29 | − */ | |
| 30 | −#define BSWAPDI BYTE $0x0f; BYTE $0xcf; | |
| 31 | − | |
| 32 | −#define BODY(off,FN,V,A,B,C,D,E)\ | |
| 33 | − movl (off-64)(%ebp), %edi;\ | |
| 34 | − xorl (off-56)(%ebp), %edi;\ | |
| 35 | − xorl (off-32)(%ebp), %edi;\ | |
| 36 | − xorl (off-12)(%ebp), %edi;\ | |
| 37 | − roll $1, %edi;\ | |
| 38 | − movl %edi, off(%ebp);\ | |
| 39 | − leal V(%edi, E, 1), E;\ | |
| 40 | − movl A, %edi;\ | |
| 41 | − roll $5, %edi;\ | |
| 42 | − addl %edi, E;\ | |
| 43 | − FN(B,C,D)\ | |
| 44 | − addl %edi, E;\ | |
| 45 | − rorl $2, B;\ | |
| 46 | − | |
| 47 | −#define BODY0(off,FN,V,A,B,C,D,E)\ | |
| 48 | − movl off(%ebx), %edi;\ | |
| 49 | − bswap %edi;\ | |
| 50 | − movl %edi, off(%ebp);\ | |
| 51 | − leal V(%edi,E,1), E;\ | |
| 52 | − movl A, %edi;\ | |
| 53 | − roll $5,%edi;\ | |
| 54 | − addl %edi,E;\ | |
| 55 | − FN(B,C,D)\ | |
| 56 | − addl %edi,E;\ | |
| 57 | − rorl $2,B;\ | |
| 58 | − | |
| 59 | −/* | |
| 60 | − * fn1 = (((C^D)&B)^D); | |
| 61 | − */ | |
| 62 | −#define FN1(B,C,D)\ | |
| 63 | − movl C, %edi;\ | |
| 64 | − xorl D, %edi;\ | |
| 65 | − andl B, %edi;\ | |
| 66 | − xorl D, %edi;\ | |
| 67 | − | |
| 68 | −/* | |
| 69 | − * fn24 = B ^ C ^ D | |
| 70 | − */ | |
| 71 | −#define FN24(B,C,D)\ | |
| 72 | − movl B, %edi;\ | |
| 73 | − xorl C, %edi;\ | |
| 74 | − xorl D, %edi;\ | |
| 75 | − | |
| 76 | −/* | |
| 77 | − * fn3 = ((B ^ C) & (D ^= B)) ^ B | |
| 78 | − * D ^= B to restore D | |
| 79 | − */ | |
| 80 | −#define FN3(B,C,D)\ | |
| 81 | − movl B, %edi;\ | |
| 82 | − xorl C, %edi;\ | |
| 83 | − xorl B, D;\ | |
| 84 | − andl D, %edi;\ | |
| 85 | − xorl B, %edi;\ | |
| 86 | − xorl B, D;\ | |
| 87 | − | |
| 88 | −/* | |
| 89 | − * stack offsets | |
| 90 | − * void sha1block(uchar *DATA, int LEN, ulong *STATE) | |
| 91 | − */ | |
| 92 | −#define STACKSIZE (48+80*4) | |
| 93 | −#define DATA (STACKSIZE+8) | |
| 94 | −#define LEN (STACKSIZE+12) | |
| 95 | −#define STATE (STACKSIZE+16) | |
| 96 | − | |
| 97 | −/* | |
| 98 | − * stack offsets for locals | |
| 99 | − * ulong w[80]; | |
| 100 | − * uchar *edata; | |
| 101 | − * ulong *w15, *w40, *w60, *w80; | |
| 102 | − * register local | |
| 103 | − * ulong *wp = %ebp | |
| 104 | − * ulong a = eax, b = ebx, c = ecx, d = edx, e = esi | |
| 105 | − * ulong tmp = edi | |
| 106 | − */ | |
| 107 | −#define WARRAY (STACKSIZE-4-(80*4)) | |
| 108 | −#define TMP1 (STACKSIZE-8-(80*4)) | |
| 109 | −#define TMP2 (STACKSIZE-12-(80*4)) | |
| 110 | −#define W15 (STACKSIZE-16-(80*4)) | |
| 111 | −#define W40 (STACKSIZE-20-(80*4)) | |
| 112 | −#define W60 (STACKSIZE-24-(80*4)) | |
| 113 | −#define W80 (STACKSIZE-28-(80*4)) | |
| 114 | −#define EDATA (STACKSIZE-32-(80*4)) | |
| 115 | −#define OLDEBX (STACKSIZE-36-(80*4)) | |
| 116 | −#define OLDESI (STACKSIZE-40-(80*4)) | |
| 117 | −#define OLDEDI (STACKSIZE-44-(80*4)) | |
| 118 | − | |
| 119 | − /* Prelude */ | |
| 120 | − pushl %ebp | |
| 121 | − subl $(STACKSIZE), %esp | |
| 122 | − | |
| 123 | − mov %ebx, OLDEBX(%esp) | |
| 124 | − mov %esi, OLDESI(%esp) | |
| 125 | − mov %edi, OLDEDI(%esp) | |
| 126 | − | |
| 127 | − movl DATA(%esp), %eax | |
| 128 | − addl LEN(%esp), %eax | |
| 129 | − movl %eax, EDATA(%esp) | |
| 130 | − | |
| 131 | − leal (WARRAY+15*4)(%esp), %edi /* aw15 */ | |
| 132 | − movl %edi, W15(%esp) | |
| 133 | − leal (WARRAY+40*4)(%esp), %edx /* aw40 */ | |
| 134 | − movl %edx, W40(%esp) | |
| 135 | − leal (WARRAY+60*4)(%esp), %ecx /* aw60 */ | |
| 136 | − movl %ecx, W60(%esp) | |
| 137 | − leal (WARRAY+80*4)(%esp), %edi /* aw80 */ | |
| 138 | − movl %edi, W80(%esp) | |
| 139 | − | |
| 140 | −0: | |
| 141 | − leal WARRAY(%esp), %ebp /* warray */ | |
| 142 | − | |
| 143 | − movl STATE(%esp), %edi /* state */ | |
| 144 | − movl (%edi),%eax | |
| 145 | − movl 4(%edi),%ebx | |
| 146 | − movl %ebx, TMP1(%esp) /* tmp1 */ | |
| 147 | − movl 8(%edi), %ecx | |
| 148 | − movl 12(%edi), %edx | |
| 149 | − movl 16(%edi), %esi | |
| 150 | − | |
| 151 | − movl DATA(%esp), %ebx /* data */ | |
| 152 | − | |
| 153 | −1: | |
| 154 | − BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi) | |
| 155 | − movl %esi,TMP2(%esp) | |
| 156 | − BODY0(4,FN1,0x5a827999,%esi,%eax,TMP1(%esp),%ecx,%edx) | |
| 157 | − movl TMP1(%esp),%esi | |
| 158 | − BODY0(8,FN1,0x5a827999,%edx,TMP2(%esp),%eax,%esi,%ecx) | |
| 159 | − BODY0(12,FN1,0x5a827999,%ecx,%edx,TMP2(%esp),%eax,%esi) | |
| 160 | − movl %esi,TMP1(%esp) | |
| 161 | − BODY0(16,FN1,0x5a827999,%esi,%ecx,%edx,TMP2(%esp),%eax) | |
| 162 | − movl TMP2(%esp),%esi | |
| 163 | − | |
| 164 | − addl $20, %ebx | |
| 165 | − addl $20, %ebp | |
| 166 | − cmpl W15(%esp), %ebp /* w15 */ | |
| 167 | − jb 1b | |
| 168 | − | |
| 169 | − BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi) | |
| 170 | − addl $4, %ebx | |
| 171 | − MOVL %ebx, DATA(%esp) /* data */ | |
| 172 | − MOVL TMP1(%esp),%ebx | |
| 173 | − | |
| 174 | − BODY(4,FN1,0x5a827999,%esi,%eax,%ebx,%ecx,%edx) | |
| 175 | − BODY(8,FN1,0x5a827999,%edx,%esi,%eax,%ebx,%ecx) | |
| 176 | − BODY(12,FN1,0x5a827999,%ecx,%edx,%esi,%eax,%ebx) | |
| 177 | − BODY(16,FN1,0x5a827999,%ebx,%ecx,%edx,%esi,%eax) | |
| 178 | − | |
| 179 | − addl $20, %ebp | |
| 180 | − | |
| 181 | −2: | |
| 182 | − BODY(0,FN24,0x6ed9eba1,%eax,%ebx,%ecx,%edx,%esi) | |
| 183 | − BODY(4,FN24,0x6ed9eba1,%esi,%eax,%ebx,%ecx,%edx) | |
| 184 | − BODY(8,FN24,0x6ed9eba1,%edx,%esi,%eax,%ebx,%ecx) | |
| 185 | − BODY(12,FN24,0x6ed9eba1,%ecx,%edx,%esi,%eax,%ebx) | |
| 186 | − BODY(16,FN24,0x6ed9eba1,%ebx,%ecx,%edx,%esi,%eax) | |
| 187 | − | |
| 188 | − addl $20,%ebp | |
| 189 | − cmpl W40(%esp), %ebp | |
| 190 | − jb 2b | |
| 191 | − | |
| 192 | −3: | |
| 193 | − BODY(0,FN3,0x8f1bbcdc,%eax,%ebx,%ecx,%edx,%esi) | |
| 194 | − BODY(4,FN3,0x8f1bbcdc,%esi,%eax,%ebx,%ecx,%edx) | |
| 195 | − BODY(8,FN3,0x8f1bbcdc,%edx,%esi,%eax,%ebx,%ecx) | |
| 196 | − BODY(12,FN3,0x8f1bbcdc,%ecx,%edx,%esi,%eax,%ebx) | |
| 197 | − BODY(16,FN3,0x8f1bbcdc,%ebx,%ecx,%edx,%esi,%eax) | |
| 198 | − | |
| 199 | − addl $20, %ebp | |
| 200 | − cmpl W60(%esp), %ebp /* w60 */ | |
| 201 | − jb 3b | |
| 202 | − | |
| 203 | −4: | |
| 204 | − BODY(0,FN24,0xca62c1d6,%eax,%ebx,%ecx,%edx,%esi) | |
| 205 | − BODY(4,FN24,0xca62c1d6,%esi,%eax,%ebx,%ecx,%edx) | |
| 206 | − BODY(8,FN24,0xca62c1d6,%edx,%esi,%eax,%ebx,%ecx) | |
| 207 | − BODY(12,FN24,0xca62c1d6,%ecx,%edx,%esi,%eax,%ebx) | |
| 208 | − BODY(16,FN24,0xca62c1d6,%ebx,%ecx,%edx,%esi,%eax) | |
| 209 | − | |
| 210 | − addl $20, %ebp | |
| 211 | − cmpl W80(%esp), %ebp /* w80 */ | |
| 212 | − jb 4b | |
| 213 | − | |
| 214 | − movl STATE(%esp), %edi /* state */ | |
| 215 | − addl %eax, 0(%edi) | |
| 216 | − addl %ebx, 4(%edi) | |
| 217 | − addl %ecx, 8(%edi) | |
| 218 | − addl %edx, 12(%edi) | |
| 219 | − addl %esi, 16(%edi) | |
| 220 | − | |
| 221 | − movl EDATA(%esp), %edi /* edata */ | |
| 222 | − cmpl %edi, DATA(%esp) /* data */ | |
| 223 | − jb 0b | |
| 224 | − | |
| 225 | − /* Postlude */ | |
| 226 | − mov OLDEBX(%esp), %ebx | |
| 227 | − mov OLDESI(%esp), %esi | |
| 228 | − mov OLDEDI(%esp), %edi | |
| 229 | − addl $(STACKSIZE), %esp | |
| 230 | − popl %ebp | |
| 231 | − ret | |