| 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 13 matching lines...) Expand all Loading... |
| 24 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 24 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 25 * | 25 * |
| 26 * In addition, the following condition applies: | 26 * In addition, the following condition applies: |
| 27 * | 27 * |
| 28 * All redistributions must retain an intact copy of this copyright notice | 28 * All redistributions must retain an intact copy of this copyright notice |
| 29 * and disclaimer. | 29 * and disclaimer. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 | 32 |
| 33 // The code has been adapted for use as a benchmark by Google. | 33 // The code has been adapted for use as a benchmark by Google. |
| 34 var Crypto = new BenchmarkSuite('Crypto', 110465, [ | 34 var Crypto = new BenchmarkSuite('Crypto', 266181, [ |
| 35 new Benchmark("Encrypt", encrypt), | 35 new Benchmark("Encrypt", encrypt), |
| 36 new Benchmark("Decrypt", decrypt) | 36 new Benchmark("Decrypt", decrypt) |
| 37 ]); | 37 ]); |
| 38 | 38 |
| 39 | 39 |
| 40 // Basic JavaScript BN library - subset useful for RSA encryption. | 40 // Basic JavaScript BN library - subset useful for RSA encryption. |
| 41 | 41 |
| 42 // Bits per digit | 42 // Bits per digit |
| 43 var dbits; | 43 var dbits; |
| 44 var BI_DB; | 44 var BI_DB; |
| (...skipping 1644 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 |