1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/pgo/js-input/crypto-md5.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,336 @@ 1.4 +<!DOCTYPE html> 1.5 +<head> 1.6 +<!-- 1.7 + Copyright (C) 2007 Apple Inc. All rights reserved. 1.8 + 1.9 + Redistribution and use in source and binary forms, with or without 1.10 + modification, are permitted provided that the following conditions 1.11 + are met: 1.12 + 1. Redistributions of source code must retain the above copyright 1.13 + notice, this list of conditions and the following disclaimer. 1.14 + 2. Redistributions in binary form must reproduce the above copyright 1.15 + notice, this list of conditions and the following disclaimer in the 1.16 + documentation and/or other materials provided with the distribution. 1.17 + 1.18 + THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 1.19 + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.20 + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1.21 + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 1.22 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 1.26 + OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.27 + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.28 + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.29 +--> 1.30 + 1.31 +<title>SunSpider crypto-md5</title> 1.32 + 1.33 +</head> 1.34 + 1.35 +<body> 1.36 +<h3>crypto-md5</h3> 1.37 +<div id="console"> 1.38 +</div> 1.39 + 1.40 +<script> 1.41 + 1.42 +var _sunSpiderStartDate = new Date(); 1.43 + 1.44 +/* 1.45 + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message 1.46 + * Digest Algorithm, as defined in RFC 1321. 1.47 + * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. 1.48 + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 1.49 + * Distributed under the BSD License 1.50 + * See http://pajhome.org.uk/crypt/md5 for more info. 1.51 + */ 1.52 + 1.53 +/* 1.54 + * Configurable variables. You may need to tweak these to be compatible with 1.55 + * the server-side, but the defaults work in most cases. 1.56 + */ 1.57 +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ 1.58 +var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ 1.59 +var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ 1.60 + 1.61 +/* 1.62 + * These are the functions you'll usually want to call 1.63 + * They take string arguments and return either hex or base-64 encoded strings 1.64 + */ 1.65 +function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} 1.66 +function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} 1.67 +function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} 1.68 +function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } 1.69 +function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } 1.70 +function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } 1.71 + 1.72 +/* 1.73 + * Perform a simple self-test to see if the VM is working 1.74 + */ 1.75 +function md5_vm_test() 1.76 +{ 1.77 + return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; 1.78 +} 1.79 + 1.80 +/* 1.81 + * Calculate the MD5 of an array of little-endian words, and a bit length 1.82 + */ 1.83 +function core_md5(x, len) 1.84 +{ 1.85 + /* append padding */ 1.86 + x[len >> 5] |= 0x80 << ((len) % 32); 1.87 + x[(((len + 64) >>> 9) << 4) + 14] = len; 1.88 + 1.89 + var a = 1732584193; 1.90 + var b = -271733879; 1.91 + var c = -1732584194; 1.92 + var d = 271733878; 1.93 + 1.94 + for(var i = 0; i < x.length; i += 16) 1.95 + { 1.96 + var olda = a; 1.97 + var oldb = b; 1.98 + var oldc = c; 1.99 + var oldd = d; 1.100 + 1.101 + a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); 1.102 + d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); 1.103 + c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); 1.104 + b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); 1.105 + a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); 1.106 + d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); 1.107 + c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); 1.108 + b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); 1.109 + a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); 1.110 + d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); 1.111 + c = md5_ff(c, d, a, b, x[i+10], 17, -42063); 1.112 + b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); 1.113 + a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); 1.114 + d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); 1.115 + c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); 1.116 + b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); 1.117 + 1.118 + a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); 1.119 + d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); 1.120 + c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); 1.121 + b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); 1.122 + a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); 1.123 + d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); 1.124 + c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); 1.125 + b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); 1.126 + a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); 1.127 + d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); 1.128 + c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); 1.129 + b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); 1.130 + a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); 1.131 + d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); 1.132 + c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); 1.133 + b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); 1.134 + 1.135 + a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); 1.136 + d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); 1.137 + c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); 1.138 + b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); 1.139 + a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); 1.140 + d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); 1.141 + c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); 1.142 + b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); 1.143 + a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); 1.144 + d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); 1.145 + c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); 1.146 + b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); 1.147 + a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); 1.148 + d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); 1.149 + c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); 1.150 + b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); 1.151 + 1.152 + a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); 1.153 + d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); 1.154 + c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); 1.155 + b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); 1.156 + a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); 1.157 + d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); 1.158 + c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); 1.159 + b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); 1.160 + a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); 1.161 + d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); 1.162 + c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); 1.163 + b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); 1.164 + a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); 1.165 + d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); 1.166 + c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); 1.167 + b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); 1.168 + 1.169 + a = safe_add(a, olda); 1.170 + b = safe_add(b, oldb); 1.171 + c = safe_add(c, oldc); 1.172 + d = safe_add(d, oldd); 1.173 + } 1.174 + return Array(a, b, c, d); 1.175 + 1.176 +} 1.177 + 1.178 +/* 1.179 + * These functions implement the four basic operations the algorithm uses. 1.180 + */ 1.181 +function md5_cmn(q, a, b, x, s, t) 1.182 +{ 1.183 + return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); 1.184 +} 1.185 +function md5_ff(a, b, c, d, x, s, t) 1.186 +{ 1.187 + return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); 1.188 +} 1.189 +function md5_gg(a, b, c, d, x, s, t) 1.190 +{ 1.191 + return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); 1.192 +} 1.193 +function md5_hh(a, b, c, d, x, s, t) 1.194 +{ 1.195 + return md5_cmn(b ^ c ^ d, a, b, x, s, t); 1.196 +} 1.197 +function md5_ii(a, b, c, d, x, s, t) 1.198 +{ 1.199 + return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); 1.200 +} 1.201 + 1.202 +/* 1.203 + * Calculate the HMAC-MD5, of a key and some data 1.204 + */ 1.205 +function core_hmac_md5(key, data) 1.206 +{ 1.207 + var bkey = str2binl(key); 1.208 + if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); 1.209 + 1.210 + var ipad = Array(16), opad = Array(16); 1.211 + for(var i = 0; i < 16; i++) 1.212 + { 1.213 + ipad[i] = bkey[i] ^ 0x36363636; 1.214 + opad[i] = bkey[i] ^ 0x5C5C5C5C; 1.215 + } 1.216 + 1.217 + var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); 1.218 + return core_md5(opad.concat(hash), 512 + 128); 1.219 +} 1.220 + 1.221 +/* 1.222 + * Add integers, wrapping at 2^32. This uses 16-bit operations internally 1.223 + * to work around bugs in some JS interpreters. 1.224 + */ 1.225 +function safe_add(x, y) 1.226 +{ 1.227 + var lsw = (x & 0xFFFF) + (y & 0xFFFF); 1.228 + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 1.229 + return (msw << 16) | (lsw & 0xFFFF); 1.230 +} 1.231 + 1.232 +/* 1.233 + * Bitwise rotate a 32-bit number to the left. 1.234 + */ 1.235 +function bit_rol(num, cnt) 1.236 +{ 1.237 + return (num << cnt) | (num >>> (32 - cnt)); 1.238 +} 1.239 + 1.240 +/* 1.241 + * Convert a string to an array of little-endian words 1.242 + * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. 1.243 + */ 1.244 +function str2binl(str) 1.245 +{ 1.246 + var bin = Array(); 1.247 + var mask = (1 << chrsz) - 1; 1.248 + for(var i = 0; i < str.length * chrsz; i += chrsz) 1.249 + bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); 1.250 + return bin; 1.251 +} 1.252 + 1.253 +/* 1.254 + * Convert an array of little-endian words to a string 1.255 + */ 1.256 +function binl2str(bin) 1.257 +{ 1.258 + var str = ""; 1.259 + var mask = (1 << chrsz) - 1; 1.260 + for(var i = 0; i < bin.length * 32; i += chrsz) 1.261 + str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); 1.262 + return str; 1.263 +} 1.264 + 1.265 +/* 1.266 + * Convert an array of little-endian words to a hex string. 1.267 + */ 1.268 +function binl2hex(binarray) 1.269 +{ 1.270 + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 1.271 + var str = ""; 1.272 + for(var i = 0; i < binarray.length * 4; i++) 1.273 + { 1.274 + str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + 1.275 + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); 1.276 + } 1.277 + return str; 1.278 +} 1.279 + 1.280 +/* 1.281 + * Convert an array of little-endian words to a base-64 string 1.282 + */ 1.283 +function binl2b64(binarray) 1.284 +{ 1.285 + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 1.286 + var str = ""; 1.287 + for(var i = 0; i < binarray.length * 4; i += 3) 1.288 + { 1.289 + var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) 1.290 + | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) 1.291 + | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); 1.292 + for(var j = 0; j < 4; j++) 1.293 + { 1.294 + if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; 1.295 + else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); 1.296 + } 1.297 + } 1.298 + return str; 1.299 +} 1.300 + 1.301 +var plainText = "Rebellious subjects, enemies to peace,\n\ 1.302 +Profaners of this neighbour-stained steel,--\n\ 1.303 +Will they not hear? What, ho! you men, you beasts,\n\ 1.304 +That quench the fire of your pernicious rage\n\ 1.305 +With purple fountains issuing from your veins,\n\ 1.306 +On pain of torture, from those bloody hands\n\ 1.307 +Throw your mistemper'd weapons to the ground,\n\ 1.308 +And hear the sentence of your moved prince.\n\ 1.309 +Three civil brawls, bred of an airy word,\n\ 1.310 +By thee, old Capulet, and Montague,\n\ 1.311 +Have thrice disturb'd the quiet of our streets,\n\ 1.312 +And made Verona's ancient citizens\n\ 1.313 +Cast by their grave beseeming ornaments,\n\ 1.314 +To wield old partisans, in hands as old,\n\ 1.315 +Canker'd with peace, to part your canker'd hate:\n\ 1.316 +If ever you disturb our streets again,\n\ 1.317 +Your lives shall pay the forfeit of the peace.\n\ 1.318 +For this time, all the rest depart away:\n\ 1.319 +You Capulet; shall go along with me:\n\ 1.320 +And, Montague, come you this afternoon,\n\ 1.321 +To know our further pleasure in this case,\n\ 1.322 +To old Free-town, our common judgment-place.\n\ 1.323 +Once more, on pain of death, all men depart." 1.324 + 1.325 +for (var i = 0; i <4; i++) { 1.326 + plainText += plainText; 1.327 +} 1.328 + 1.329 +var md5Output = hex_md5(plainText); 1.330 + 1.331 + 1.332 +var _sunSpiderInterval = new Date() - _sunSpiderStartDate; 1.333 + 1.334 +document.getElementById("console").innerHTML = _sunSpiderInterval; 1.335 +</script> 1.336 + 1.337 + 1.338 +</body> 1.339 +</html>