Diffstat (limited to 'frontend/gamma/js/Clipperz/Crypto/BigInt.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/BigInt.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/BigInt.js b/frontend/gamma/js/Clipperz/Crypto/BigInt.js index d4d05d2..41483a3 100644 --- a/frontend/gamma/js/Clipperz/Crypto/BigInt.js +++ b/frontend/gamma/js/Clipperz/Crypto/BigInt.js | |||
@@ -1,72 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } | 27 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } |
31 | 28 | ||
32 | //############################################################################# | 29 | //############################################################################# |
33 | //Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js | 30 | //Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js |
34 | //############################################################################# | 31 | //############################################################################# |
35 | 32 | ||
36 | 33 | ||
37 | //////////////////////////////////////////////////////////////////////////////////////// | 34 | //////////////////////////////////////////////////////////////////////////////////////// |
38 | // Big Integer Library v. 5.0 | 35 | // Big Integer Library v. 5.0 |
39 | // Created 2000, last modified 2006 | 36 | // Created 2000, last modified 2006 |
40 | // Leemon Baird | 37 | // Leemon Baird |
41 | // www.leemon.com | 38 | // www.leemon.com |
42 | // | 39 | // |
43 | // This file is public domain. You can use it for any purpose without restriction. | 40 | // This file is public domain. You can use it for any purpose without restriction. |
44 | // I do not guarantee that it is correct, so use it at your own risk. If you use | 41 | // I do not guarantee that it is correct, so use it at your own risk. If you use |
45 | // it for something interesting, I'd appreciate hearing about it. If you find | 42 | // it for something interesting, I'd appreciate hearing about it. If you find |
46 | // any bugs or make any improvements, I'd appreciate hearing about those too. | 43 | // any bugs or make any improvements, I'd appreciate hearing about those too. |
47 | // It would also be nice if my name and address were left in the comments. | 44 | // It would also be nice if my name and address were left in the comments. |
48 | // But none of that is required. | 45 | // But none of that is required. |
49 | // | 46 | // |
50 | // This code defines a bigInt library for arbitrary-precision integers. | 47 | // This code defines a bigInt library for arbitrary-precision integers. |
51 | // A bigInt is an array of integers storing the value in chunks of bpe bits, | 48 | // A bigInt is an array of integers storing the value in chunks of bpe bits, |
52 | // little endian (buff[0] is the least significant word). | 49 | // little endian (buff[0] is the least significant word). |
53 | // Negative bigInts are stored two's complement. | 50 | // Negative bigInts are stored two's complement. |
54 | // Some functions assume their parameters have at least one leading zero element. | 51 | // Some functions assume their parameters have at least one leading zero element. |
55 | // Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, | 52 | // Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, |
56 | // so the caller must make sure overflow won't happen. | 53 | // so the caller must make sure overflow won't happen. |
57 | // For each function where a parameter is modified, that same | 54 | // For each function where a parameter is modified, that same |
58 | // variable must not be used as another argument too. | 55 | // variable must not be used as another argument too. |
59 | // So, you cannot square x by doing multMod_(x,x,n). | 56 | // So, you cannot square x by doing multMod_(x,x,n). |
60 | // You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). | 57 | // You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). |
61 | // | 58 | // |
62 | // These functions are designed to avoid frequent dynamic memory allocation in the inner loop. | 59 | // These functions are designed to avoid frequent dynamic memory allocation in the inner loop. |
63 | // For most functions, if it needs a BigInt as a local variable it will actually use | 60 | // For most functions, if it needs a BigInt as a local variable it will actually use |
64 | // a global, and will only allocate to it when it's not the right size. This ensures | 61 | // a global, and will only allocate to it when it's not the right size. This ensures |
65 | // that when a function is called repeatedly with same-sized parameters, it only allocates | 62 | // that when a function is called repeatedly with same-sized parameters, it only allocates |
66 | // memory on the first call. | 63 | // memory on the first call. |
67 | // | 64 | // |
68 | // Note that for cryptographic purposes, the calls to Math.random() must | 65 | // Note that for cryptographic purposes, the calls to Math.random() must |
69 | // be replaced with calls to a better pseudorandom number generator. | 66 | // be replaced with calls to a better pseudorandom number generator. |
70 | // | 67 | // |
71 | // In the following, "bigInt" means a bigInt with at least one leading zero element, | 68 | // In the following, "bigInt" means a bigInt with at least one leading zero element, |
72 | // and "integer" means a nonnegative integer less than radix. In some cases, integer | 69 | // and "integer" means a nonnegative integer less than radix. In some cases, integer |