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