Diffstat (limited to 'frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js index 5a430d1..b705a20 100644 --- a/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.js +++ b/frontend/gamma/js/Clipperz/Crypto/ECC/BinaryField/Value.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 | //try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 26 | //try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
30 | //throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; | 27 | //throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; |
31 | //} | 28 | //} |
32 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
33 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } | 30 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } |
34 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } | 31 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } |
35 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } | 32 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } |
36 | 33 | ||
37 | Clipperz.Crypto.ECC.BinaryField.Value = function(aValue, aBase, aBitSize) { | 34 | Clipperz.Crypto.ECC.BinaryField.Value = function(aValue, aBase, aBitSize) { |
38 | if (aValue.constructor == String) { | 35 | if (aValue.constructor == String) { |
39 | varvalue; | 36 | varvalue; |
40 | varstringLength; | 37 | varstringLength; |
41 | var numberOfWords; | 38 | var numberOfWords; |
42 | vari,c; | 39 | vari,c; |
43 | 40 | ||
44 | if (aBase != 16) { | 41 | if (aBase != 16) { |
45 | throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; | 42 | throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; |
46 | } | 43 | } |
47 | 44 | ||
48 | value = aValue.replace(/ /g, ''); | 45 | value = aValue.replace(/ /g, ''); |
49 | stringLength = value.length; | 46 | stringLength = value.length; |
50 | numberOfWords = Math.ceil(stringLength / 8); | 47 | numberOfWords = Math.ceil(stringLength / 8); |
51 | this._value = new Array(numberOfWords); | 48 | this._value = new Array(numberOfWords); |
52 | 49 | ||
53 | c = numberOfWords; | 50 | c = numberOfWords; |
54 | for (i=0; i<c; i++) { | 51 | for (i=0; i<c; i++) { |
55 | varword; | 52 | varword; |
56 | 53 | ||
57 | if (i < (c-1)) { | 54 | if (i < (c-1)) { |
58 | word = parseInt(value.substr(stringLength-((i+1)*8), 8), 16); | 55 | word = parseInt(value.substr(stringLength-((i+1)*8), 8), 16); |
59 | } else { | 56 | } else { |
60 | word = parseInt(value.substr(0, stringLength-(i*8)), 16); | 57 | word = parseInt(value.substr(0, stringLength-(i*8)), 16); |
61 | } | 58 | } |
62 | 59 | ||
63 | this._value[i] = word; | 60 | this._value[i] = word; |
64 | } | 61 | } |
65 | } else if (aValue.constructor == Array) { | 62 | } else if (aValue.constructor == Array) { |
66 | var itemsToCopy; | 63 | var itemsToCopy; |
67 | 64 | ||
68 | itemsToCopy = aValue.length; | 65 | itemsToCopy = aValue.length; |
69 | while (aValue[itemsToCopy - 1] == 0) { | 66 | while (aValue[itemsToCopy - 1] == 0) { |
70 | itemsToCopy --; | 67 | itemsToCopy --; |
71 | } | 68 | } |
72 | 69 | ||