OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2003-2005 Tom Wu | 2 * Copyright (c) 2003-2005 Tom Wu |
3 * All Rights Reserved. | 3 * All Rights Reserved. |
4 * | 4 * |
5 * Permission is hereby granted, free of charge, to any person obtaining | 5 * Permission is hereby granted, free of charge, to any person obtaining |
6 * a copy of this software and associated documentation files (the | 6 * a copy of this software and associated documentation files (the |
7 * "Software"), to deal in the Software without restriction, including | 7 * "Software"), to deal in the Software without restriction, including |
8 * without limitation the rights to use, copy, modify, merge, publish, | 8 * without limitation the rights to use, copy, modify, merge, publish, |
9 * distribute, sublicense, and/or sell copies of the Software, and to | 9 * distribute, sublicense, and/or sell copies of the Software, and to |
10 * permit persons to whom the Software is furnished to do so, subject to | 10 * permit persons to whom the Software is furnished to do so, subject to |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 function rng_seed_int(x) { | 1399 function rng_seed_int(x) { |
1400 rng_pool[rng_pptr++] ^= x & 255; | 1400 rng_pool[rng_pptr++] ^= x & 255; |
1401 rng_pool[rng_pptr++] ^= (x >> 8) & 255; | 1401 rng_pool[rng_pptr++] ^= (x >> 8) & 255; |
1402 rng_pool[rng_pptr++] ^= (x >> 16) & 255; | 1402 rng_pool[rng_pptr++] ^= (x >> 16) & 255; |
1403 rng_pool[rng_pptr++] ^= (x >> 24) & 255; | 1403 rng_pool[rng_pptr++] ^= (x >> 24) & 255; |
1404 if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; | 1404 if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; |
1405 } | 1405 } |
1406 | 1406 |
1407 // Mix in the current time (w/milliseconds) into the pool | 1407 // Mix in the current time (w/milliseconds) into the pool |
1408 function rng_seed_time() { | 1408 function rng_seed_time() { |
1409 // Use pre-computed date to avoid making the benchmark | 1409 // Use pre-computed date to avoid making the benchmark |
1410 // results dependent on the current date. | 1410 // results dependent on the current date. |
1411 rng_seed_int(1122926989487); | 1411 rng_seed_int(1122926989487); |
1412 } | 1412 } |
1413 | 1413 |
1414 // Initialize the pool with junk if needed. | 1414 // Initialize the pool with junk if needed. |
1415 if(rng_pool == null) { | 1415 if(rng_pool == null) { |
1416 rng_pool = new Array(); | 1416 rng_pool = new Array(); |
1417 rng_pptr = 0; | 1417 rng_pptr = 0; |
1418 var t; | 1418 var t; |
1419 while(rng_pptr < rng_psize) { // extract some randomness from Math.random() | 1419 while(rng_pptr < rng_psize) { // extract some randomness from Math.random() |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 | 1689 |
1690 function decrypt() { | 1690 function decrypt() { |
1691 var RSA = new RSAKey(); | 1691 var RSA = new RSAKey(); |
1692 RSA.setPublic(nValue, eValue); | 1692 RSA.setPublic(nValue, eValue); |
1693 RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value,
coeffValue); | 1693 RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value,
coeffValue); |
1694 var decrypted = RSA.decrypt(encrypted); | 1694 var decrypted = RSA.decrypt(encrypted); |
1695 if (decrypted != TEXT) { | 1695 if (decrypted != TEXT) { |
1696 throw new Error("Crypto operation failed"); | 1696 throw new Error("Crypto operation failed"); |
1697 } | 1697 } |
1698 } | 1698 } |
OLD | NEW |