summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js b/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js
index e91e823..f91c7e9 100644
--- a/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js
+++ b/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js
@@ -1,72 +1,69 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer 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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } 27if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; }
31 28
32if (typeof(Leemon) == 'undefined') { Leemon = {}; } 29if (typeof(Leemon) == 'undefined') { Leemon = {}; }
33if (typeof(Baird.Crypto) == 'undefined') { Baird.Crypto = {}; } 30if (typeof(Baird.Crypto) == 'undefined') { Baird.Crypto = {}; }
34if (typeof(Baird.Crypto.BigInt) == 'undefined') { Baird.Crypto.BigInt = {}; } 31if (typeof(Baird.Crypto.BigInt) == 'undefined') { Baird.Crypto.BigInt = {}; }
35 32
36 33
37//############################################################################# 34//#############################################################################
38 //Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js 35 //Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js
39//############################################################################# 36//#############################################################################
40 37
41//////////////////////////////////////////////////////////////////////////////////////// 38////////////////////////////////////////////////////////////////////////////////////////
42// Big Integer Library v. 5.0 39// Big Integer Library v. 5.0
43// Created 2000, last modified 2006 40// Created 2000, last modified 2006
44// Leemon Baird 41// Leemon Baird
45// www.leemon.com 42// www.leemon.com
46// 43//
47// This file is public domain. You can use it for any purpose without restriction. 44// This file is public domain. You can use it for any purpose without restriction.
48// I do not guarantee that it is correct, so use it at your own risk. If you use 45// I do not guarantee that it is correct, so use it at your own risk. If you use
49// it for something interesting, I'd appreciate hearing about it. If you find 46// it for something interesting, I'd appreciate hearing about it. If you find
50// any bugs or make any improvements, I'd appreciate hearing about those too. 47// any bugs or make any improvements, I'd appreciate hearing about those too.
51// It would also be nice if my name and address were left in the comments. 48// It would also be nice if my name and address were left in the comments.
52// But none of that is required. 49// But none of that is required.
53// 50//
54// This code defines a bigInt library for arbitrary-precision integers. 51// This code defines a bigInt library for arbitrary-precision integers.
55// A bigInt is an array of integers storing the value in chunks of bpe bits, 52// A bigInt is an array of integers storing the value in chunks of bpe bits,
56// little endian (buff[0] is the least significant word). 53// little endian (buff[0] is the least significant word).
57// Negative bigInts are stored two's complement. 54// Negative bigInts are stored two's complement.
58// Some functions assume their parameters have at least one leading zero element. 55// Some functions assume their parameters have at least one leading zero element.
59// Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, 56// Functions with an underscore at the end of the name have unpredictable behavior in case of overflow,
60// so the caller must make sure overflow won't happen. 57// so the caller must make sure overflow won't happen.
61// For each function where a parameter is modified, that same 58// For each function where a parameter is modified, that same
62// variable must not be used as another argument too. 59// variable must not be used as another argument too.
63// So, you cannot square x by doing multMod_(x,x,n). 60// So, you cannot square x by doing multMod_(x,x,n).
64// You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). 61// You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n).
65// 62//
66// These functions are designed to avoid frequent dynamic memory allocation in the inner loop. 63// These functions are designed to avoid frequent dynamic memory allocation in the inner loop.
67// For most functions, if it needs a BigInt as a local variable it will actually use 64// For most functions, if it needs a BigInt as a local variable it will actually use
68// a global, and will only allocate to it when it's not the right size. This ensures 65// a global, and will only allocate to it when it's not the right size. This ensures
69// that when a function is called repeatedly with same-sized parameters, it only allocates 66// that when a function is called repeatedly with same-sized parameters, it only allocates
70// memory on the first call. 67// memory on the first call.
71// 68//
72// Note that for cryptographic purposes, the calls to Math.random() must 69// Note that for cryptographic purposes, the calls to Math.random() must