author | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-31 13:42:04 (UTC) |
commit | 07d0357beef5d9328a2dd8d07ad7b39c87ac55e4 (patch) (unidiff) | |
tree | f7a4aed8848302db153c2a211f8e58b944eb4c5b /frontend/beta/js/Clipperz/Crypto | |
parent | 767a3dcf48b6ac911c088af5dd7738a728eb6b99 (diff) | |
download | clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.zip clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.gz clipperz-07d0357beef5d9328a2dd8d07ad7b39c87ac55e4.tar.bz2 |
Updated Copyright claims
- updated reference dates;
- removed reference to Community Edition;
- normalized logging using Clipperz.log[Warn|Error|Debug]
Diffstat (limited to 'frontend/beta/js/Clipperz/Crypto') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/AES.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/Base.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/BigInt.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/ECC.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Curve.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Point.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Value.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/PRNG.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/RSA.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/SHA.js | 22 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/SRP.js | 22 |
13 files changed, 130 insertions, 156 deletions
diff --git a/frontend/beta/js/Clipperz/Crypto/AES.js b/frontend/beta/js/Clipperz/Crypto/AES.js index 7ddda3e..a5c63fb 100644 --- a/frontend/beta/js/Clipperz/Crypto/AES.js +++ b/frontend/beta/js/Clipperz/Crypto/AES.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.AES depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.AES depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | //Dependency commented to avoid a circular reference | 28 | //Dependency commented to avoid a circular reference |
31 | //try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { | 29 | //try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { |
32 | //throw "Clipperz.Crypto.AES depends on Clipperz.Crypto.PRNG!"; | 30 | //throw "Clipperz.Crypto.AES depends on Clipperz.Crypto.PRNG!"; |
33 | //} | 31 | //} |
34 | 32 | ||
35 | if (typeof(Clipperz.Crypto.AES) == 'undefined') { Clipperz.Crypto.AES = {}; } | 33 | if (typeof(Clipperz.Crypto.AES) == 'undefined') { Clipperz.Crypto.AES = {}; } |
36 | 34 | ||
37 | //############################################################################# | 35 | //############################################################################# |
38 | 36 | ||
39 | Clipperz.Crypto.AES.DeferredExecutionContext = function(args) { | 37 | Clipperz.Crypto.AES.DeferredExecutionContext = function(args) { |
40 | args = args || {}; | 38 | args = args || {}; |
41 | 39 | ||
42 | this._key = args.key; | 40 | this._key = args.key; |
43 | this._message = args.message; | 41 | this._message = args.message; |
44 | this._result = args.message.clone(); | 42 | this._result = args.message.clone(); |
45 | this._nonce = args.nonce; | 43 | this._nonce = args.nonce; |
46 | this._messageLength = this._message.length(); | 44 | this._messageLength = this._message.length(); |
47 | 45 | ||
48 | this._messageArray = this._message.arrayValues(); | 46 | this._messageArray = this._message.arrayValues(); |
49 | this._resultArray = this._result.arrayValues(); | 47 | this._resultArray = this._result.arrayValues(); |
50 | this._nonceArray = this._nonce.arrayValues(); | 48 | this._nonceArray = this._nonce.arrayValues(); |
51 | 49 | ||
52 | this._executionStep = 0; | 50 | this._executionStep = 0; |
53 | 51 | ||
54 | return this; | 52 | return this; |
55 | } | 53 | } |
56 | 54 | ||
57 | Clipperz.Crypto.AES.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { | 55 | Clipperz.Crypto.AES.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { |
58 | 56 | ||
59 | 'key': function() { | 57 | 'key': function() { |
60 | return this._key; | 58 | return this._key; |
61 | }, | 59 | }, |
62 | 60 | ||
63 | 'message': function() { | 61 | 'message': function() { |
64 | return this._message; | 62 | return this._message; |
65 | }, | 63 | }, |
66 | 64 | ||
67 | 'messageLength': function() { | 65 | 'messageLength': function() { |
68 | return this._messageLength; | 66 | return this._messageLength; |
69 | }, | 67 | }, |
70 | 68 | ||
71 | 'result': function() { | 69 | 'result': function() { |
72 | return new Clipperz.ByteArray(this.resultArray()); | 70 | return new Clipperz.ByteArray(this.resultArray()); |
73 | }, | 71 | }, |
74 | 72 | ||
75 | 'nonce': function() { | 73 | 'nonce': function() { |
76 | return this._nonce; | 74 | return this._nonce; |
77 | }, | 75 | }, |
78 | 76 | ||
79 | 'messageArray': function() { | 77 | 'messageArray': function() { |
80 | return this._messageArray; | 78 | return this._messageArray; |
81 | }, | 79 | }, |
82 | 80 | ||
83 | 'resultArray': function() { | 81 | 'resultArray': function() { |
84 | return this._resultArray; | 82 | return this._resultArray; |
85 | }, | 83 | }, |
86 | 84 | ||
87 | 'nonceArray': function() { | 85 | 'nonceArray': function() { |
88 | return this._nonceArray; | 86 | return this._nonceArray; |
89 | }, | 87 | }, |
90 | 88 | ||
91 | 'elaborationChunkSize': function() { | 89 | 'elaborationChunkSize': function() { |
92 | return Clipperz.Crypto.AES.DeferredExecution.chunkSize; | 90 | return Clipperz.Crypto.AES.DeferredExecution.chunkSize; |
93 | }, | 91 | }, |
94 | 92 | ||
95 | 'executionStep': function() { | 93 | 'executionStep': function() { |
96 | return this._executionStep; | 94 | return this._executionStep; |
97 | }, | 95 | }, |
98 | 96 | ||
99 | 'setExecutionStep': function(aValue) { | 97 | 'setExecutionStep': function(aValue) { |
100 | this._executionStep = aValue; | 98 | this._executionStep = aValue; |
101 | }, | 99 | }, |
102 | 100 | ||
103 | 'pause': function(aValue) { | 101 | 'pause': function(aValue) { |
104 | return MochiKit.Async.wait(Clipperz.Crypto.AES.DeferredExecution.pauseTime, aValue); | 102 | return MochiKit.Async.wait(Clipperz.Crypto.AES.DeferredExecution.pauseTime, aValue); |
105 | }, | 103 | }, |
106 | 104 | ||
107 | //----------------------------------------------------------------------------- | 105 | //----------------------------------------------------------------------------- |
108 | __syntaxFix__: "syntax fix" | 106 | __syntaxFix__: "syntax fix" |
109 | 107 | ||
110 | }); | 108 | }); |
111 | 109 | ||
112 | //############################################################################# | 110 | //############################################################################# |
113 | 111 | ||
114 | Clipperz.Crypto.AES.Key = function(args) { | 112 | Clipperz.Crypto.AES.Key = function(args) { |
115 | args = args || {}; | 113 | args = args || {}; |
116 | 114 | ||
117 | this._key = args.key; | 115 | this._key = args.key; |
118 | this._keySize = args.keySize || this.key().length(); | 116 | this._keySize = args.keySize || this.key().length(); |
diff --git a/frontend/beta/js/Clipperz/Crypto/Base.js b/frontend/beta/js/Clipperz/Crypto/Base.js index d3a8e36..9acfc49 100644 --- a/frontend/beta/js/Clipperz/Crypto/Base.js +++ b/frontend/beta/js/Clipperz/Crypto/Base.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.Base) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.Base) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.Base depends on Clipperz.Base!"; | 25 | throw "Clipperz.Crypto.Base depends on Clipperz.Base!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } | 28 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } |
31 | if (typeof(Clipperz.Crypto.Base) == 'undefined') { Clipperz.Crypto.Base = {}; } | 29 | if (typeof(Clipperz.Crypto.Base) == 'undefined') { Clipperz.Crypto.Base = {}; } |
32 | 30 | ||
33 | Clipperz.Crypto.Base.VERSION = "0.1"; | 31 | Clipperz.Crypto.Base.VERSION = "0.1"; |
34 | Clipperz.Crypto.Base.NAME = "Clipperz.Crypto.Base"; | 32 | Clipperz.Crypto.Base.NAME = "Clipperz.Crypto.Base"; |
35 | 33 | ||
36 | //############################################################################# | 34 | //############################################################################# |
37 | //Downloaded on March 30, 2006 from http://anmar.eu.org/projects/jssha2/files/jssha2-0.3.zip (jsSha2/sha256.js) | 35 | //Downloaded on March 30, 2006 from http://anmar.eu.org/projects/jssha2/files/jssha2-0.3.zip (jsSha2/sha256.js) |
38 | //############################################################################# | 36 | //############################################################################# |
39 | 37 | ||
40 | /* A JavaScript implementation of the Secure Hash Algorithm, SHA-256 | 38 | /* A JavaScript implementation of the Secure Hash Algorithm, SHA-256 |
41 | * Version 0.3 Copyright Angel Marin 2003-2004 - http://anmar.eu.org/ | 39 | * Version 0.3 Copyright Angel Marin 2003-2004 - http://anmar.eu.org/ |
42 | * Distributed under the BSD License | 40 | * Distributed under the BSD License |
43 | * Some bits taken from Paul Johnston's SHA-1 implementation | 41 | * Some bits taken from Paul Johnston's SHA-1 implementation |
44 | */ | 42 | */ |
45 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ | 43 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ |
46 | function safe_add (x, y) { | 44 | function safe_add (x, y) { |
47 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); | 45 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); |
48 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); | 46 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); |
49 | return (msw << 16) | (lsw & 0xFFFF); | 47 | return (msw << 16) | (lsw & 0xFFFF); |
50 | } | 48 | } |
51 | function S (X, n) {return ( X >>> n ) | (X << (32 - n));} | 49 | function S (X, n) {return ( X >>> n ) | (X << (32 - n));} |
52 | function R (X, n) {return ( X >>> n );} | 50 | function R (X, n) {return ( X >>> n );} |
53 | function Ch(x, y, z) {return ((x & y) ^ ((~x) & z));} | 51 | function Ch(x, y, z) {return ((x & y) ^ ((~x) & z));} |
54 | function Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));} | 52 | function Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));} |
55 | function Sigma0256(x) {return (S(x, 2) ^ S(x, 13) ^ S(x, 22));} | 53 | function Sigma0256(x) {return (S(x, 2) ^ S(x, 13) ^ S(x, 22));} |
56 | function Sigma1256(x) {return (S(x, 6) ^ S(x, 11) ^ S(x, 25));} | 54 | function Sigma1256(x) {return (S(x, 6) ^ S(x, 11) ^ S(x, 25));} |
57 | function Gamma0256(x) {return (S(x, 7) ^ S(x, 18) ^ R(x, 3));} | 55 | function Gamma0256(x) {return (S(x, 7) ^ S(x, 18) ^ R(x, 3));} |
58 | function Gamma1256(x) {return (S(x, 17) ^ S(x, 19) ^ R(x, 10));} | 56 | function Gamma1256(x) {return (S(x, 17) ^ S(x, 19) ^ R(x, 10));} |
59 | function core_sha256 (m, l) { | 57 | function core_sha256 (m, l) { |
60 | var K = new Array(0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x6CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2); | 58 | var K = new Array(0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B,0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01,0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7,0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC,0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152,0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147,0x6CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC,0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85,0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819,0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08,0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F,0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208,0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2); |
61 | var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19); | 59 | var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19); |
62 | var W = new Array(64); | 60 | var W = new Array(64); |
63 | var a, b, c, d, e, f, g, h, i, j; | 61 | var a, b, c, d, e, f, g, h, i, j; |
64 | var T1, T2; | 62 | var T1, T2; |
65 | /* append padding */ | 63 | /* append padding */ |
66 | m[l >> 5] |= 0x80 << (24 - l % 32); | 64 | m[l >> 5] |= 0x80 << (24 - l % 32); |
67 | m[((l + 64 >> 9) << 4) + 15] = l; | 65 | m[((l + 64 >> 9) << 4) + 15] = l; |
68 | for ( var i = 0; i<m.length; i+=16 ) { | 66 | for ( var i = 0; i<m.length; i+=16 ) { |
69 | a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; | 67 | a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; |
70 | for ( var j = 0; j<64; j++) { | 68 | for ( var j = 0; j<64; j++) { |
71 | if (j < 16) W[j] = m[j + i]; | 69 | if (j < 16) W[j] = m[j + i]; |
72 | else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]); | 70 | else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]); |
73 | T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]); | 71 | T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]); |
74 | T2 = safe_add(Sigma0256(a), Maj(a, b, c)); | 72 | T2 = safe_add(Sigma0256(a), Maj(a, b, c)); |
75 | h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2); | 73 | h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2); |
76 | } | 74 | } |
77 | HASH[0] = safe_add(a, HASH[0]); HASH[1] = safe_add(b, HASH[1]); HASH[2] = safe_add(c, HASH[2]); HASH[3] = safe_add(d, HASH[3]); HASH[4] = safe_add(e, HASH[4]); HASH[5] = safe_add(f, HASH[5]); HASH[6] = safe_add(g, HASH[6]); HASH[7] = safe_add(h, HASH[7]); | 75 | HASH[0] = safe_add(a, HASH[0]); HASH[1] = safe_add(b, HASH[1]); HASH[2] = safe_add(c, HASH[2]); HASH[3] = safe_add(d, HASH[3]); HASH[4] = safe_add(e, HASH[4]); HASH[5] = safe_add(f, HASH[5]); HASH[6] = safe_add(g, HASH[6]); HASH[7] = safe_add(h, HASH[7]); |
78 | } | 76 | } |
79 | return HASH; | 77 | return HASH; |
80 | } | 78 | } |
81 | function str2binb (str) { | 79 | function str2binb (str) { |
82 | var bin = Array(); | 80 | var bin = Array(); |
83 | var mask = (1 << chrsz) - 1; | 81 | var mask = (1 << chrsz) - 1; |
84 | for(var i = 0; i < str.length * chrsz; i += chrsz) | 82 | for(var i = 0; i < str.length * chrsz; i += chrsz) |
85 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32); | 83 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32); |
86 | return bin; | 84 | return bin; |
87 | } | 85 | } |
88 | function binb2hex (binarray) { | 86 | function binb2hex (binarray) { |
89 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ | 87 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ |
90 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; | 88 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; |
91 | var str = ""; | 89 | var str = ""; |
92 | for (var i = 0; i < binarray.length * 4; i++) { | 90 | for (var i = 0; i < binarray.length * 4; i++) { |
93 | str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); | 91 | str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); |
94 | } | 92 | } |
95 | return str; | 93 | return str; |
96 | } | 94 | } |
97 | function hex_sha256(s){return binb2hex(core_sha256(str2binb(s),s.length * chrsz));} | 95 | function hex_sha256(s){return binb2hex(core_sha256(str2binb(s),s.length * chrsz));} |
98 | 96 | ||
99 | 97 | ||
100 | 98 | ||
101 | //############################################################################# | 99 | //############################################################################# |
102 | //Downloaded on March 30, 2006 from http://www.fourmilab.ch/javascrypt/javascrypt.zip (entropy.js) | 100 | //Downloaded on March 30, 2006 from http://www.fourmilab.ch/javascrypt/javascrypt.zip (entropy.js) |
103 | //############################################################################# | 101 | //############################################################################# |
104 | 102 | ||
105 | // Entropy collection utilities | 103 | // Entropy collection utilities |
106 | 104 | ||
107 | /*Start by declaring static storage and initialise | 105 | /*Start by declaring static storage and initialise |
108 | the entropy vector from the time we come through | 106 | the entropy vector from the time we come through |
109 | here. */ | 107 | here. */ |
110 | 108 | ||
111 | var entropyData = new Array(); // Collected entropy data | 109 | var entropyData = new Array(); // Collected entropy data |
112 | var edlen = 0; // Keyboard array data length | 110 | var edlen = 0; // Keyboard array data length |
113 | 111 | ||
114 | addEntropyTime(); // Start entropy collection with page load time | 112 | addEntropyTime(); // Start entropy collection with page load time |
115 | ce(); // Roll milliseconds into initial entropy | 113 | ce(); // Roll milliseconds into initial entropy |
116 | 114 | ||
117 | //Add a byte to the entropy vector | 115 | //Add a byte to the entropy vector |
118 | 116 | ||
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,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } | 25 | if (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. |
71 | // | 69 | // |
72 | // The following functions do not modify their inputs, but dynamically allocate memory every time they are called: | 70 | // The following functions do not modify their inputs, but dynamically allocate memory every time they are called: |
73 | // | 71 | // |
74 | // function bigInt2str(x,base) //convert a bigInt into a string in a given base, from base 2 up to base 95 | 72 | // function bigInt2str(x,base) //convert a bigInt into a string in a given base, from base 2 up to base 95 |
75 | // function dup(x) //returns a copy of bigInt x | 73 | // function dup(x) //returns a copy of bigInt x |
76 | // function findPrimes(n) //return array of all primes less than integer n | 74 | // function findPrimes(n) //return array of all primes less than integer n |
77 | // function int2bigInt(t,n,m) //convert integer t to a bigInt with at least n bits and m array elements | 75 | // function int2bigInt(t,n,m) //convert integer t to a bigInt with at least n bits and m array elements |
78 | // function int2bigInt(s,b,n,m) //convert string s in base b to a bigInt with at least n bits and m array elements | 76 | // function int2bigInt(s,b,n,m) //convert string s in base b to a bigInt with at least n bits and m array elements |
79 | // function trim(x,k) //return a copy of x with exactly k leading zero elements | 77 | // function trim(x,k) //return a copy of x with exactly k leading zero elements |
80 | // | 78 | // |
81 | // The following functions do not modify their inputs, so there is never a problem with the result being too big: | 79 | // The following functions do not modify their inputs, so there is never a problem with the result being too big: |
82 | // | 80 | // |
83 | // function bitSize(x) //returns how many bits long the bigInt x is, not counting leading zeros | 81 | // function bitSize(x) //returns how many bits long the bigInt x is, not counting leading zeros |
84 | // function equals(x,y) //is the bigInt x equal to the bigint y? | 82 | // function equals(x,y) //is the bigInt x equal to the bigint y? |
85 | // function equalsInt(x,y) //is bigint x equal to integer y? | 83 | // function equalsInt(x,y) //is bigint x equal to integer y? |
86 | // function greater(x,y) //is x>y? (x and y are nonnegative bigInts) | 84 | // function greater(x,y) //is x>y? (x and y are nonnegative bigInts) |
87 | // function greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y? | 85 | // function greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y? |
88 | // function isZero(x) //is the bigInt x equal to zero? | 86 | // function isZero(x) //is the bigInt x equal to zero? |
89 | // function millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime (as opposed to definitely composite)? | 87 | // function millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime (as opposed to definitely composite)? |
90 | // function modInt(x,n) //return x mod n for bigInt x and integer n. | 88 | // function modInt(x,n) //return x mod n for bigInt x and integer n. |
91 | // function negative(x) //is bigInt x negative? | 89 | // function negative(x) //is bigInt x negative? |
92 | // | 90 | // |
93 | // The following functions do not modify their inputs, but allocate memory and call functions with underscores | 91 | // The following functions do not modify their inputs, but allocate memory and call functions with underscores |
94 | // | 92 | // |
95 | // function add(x,y) //return (x+y) for bigInts x and y. | 93 | // function add(x,y) //return (x+y) for bigInts x and y. |
96 | // function addInt(x,n) //return (x+n) where x is a bigInt and n is an integer. | 94 | // function addInt(x,n) //return (x+n) where x is a bigInt and n is an integer. |
97 | // function expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed | 95 | // function expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed |
98 | // function inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null | 96 | // function inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null |
99 | // function mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n. | 97 | // function mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n. |
100 | // function mult(x,y) //return x*y for bigInts x and y. This is faster when y<x. | 98 | // function mult(x,y) //return x*y for bigInts x and y. This is faster when y<x. |
101 | // function multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. | 99 | // function multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. |
102 | // function powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. | 100 | // function powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. |
103 | // function randTruePrime(k) //return a new, random, k-bit, true prime using Maurer's algorithm. | 101 | // function randTruePrime(k) //return a new, random, k-bit, true prime using Maurer's algorithm. |
104 | // function sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement | 102 | // function sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement |
105 | // | 103 | // |
106 | // The following functions write a bigInt result to one of the parameters, but | 104 | // The following functions write a bigInt result to one of the parameters, but |
107 | // the result is never bigger than the original, so there can't be overflow problems: | 105 | // the result is never bigger than the original, so there can't be overflow problems: |
108 | // | 106 | // |
109 | // function divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder | 107 | // function divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder |
110 | // function GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). | 108 | // function GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). |
111 | // function halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement | 109 | // function halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement |
112 | // function mod_(x,n) //do x=x mod n for bigInts x and n. | 110 | // function mod_(x,n) //do x=x mod n for bigInts x and n. |
113 | // function rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. | 111 | // function rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. |
114 | // | 112 | // |
115 | // The following functions write a bigInt result to one of the parameters. The caller is responsible for | 113 | // The following functions write a bigInt result to one of the parameters. The caller is responsible for |
116 | // ensuring it is large enough to hold the result. | 114 | // ensuring it is large enough to hold the result. |
117 | // | 115 | // |
118 | // function addInt_(x,n) //do x=x+n where x is a bigInt and n is an integer | 116 | // function addInt_(x,n) //do x=x+n where x is a bigInt and n is an integer |
diff --git a/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js b/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js index f91c7e9..bc60330 100644 --- a/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js +++ b/frontend/beta/js/Clipperz/Crypto/BigInt_scoped.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } | 25 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } |
28 | 26 | ||
29 | if (typeof(Leemon) == 'undefined') { Leemon = {}; } | 27 | if (typeof(Leemon) == 'undefined') { Leemon = {}; } |
30 | if (typeof(Baird.Crypto) == 'undefined') { Baird.Crypto = {}; } | 28 | if (typeof(Baird.Crypto) == 'undefined') { Baird.Crypto = {}; } |
31 | if (typeof(Baird.Crypto.BigInt) == 'undefined') { Baird.Crypto.BigInt = {}; } | 29 | if (typeof(Baird.Crypto.BigInt) == 'undefined') { Baird.Crypto.BigInt = {}; } |
32 | 30 | ||
33 | 31 | ||
34 | //############################################################################# | 32 | //############################################################################# |
35 | //Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js | 33 | //Downloaded on March 05, 2007 from http://www.leemon.com/crypto/BigInt.js |
36 | //############################################################################# | 34 | //############################################################################# |
37 | 35 | ||
38 | //////////////////////////////////////////////////////////////////////////////////////// | 36 | //////////////////////////////////////////////////////////////////////////////////////// |
39 | // Big Integer Library v. 5.0 | 37 | // Big Integer Library v. 5.0 |
40 | // Created 2000, last modified 2006 | 38 | // Created 2000, last modified 2006 |
41 | // Leemon Baird | 39 | // Leemon Baird |
42 | // www.leemon.com | 40 | // www.leemon.com |
43 | // | 41 | // |
44 | // This file is public domain. You can use it for any purpose without restriction. | 42 | // This file is public domain. You can use it for any purpose without restriction. |
45 | // I do not guarantee that it is correct, so use it at your own risk. If you use | 43 | // I do not guarantee that it is correct, so use it at your own risk. If you use |
46 | // it for something interesting, I'd appreciate hearing about it. If you find | 44 | // it for something interesting, I'd appreciate hearing about it. If you find |
47 | // any bugs or make any improvements, I'd appreciate hearing about those too. | 45 | // any bugs or make any improvements, I'd appreciate hearing about those too. |
48 | // It would also be nice if my name and address were left in the comments. | 46 | // It would also be nice if my name and address were left in the comments. |
49 | // But none of that is required. | 47 | // But none of that is required. |
50 | // | 48 | // |
51 | // This code defines a bigInt library for arbitrary-precision integers. | 49 | // This code defines a bigInt library for arbitrary-precision integers. |
52 | // A bigInt is an array of integers storing the value in chunks of bpe bits, | 50 | // A bigInt is an array of integers storing the value in chunks of bpe bits, |
53 | // little endian (buff[0] is the least significant word). | 51 | // little endian (buff[0] is the least significant word). |
54 | // Negative bigInts are stored two's complement. | 52 | // Negative bigInts are stored two's complement. |
55 | // Some functions assume their parameters have at least one leading zero element. | 53 | // Some functions assume their parameters have at least one leading zero element. |
56 | // Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, | 54 | // Functions with an underscore at the end of the name have unpredictable behavior in case of overflow, |
57 | // so the caller must make sure overflow won't happen. | 55 | // so the caller must make sure overflow won't happen. |
58 | // For each function where a parameter is modified, that same | 56 | // For each function where a parameter is modified, that same |
59 | // variable must not be used as another argument too. | 57 | // variable must not be used as another argument too. |
60 | // So, you cannot square x by doing multMod_(x,x,n). | 58 | // So, you cannot square x by doing multMod_(x,x,n). |
61 | // You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). | 59 | // You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n). |
62 | // | 60 | // |
63 | // These functions are designed to avoid frequent dynamic memory allocation in the inner loop. | 61 | // These functions are designed to avoid frequent dynamic memory allocation in the inner loop. |
64 | // For most functions, if it needs a BigInt as a local variable it will actually use | 62 | // For most functions, if it needs a BigInt as a local variable it will actually use |
65 | // a global, and will only allocate to it when it's not the right size. This ensures | 63 | // a global, and will only allocate to it when it's not the right size. This ensures |
66 | // that when a function is called repeatedly with same-sized parameters, it only allocates | 64 | // that when a function is called repeatedly with same-sized parameters, it only allocates |
67 | // memory on the first call. | 65 | // memory on the first call. |
68 | // | 66 | // |
69 | // Note that for cryptographic purposes, the calls to Math.random() must | 67 | // Note that for cryptographic purposes, the calls to Math.random() must |
70 | // be replaced with calls to a better pseudorandom number generator. | 68 | // be replaced with calls to a better pseudorandom number generator. |
71 | // | 69 | // |
72 | // In the following, "bigInt" means a bigInt with at least one leading zero element, | 70 | // In the following, "bigInt" means a bigInt with at least one leading zero element, |
73 | // and "integer" means a nonnegative integer less than radix. In some cases, integer | 71 | // and "integer" means a nonnegative integer less than radix. In some cases, integer |
74 | // can be negative. Negative bigInts are 2s complement. | 72 | // can be negative. Negative bigInts are 2s complement. |
75 | // | 73 | // |
76 | // The following functions do not modify their inputs, but dynamically allocate memory every time they are called: | 74 | // The following functions do not modify their inputs, but dynamically allocate memory every time they are called: |
77 | // | 75 | // |
78 | // function bigInt2str(x,base) //convert a bigInt into a string in a given base, from base 2 up to base 95 | 76 | // function bigInt2str(x,base) //convert a bigInt into a string in a given base, from base 2 up to base 95 |
79 | // function dup(x) //returns a copy of bigInt x | 77 | // function dup(x) //returns a copy of bigInt x |
80 | // function findPrimes(n) //return array of all primes less than integer n | 78 | // function findPrimes(n) //return array of all primes less than integer n |
81 | // function int2bigInt(t,n,m) //convert integer t to a bigInt with at least n bits and m array elements | 79 | // function int2bigInt(t,n,m) //convert integer t to a bigInt with at least n bits and m array elements |
82 | // function str2bigInt(s,b,n,m) //convert string s in base b to a bigInt with at least n bits and m array elements | 80 | // function str2bigInt(s,b,n,m) //convert string s in base b to a bigInt with at least n bits and m array elements |
83 | // function trim(x,k) //return a copy of x with exactly k leading zero elements | 81 | // function trim(x,k) //return a copy of x with exactly k leading zero elements |
84 | // | 82 | // |
85 | // The following functions do not modify their inputs, so there is never a problem with the result being too big: | 83 | // The following functions do not modify their inputs, so there is never a problem with the result being too big: |
86 | // | 84 | // |
87 | // function bitSize(x) //returns how many bits long the bigInt x is, not counting leading zeros | 85 | // function bitSize(x) //returns how many bits long the bigInt x is, not counting leading zeros |
88 | // function equals(x,y) //is the bigInt x equal to the bigint y? | 86 | // function equals(x,y) //is the bigInt x equal to the bigint y? |
89 | // function equalsInt(x,y) //is bigint x equal to integer y? | 87 | // function equalsInt(x,y) //is bigint x equal to integer y? |
90 | // function greater(x,y) //is x>y? (x and y are nonnegative bigInts) | 88 | // function greater(x,y) //is x>y? (x and y are nonnegative bigInts) |
91 | // function greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y? | 89 | // function greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y? |
92 | // function isZero(x) //is the bigInt x equal to zero? | 90 | // function isZero(x) //is the bigInt x equal to zero? |
93 | // function millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime (as opposed to definitely composite)? | 91 | // function millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime (as opposed to definitely composite)? |
94 | // function modInt(x,n) //return x mod n for bigInt x and integer n. | 92 | // function modInt(x,n) //return x mod n for bigInt x and integer n. |
95 | // function negative(x) //is bigInt x negative? | 93 | // function negative(x) //is bigInt x negative? |
96 | // | 94 | // |
97 | // The following functions do not modify their inputs, but allocate memory and call functions with underscores | 95 | // The following functions do not modify their inputs, but allocate memory and call functions with underscores |
98 | // | 96 | // |
99 | // function add(x,y) //return (x+y) for bigInts x and y. | 97 | // function add(x,y) //return (x+y) for bigInts x and y. |
100 | // function addInt(x,n) //return (x+n) where x is a bigInt and n is an integer. | 98 | // function addInt(x,n) //return (x+n) where x is a bigInt and n is an integer. |
101 | // function expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed | 99 | // function expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed |
102 | // function inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null | 100 | // function inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null |
103 | // function mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n. | 101 | // function mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n. |
104 | // function mult(x,y) //return x*y for bigInts x and y. This is faster when y<x. | 102 | // function mult(x,y) //return x*y for bigInts x and y. This is faster when y<x. |
105 | // function multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. | 103 | // function multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x. |
106 | // function powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. | 104 | // function powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n. |
107 | // function randTruePrime(k) //return a new, random, k-bit, true prime using Maurer's algorithm. | 105 | // function randTruePrime(k) //return a new, random, k-bit, true prime using Maurer's algorithm. |
108 | // function sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement | 106 | // function sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement |
109 | // | 107 | // |
110 | // The following functions write a bigInt result to one of the parameters, but | 108 | // The following functions write a bigInt result to one of the parameters, but |
111 | // the result is never bigger than the original, so there can't be overflow problems: | 109 | // the result is never bigger than the original, so there can't be overflow problems: |
112 | // | 110 | // |
113 | // function divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder | 111 | // function divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder |
114 | // function GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). | 112 | // function GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). |
115 | // function halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement | 113 | // function halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement |
116 | // function mod_(x,n) //do x=x mod n for bigInts x and n. | 114 | // function mod_(x,n) //do x=x mod n for bigInts x and n. |
117 | // function rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. | 115 | // function rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. |
118 | // | 116 | // |
diff --git a/frontend/beta/js/Clipperz/Crypto/ECC.js b/frontend/beta/js/Clipperz/Crypto/ECC.js index bdfd9be..74eb02f 100644 --- a/frontend/beta/js/Clipperz/Crypto/ECC.js +++ b/frontend/beta/js/Clipperz/Crypto/ECC.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | /* | 24 | /* |
27 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 25 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
28 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; | 26 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; |
29 | } | 27 | } |
30 | 28 | ||
31 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } | 29 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } |
32 | 30 | ||
33 | 31 | ||
34 | //############################################################################# | 32 | //############################################################################# |
35 | 33 | ||
36 | Clipperz.Crypto.ECC.BinaryField = {}; | 34 | Clipperz.Crypto.ECC.BinaryField = {}; |
37 | 35 | ||
38 | //############################################################################# | 36 | //############################################################################# |
39 | 37 | ||
40 | Clipperz.Crypto.ECC.BinaryField.AbstractValue = function(aValue, aBase) { | 38 | Clipperz.Crypto.ECC.BinaryField.AbstractValue = function(aValue, aBase) { |
41 | return this; | 39 | return this; |
42 | } | 40 | } |
43 | 41 | ||
44 | Clipperz.Crypto.ECC.BinaryField.AbstractValue.prototype = MochiKit.Base.update(null, { | 42 | Clipperz.Crypto.ECC.BinaryField.AbstractValue.prototype = MochiKit.Base.update(null, { |
45 | 43 | ||
46 | 'asString': function(aBase) { | 44 | 'asString': function(aBase) { |
47 | throw Clipperz.Base.exception.AbstractMethod; | 45 | throw Clipperz.Base.exception.AbstractMethod; |
48 | }, | 46 | }, |
49 | 47 | ||
50 | 'isZero': function() { | 48 | 'isZero': function() { |
51 | throw Clipperz.Base.exception.AbstractMethod; | 49 | throw Clipperz.Base.exception.AbstractMethod; |
52 | }, | 50 | }, |
53 | 51 | ||
54 | 'shiftLeft': function(aNumberOfBitsToShift) { | 52 | 'shiftLeft': function(aNumberOfBitsToShift) { |
55 | throw Clipperz.Base.exception.AbstractMethod; | 53 | throw Clipperz.Base.exception.AbstractMethod; |
56 | }, | 54 | }, |
57 | 55 | ||
58 | 'bitSize': function() { | 56 | 'bitSize': function() { |
59 | throw Clipperz.Base.exception.AbstractMethod; | 57 | throw Clipperz.Base.exception.AbstractMethod; |
60 | }, | 58 | }, |
61 | 59 | ||
62 | 'isBitSet': function(aBitPosition) { | 60 | 'isBitSet': function(aBitPosition) { |
63 | throw Clipperz.Base.exception.AbstractMethod; | 61 | throw Clipperz.Base.exception.AbstractMethod; |
64 | }, | 62 | }, |
65 | 63 | ||
66 | 'xor': function(aValue) { | 64 | 'xor': function(aValue) { |
67 | throw Clipperz.Base.exception.AbstractMethod; | 65 | throw Clipperz.Base.exception.AbstractMethod; |
68 | }, | 66 | }, |
69 | 67 | ||
70 | 'compare': function(aValue) { | 68 | 'compare': function(aValue) { |
71 | throw Clipperz.Base.exception.AbstractMethod; | 69 | throw Clipperz.Base.exception.AbstractMethod; |
72 | }, | 70 | }, |
73 | 71 | ||
74 | //----------------------------------------------------------------------------- | 72 | //----------------------------------------------------------------------------- |
75 | __syntaxFix__: "syntax fix" | 73 | __syntaxFix__: "syntax fix" |
76 | }); | 74 | }); |
77 | 75 | ||
78 | //***************************************************************************** | 76 | //***************************************************************************** |
79 | / * | 77 | / * |
80 | Clipperz.Crypto.ECC.BinaryField.BigIntValue = function(aValue, aBase) { | 78 | Clipperz.Crypto.ECC.BinaryField.BigIntValue = function(aValue, aBase) { |
81 | this._value = new Clipperz.Crypto.BigInt(aValue, aBase); | 79 | this._value = new Clipperz.Crypto.BigInt(aValue, aBase); |
82 | return this; | 80 | return this; |
83 | } | 81 | } |
84 | 82 | ||
85 | Clipperz.Crypto.ECC.BinaryField.BigIntValue.prototype = MochiKit.Base.update(new Clipperz.Crypto.ECC.BinaryField.AbstractValue(), { | 83 | Clipperz.Crypto.ECC.BinaryField.BigIntValue.prototype = MochiKit.Base.update(new Clipperz.Crypto.ECC.BinaryField.AbstractValue(), { |
86 | 84 | ||
87 | 'value': function() { | 85 | 'value': function() { |
88 | return this._value; | 86 | return this._value; |
89 | }, | 87 | }, |
90 | 88 | ||
91 | //----------------------------------------------------------------------------- | 89 | //----------------------------------------------------------------------------- |
92 | 90 | ||
93 | 'isZero': function() { | 91 | 'isZero': function() { |
94 | return (this.value().compare(Clipperz.Crypto.ECC.BinaryField.BigIntValue.O) == 0); | 92 | return (this.value().compare(Clipperz.Crypto.ECC.BinaryField.BigIntValue.O) == 0); |
95 | }, | 93 | }, |
96 | 94 | ||
97 | //----------------------------------------------------------------------------- | 95 | //----------------------------------------------------------------------------- |
98 | 96 | ||
99 | 'asString': function(aBase) { | 97 | 'asString': function(aBase) { |
100 | return this.value().asString(aBase); | 98 | return this.value().asString(aBase); |
101 | }, | 99 | }, |
102 | 100 | ||
103 | //----------------------------------------------------------------------------- | 101 | //----------------------------------------------------------------------------- |
104 | 102 | ||
105 | 'shiftLeft': function(aNumberOfBitsToShift) { | 103 | 'shiftLeft': function(aNumberOfBitsToShift) { |
106 | return new Clipperz.Crypto.ECC.BinaryField.BigIntValue(this.value().shiftLeft(aNumberOfBitsToShift)); | 104 | return new Clipperz.Crypto.ECC.BinaryField.BigIntValue(this.value().shiftLeft(aNumberOfBitsToShift)); |
107 | }, | 105 | }, |
108 | 106 | ||
109 | //----------------------------------------------------------------------------- | 107 | //----------------------------------------------------------------------------- |
110 | 108 | ||
111 | 'bitSize': function() { | 109 | 'bitSize': function() { |
112 | return this.value().bitSize(); | 110 | return this.value().bitSize(); |
113 | }, | 111 | }, |
114 | 112 | ||
115 | //----------------------------------------------------------------------------- | 113 | //----------------------------------------------------------------------------- |
116 | 114 | ||
117 | 'isBitSet': function(aBitPosition) { | 115 | 'isBitSet': function(aBitPosition) { |
118 | return this.value().isBitSet(aBitPosition); | 116 | return this.value().isBitSet(aBitPosition); |
diff --git a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Curve.js b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Curve.js index 01127c3..c39a075 100644 --- a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Curve.js +++ b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Curve.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } | 27 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } |
30 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } | 28 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } |
31 | 29 | ||
32 | Clipperz.Crypto.ECC.BinaryField.Curve = function(args) { | 30 | Clipperz.Crypto.ECC.BinaryField.Curve = function(args) { |
33 | args = args || {}; | 31 | args = args || {}; |
34 | 32 | ||
35 | this._modulus = args.modulus; | 33 | this._modulus = args.modulus; |
36 | 34 | ||
37 | this._a = args.a; | 35 | this._a = args.a; |
38 | this._b = args.b; | 36 | this._b = args.b; |
39 | this._G = args.G; | 37 | this._G = args.G; |
40 | this._r = args.r; | 38 | this._r = args.r; |
41 | this._h = args.h; | 39 | this._h = args.h; |
42 | 40 | ||
43 | this._finiteField = null; | 41 | this._finiteField = null; |
44 | 42 | ||
45 | return this; | 43 | return this; |
46 | } | 44 | } |
47 | 45 | ||
48 | Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { | 46 | Clipperz.Crypto.ECC.BinaryField.Curve.prototype = MochiKit.Base.update(null, { |
49 | 47 | ||
50 | 'asString': function() { | 48 | 'asString': function() { |
51 | return "Clipperz.Crypto.ECC.BinaryField.Curve"; | 49 | return "Clipperz.Crypto.ECC.BinaryField.Curve"; |
52 | }, | 50 | }, |
53 | 51 | ||
54 | //----------------------------------------------------------------------------- | 52 | //----------------------------------------------------------------------------- |
55 | 53 | ||
56 | 'modulus': function() { | 54 | 'modulus': function() { |
57 | return this._modulus; | 55 | return this._modulus; |
58 | }, | 56 | }, |
59 | 57 | ||
60 | 'a': function() { | 58 | 'a': function() { |
61 | return this._a; | 59 | return this._a; |
62 | }, | 60 | }, |
63 | 61 | ||
64 | 'b': function() { | 62 | 'b': function() { |
65 | return this._b; | 63 | return this._b; |
66 | }, | 64 | }, |
67 | 65 | ||
68 | 'G': function() { | 66 | 'G': function() { |
69 | return this._G; | 67 | return this._G; |
70 | }, | 68 | }, |
71 | 69 | ||
72 | 'r': function() { | 70 | 'r': function() { |
73 | return this._r; | 71 | return this._r; |
74 | }, | 72 | }, |
75 | 73 | ||
76 | 'h': function() { | 74 | 'h': function() { |
77 | return this._h; | 75 | return this._h; |
78 | }, | 76 | }, |
79 | 77 | ||
80 | //----------------------------------------------------------------------------- | 78 | //----------------------------------------------------------------------------- |
81 | 79 | ||
82 | 'finiteField': function() { | 80 | 'finiteField': function() { |
83 | if (this._finiteField == null) { | 81 | if (this._finiteField == null) { |
84 | this._finiteField = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:this.modulus()}) | 82 | this._finiteField = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:this.modulus()}) |
85 | } | 83 | } |
86 | 84 | ||
87 | return this._finiteField; | 85 | return this._finiteField; |
88 | }, | 86 | }, |
89 | 87 | ||
90 | //----------------------------------------------------------------------------- | 88 | //----------------------------------------------------------------------------- |
91 | 89 | ||
92 | 'negate': function(aPointA) { | 90 | 'negate': function(aPointA) { |
93 | var result; | 91 | var result; |
94 | 92 | ||
95 | result = new Clipperz.Crypto.ECC.Point({x:aPointA.x(), y:this.finiteField().add(aPointA.y(), aPointA.x())}) | 93 | result = new Clipperz.Crypto.ECC.Point({x:aPointA.x(), y:this.finiteField().add(aPointA.y(), aPointA.x())}) |
96 | 94 | ||
97 | return result; | 95 | return result; |
98 | }, | 96 | }, |
99 | 97 | ||
100 | //----------------------------------------------------------------------------- | 98 | //----------------------------------------------------------------------------- |
101 | 99 | ||
102 | 'add': function(aPointA, aPointB) { | 100 | 'add': function(aPointA, aPointB) { |
103 | var result; | 101 | var result; |
104 | 102 | ||
105 | //console.log(">>> ECC.BinaryField.Curve.add"); | 103 | //console.log(">>> ECC.BinaryField.Curve.add"); |
106 | if (aPointA.isZero()) { | 104 | if (aPointA.isZero()) { |
107 | //console.log("--- pointA == zero"); | 105 | //console.log("--- pointA == zero"); |
108 | result = aPointB; | 106 | result = aPointB; |
109 | } else if (aPointB.isZero()) { | 107 | } else if (aPointB.isZero()) { |
110 | //console.log("--- pointB == zero"); | 108 | //console.log("--- pointB == zero"); |
111 | result = aPointA; | 109 | result = aPointA; |
112 | } else if ((aPointA.x().compare(aPointB.x()) == 0) && ((aPointA.y().compare(aPointB.y()) != 0) || aPointB.x().isZero())) { | 110 | } else if ((aPointA.x().compare(aPointB.x()) == 0) && ((aPointA.y().compare(aPointB.y()) != 0) || aPointB.x().isZero())) { |
113 | //console.log("compare A.x - B.x: ", aPointA.x().compare(aPointB.x())); | 111 | //console.log("compare A.x - B.x: ", aPointA.x().compare(aPointB.x())); |
114 | //console.log("compare A.y - B.y: ", (aPointA.y().compare(aPointB.y()) != 0)); | 112 | //console.log("compare A.y - B.y: ", (aPointA.y().compare(aPointB.y()) != 0)); |
115 | //console.log("compare B.x.isZero(): ", aPointB.x().isZero()); | 113 | //console.log("compare B.x.isZero(): ", aPointB.x().isZero()); |
116 | 114 | ||
117 | //console.log("--- result = zero"); | 115 | //console.log("--- result = zero"); |
118 | result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); | 116 | result = new Clipperz.Crypto.ECC.BinaryField.Point({x:Clipperz.Crypto.ECC.BinaryField.Value.O, y:Clipperz.Crypto.ECC.BinaryField.Value.O}); |
diff --git a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js index 650b479..de1e6a8 100644 --- a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js +++ b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } | 27 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } |
30 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } | 28 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } |
31 | 29 | ||
32 | Clipperz.Crypto.ECC.BinaryField.FiniteField = function(args) { | 30 | Clipperz.Crypto.ECC.BinaryField.FiniteField = function(args) { |
33 | args = args || {}; | 31 | args = args || {}; |
34 | this._modulus = args.modulus; | 32 | this._modulus = args.modulus; |
35 | 33 | ||
36 | return this; | 34 | return this; |
37 | } | 35 | } |
38 | 36 | ||
39 | Clipperz.Crypto.ECC.BinaryField.FiniteField.prototype = MochiKit.Base.update(null, { | 37 | Clipperz.Crypto.ECC.BinaryField.FiniteField.prototype = MochiKit.Base.update(null, { |
40 | 38 | ||
41 | 'asString': function() { | 39 | 'asString': function() { |
42 | return "Clipperz.Crypto.ECC.BinaryField.FiniteField (" + this.modulus().asString() + ")"; | 40 | return "Clipperz.Crypto.ECC.BinaryField.FiniteField (" + this.modulus().asString() + ")"; |
43 | }, | 41 | }, |
44 | 42 | ||
45 | //----------------------------------------------------------------------------- | 43 | //----------------------------------------------------------------------------- |
46 | 44 | ||
47 | 'modulus': function() { | 45 | 'modulus': function() { |
48 | return this._modulus; | 46 | return this._modulus; |
49 | }, | 47 | }, |
50 | 48 | ||
51 | //----------------------------------------------------------------------------- | 49 | //----------------------------------------------------------------------------- |
52 | 50 | ||
53 | '_module': function(aValue) { | 51 | '_module': function(aValue) { |
54 | varresult; | 52 | varresult; |
55 | var modulusComparison; | 53 | var modulusComparison; |
56 | //console.log(">>> binaryField.finiteField.(standard)module"); | 54 | //console.log(">>> binaryField.finiteField.(standard)module"); |
57 | 55 | ||
58 | modulusComparison = Clipperz.Crypto.ECC.BinaryField.Value._compare(aValue, this.modulus()._value); | 56 | modulusComparison = Clipperz.Crypto.ECC.BinaryField.Value._compare(aValue, this.modulus()._value); |
59 | 57 | ||
60 | if (modulusComparison < 0) { | 58 | if (modulusComparison < 0) { |
61 | result = aValue; | 59 | result = aValue; |
62 | } else if (modulusComparison == 0) { | 60 | } else if (modulusComparison == 0) { |
63 | result = [0]; | 61 | result = [0]; |
64 | } else { | 62 | } else { |
65 | var modulusBitSize; | 63 | var modulusBitSize; |
66 | var resultBitSize; | 64 | var resultBitSize; |
67 | 65 | ||
68 | result = aValue; | 66 | result = aValue; |
69 | 67 | ||
70 | modulusBitSize = this.modulus().bitSize(); | 68 | modulusBitSize = this.modulus().bitSize(); |
71 | resultBitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(result); | 69 | resultBitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(result); |
72 | while (resultBitSize >= modulusBitSize) { | 70 | while (resultBitSize >= modulusBitSize) { |
73 | Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(this.modulus()._value, resultBitSize - modulusBitSize)); | 71 | Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, Clipperz.Crypto.ECC.BinaryField.Value._shiftLeft(this.modulus()._value, resultBitSize - modulusBitSize)); |
74 | resultBitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(result); | 72 | resultBitSize = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(result); |
75 | } | 73 | } |
76 | } | 74 | } |
77 | //console.log("<<< binaryField.finiteField.(standard)module"); | 75 | //console.log("<<< binaryField.finiteField.(standard)module"); |
78 | 76 | ||
79 | return result; | 77 | return result; |
80 | }, | 78 | }, |
81 | 79 | ||
82 | 'module': function(aValue) { | 80 | 'module': function(aValue) { |
83 | return new Clipperz.Crypto.ECC.BinaryField.Value(this._module(aValue._value.slice(0))); | 81 | return new Clipperz.Crypto.ECC.BinaryField.Value(this._module(aValue._value.slice(0))); |
84 | }, | 82 | }, |
85 | 83 | ||
86 | //----------------------------------------------------------------------------- | 84 | //----------------------------------------------------------------------------- |
87 | 85 | ||
88 | '_add': function(a, b) { | 86 | '_add': function(a, b) { |
89 | return Clipperz.Crypto.ECC.BinaryField.Value._xor(a, b); | 87 | return Clipperz.Crypto.ECC.BinaryField.Value._xor(a, b); |
90 | }, | 88 | }, |
91 | 89 | ||
92 | '_overwriteAdd': function(a, b) { | 90 | '_overwriteAdd': function(a, b) { |
93 | Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(a, b); | 91 | Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(a, b); |
94 | }, | 92 | }, |
95 | 93 | ||
96 | 'add': function(a, b) { | 94 | 'add': function(a, b) { |
97 | return new Clipperz.Crypto.ECC.BinaryField.Value(this._add(a._value, b._value)); | 95 | return new Clipperz.Crypto.ECC.BinaryField.Value(this._add(a._value, b._value)); |
98 | }, | 96 | }, |
99 | 97 | ||
100 | //----------------------------------------------------------------------------- | 98 | //----------------------------------------------------------------------------- |
101 | 99 | ||
102 | 'negate': function(aValue) { | 100 | 'negate': function(aValue) { |
103 | return aValue.clone(); | 101 | return aValue.clone(); |
104 | }, | 102 | }, |
105 | 103 | ||
106 | //----------------------------------------------------------------------------- | 104 | //----------------------------------------------------------------------------- |
107 | 105 | ||
108 | '_multiply': function(a, b) { | 106 | '_multiply': function(a, b) { |
109 | var result; | 107 | var result; |
110 | var valueToXor; | 108 | var valueToXor; |
111 | var i,c; | 109 | var i,c; |
112 | 110 | ||
113 | result = [0]; | 111 | result = [0]; |
114 | valueToXor = b; | 112 | valueToXor = b; |
115 | c = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(a); | 113 | c = Clipperz.Crypto.ECC.BinaryField.Value._bitSize(a); |
116 | for (i=0; i<c; i++) { | 114 | for (i=0; i<c; i++) { |
117 | if (Clipperz.Crypto.ECC.BinaryField.Value._isBitSet(a, i) === true) { | 115 | if (Clipperz.Crypto.ECC.BinaryField.Value._isBitSet(a, i) === true) { |
118 | Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, valueToXor); | 116 | Clipperz.Crypto.ECC.BinaryField.Value._overwriteXor(result, valueToXor); |
diff --git a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Point.js b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Point.js index 6661839..c5db6c6 100644 --- a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Point.js +++ b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Point.js | |||
@@ -1,64 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } | 27 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } |
30 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } | 28 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } |
31 | 29 | ||
32 | Clipperz.Crypto.ECC.BinaryField.Point = function(args) { | 30 | Clipperz.Crypto.ECC.BinaryField.Point = function(args) { |
33 | args = args || {}; | 31 | args = args || {}; |
34 | this._x = args.x; | 32 | this._x = args.x; |
35 | this._y = args.y; | 33 | this._y = args.y; |
36 | 34 | ||
37 | return this; | 35 | return this; |
38 | } | 36 | } |
39 | 37 | ||
40 | Clipperz.Crypto.ECC.BinaryField.Point.prototype = MochiKit.Base.update(null, { | 38 | Clipperz.Crypto.ECC.BinaryField.Point.prototype = MochiKit.Base.update(null, { |
41 | 39 | ||
42 | 'asString': function() { | 40 | 'asString': function() { |
43 | return "Clipperz.Crypto.ECC.BinaryField.Point (" + this.x() + ", " + this.y() + ")"; | 41 | return "Clipperz.Crypto.ECC.BinaryField.Point (" + this.x() + ", " + this.y() + ")"; |
44 | }, | 42 | }, |
45 | 43 | ||
46 | //----------------------------------------------------------------------------- | 44 | //----------------------------------------------------------------------------- |
47 | 45 | ||
48 | 'x': function() { | 46 | 'x': function() { |
49 | return this._x; | 47 | return this._x; |
50 | }, | 48 | }, |
51 | 49 | ||
52 | 'y': function() { | 50 | 'y': function() { |
53 | return this._y; | 51 | return this._y; |
54 | }, | 52 | }, |
55 | 53 | ||
56 | //----------------------------------------------------------------------------- | 54 | //----------------------------------------------------------------------------- |
57 | 55 | ||
58 | 'isZero': function() { | 56 | 'isZero': function() { |
59 | return (this.x().isZero() && this.y().isZero()) | 57 | return (this.x().isZero() && this.y().isZero()) |
60 | }, | 58 | }, |
61 | 59 | ||
62 | //----------------------------------------------------------------------------- | 60 | //----------------------------------------------------------------------------- |
63 | __syntaxFix__: "syntax fix" | 61 | __syntaxFix__: "syntax fix" |
64 | }); | 62 | }); |
diff --git a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Value.js b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Value.js index b5beafa..278c299 100644 --- a/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Value.js +++ b/frontend/beta/js/Clipperz/Crypto/ECC/BinaryField/Value.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.ECC depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } | 27 | if (typeof(Clipperz.Crypto.ECC) == 'undefined') { Clipperz.Crypto.ECC = {}; } |
30 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } | 28 | if (typeof(Clipperz.Crypto.ECC.BinaryField) == 'undefined') { Clipperz.Crypto.ECC.BinaryField = {}; } |
31 | 29 | ||
32 | Clipperz.Crypto.ECC.BinaryField.Value = function(aValue, aBase) { | 30 | Clipperz.Crypto.ECC.BinaryField.Value = function(aValue, aBase) { |
33 | if (aValue.constructor == String) { | 31 | if (aValue.constructor == String) { |
34 | varvalue; | 32 | varvalue; |
35 | varstringLength; | 33 | varstringLength; |
36 | var numberOfWords; | 34 | var numberOfWords; |
37 | vari,c; | 35 | vari,c; |
38 | 36 | ||
39 | if (aBase != 16) { | 37 | if (aBase != 16) { |
40 | throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; | 38 | throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; |
41 | } | 39 | } |
42 | 40 | ||
43 | value = aValue.replace(/ /g, ''); | 41 | value = aValue.replace(/ /g, ''); |
44 | stringLength = value.length; | 42 | stringLength = value.length; |
45 | numberOfWords = Math.ceil(stringLength / 8); | 43 | numberOfWords = Math.ceil(stringLength / 8); |
46 | this._value = new Array(numberOfWords); | 44 | this._value = new Array(numberOfWords); |
47 | 45 | ||
48 | c = numberOfWords; | 46 | c = numberOfWords; |
49 | for (i=0; i<c; i++) { | 47 | for (i=0; i<c; i++) { |
50 | varword; | 48 | varword; |
51 | 49 | ||
52 | if (i < (c-1)) { | 50 | if (i < (c-1)) { |
53 | word = parseInt(value.substr(stringLength-((i+1)*8), 8), 16); | 51 | word = parseInt(value.substr(stringLength-((i+1)*8), 8), 16); |
54 | } else { | 52 | } else { |
55 | word = parseInt(value.substr(0, stringLength-(i*8)), 16); | 53 | word = parseInt(value.substr(0, stringLength-(i*8)), 16); |
56 | } | 54 | } |
57 | 55 | ||
58 | this._value[i] = word; | 56 | this._value[i] = word; |
59 | } | 57 | } |
60 | } else if (aValue.constructor == Array) { | 58 | } else if (aValue.constructor == Array) { |
61 | var itemsToCopy; | 59 | var itemsToCopy; |
62 | 60 | ||
63 | itemsToCopy = aValue.length; | 61 | itemsToCopy = aValue.length; |
64 | while (aValue[itemsToCopy - 1] == 0) { | 62 | while (aValue[itemsToCopy - 1] == 0) { |
65 | itemsToCopy --; | 63 | itemsToCopy --; |
66 | } | 64 | } |
67 | 65 | ||
68 | this._value = aValue.slice(0, itemsToCopy); | 66 | this._value = aValue.slice(0, itemsToCopy); |
69 | } else if (aValue.constructor == Number) { | 67 | } else if (aValue.constructor == Number) { |
70 | this._value = [aValue]; | 68 | this._value = [aValue]; |
71 | } else { | 69 | } else { |
72 | // throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedConstructorValueType; | 70 | // throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedConstructorValueType; |
73 | } | 71 | } |
74 | 72 | ||
75 | return this; | 73 | return this; |
76 | } | 74 | } |
77 | 75 | ||
78 | Clipperz.Crypto.ECC.BinaryField.Value.prototype = MochiKit.Base.update(null, { | 76 | Clipperz.Crypto.ECC.BinaryField.Value.prototype = MochiKit.Base.update(null, { |
79 | 77 | ||
80 | 'value': function() { | 78 | 'value': function() { |
81 | return this._value; | 79 | return this._value; |
82 | }, | 80 | }, |
83 | 81 | ||
84 | //----------------------------------------------------------------------------- | 82 | //----------------------------------------------------------------------------- |
85 | 83 | ||
86 | 'wordSize': function() { | 84 | 'wordSize': function() { |
87 | return this._value.length | 85 | return this._value.length |
88 | }, | 86 | }, |
89 | 87 | ||
90 | //----------------------------------------------------------------------------- | 88 | //----------------------------------------------------------------------------- |
91 | 89 | ||
92 | 'clone': function() { | 90 | 'clone': function() { |
93 | return new Clipperz.Crypto.ECC.BinaryField.Value(this._value.slice(0)); | 91 | return new Clipperz.Crypto.ECC.BinaryField.Value(this._value.slice(0)); |
94 | }, | 92 | }, |
95 | 93 | ||
96 | //----------------------------------------------------------------------------- | 94 | //----------------------------------------------------------------------------- |
97 | 95 | ||
98 | 'isZero': function() { | 96 | 'isZero': function() { |
99 | return (this.compare(Clipperz.Crypto.ECC.BinaryField.Value.O) == 0); | 97 | return (this.compare(Clipperz.Crypto.ECC.BinaryField.Value.O) == 0); |
100 | }, | 98 | }, |
101 | 99 | ||
102 | //----------------------------------------------------------------------------- | 100 | //----------------------------------------------------------------------------- |
103 | 101 | ||
104 | 'asString': function(aBase) { | 102 | 'asString': function(aBase) { |
105 | varresult; | 103 | varresult; |
106 | var i,c; | 104 | var i,c; |
107 | 105 | ||
108 | if (aBase != 16) { | 106 | if (aBase != 16) { |
109 | throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; | 107 | throw Clipperz.Crypto.ECC.BinaryField.Value.exception.UnsupportedBase; |
110 | } | 108 | } |
111 | 109 | ||
112 | result = ""; | 110 | result = ""; |
113 | c = this.wordSize(); | 111 | c = this.wordSize(); |
114 | for (i=0; i<c; i++) { | 112 | for (i=0; i<c; i++) { |
115 | varwordAsString; | 113 | varwordAsString; |
116 | 114 | ||
117 | // wordAsString = ("00000000" + this.value()[i].toString(16)); | 115 | // wordAsString = ("00000000" + this.value()[i].toString(16)); |
118 | wordAsString = ("00000000" + this._value[i].toString(16)); | 116 | wordAsString = ("00000000" + this._value[i].toString(16)); |
diff --git a/frontend/beta/js/Clipperz/Crypto/PRNG.js b/frontend/beta/js/Clipperz/Crypto/PRNG.js index 39d0045..b5c3f8a 100644 --- a/frontend/beta/js/Clipperz/Crypto/PRNG.js +++ b/frontend/beta/js/Clipperz/Crypto/PRNG.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | try { if (typeof(Clipperz.Crypto.SHA) == 'undefined') { throw ""; }} catch (e) { | 28 | try { if (typeof(Clipperz.Crypto.SHA) == 'undefined') { throw ""; }} catch (e) { |
31 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.SHA!"; | 29 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.SHA!"; |
32 | } | 30 | } |
33 | 31 | ||
34 | try { if (typeof(Clipperz.Crypto.AES) == 'undefined') { throw ""; }} catch (e) { | 32 | try { if (typeof(Clipperz.Crypto.AES) == 'undefined') { throw ""; }} catch (e) { |
35 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.AES!"; | 33 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.AES!"; |
36 | } | 34 | } |
37 | 35 | ||
38 | if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { Clipperz.Crypto.PRNG = {}; } | 36 | if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { Clipperz.Crypto.PRNG = {}; } |
39 | 37 | ||
40 | //############################################################################# | 38 | //############################################################################# |
41 | 39 | ||
42 | Clipperz.Crypto.PRNG.EntropyAccumulator = function(args) { | 40 | Clipperz.Crypto.PRNG.EntropyAccumulator = function(args) { |
43 | args = args || {}; | 41 | args = args || {}; |
44 | //MochiKit.Base.bindMethods(this); | 42 | //MochiKit.Base.bindMethods(this); |
45 | 43 | ||
46 | this._stack = new Clipperz.ByteArray(); | 44 | this._stack = new Clipperz.ByteArray(); |
47 | this._maxStackLengthBeforeHashing = args.maxStackLengthBeforeHashing || 256; | 45 | this._maxStackLengthBeforeHashing = args.maxStackLengthBeforeHashing || 256; |
48 | return this; | 46 | return this; |
49 | } | 47 | } |
50 | 48 | ||
51 | Clipperz.Crypto.PRNG.EntropyAccumulator.prototype = MochiKit.Base.update(null, { | 49 | Clipperz.Crypto.PRNG.EntropyAccumulator.prototype = MochiKit.Base.update(null, { |
52 | 50 | ||
53 | 'toString': function() { | 51 | 'toString': function() { |
54 | return "Clipperz.Crypto.PRNG.EntropyAccumulator"; | 52 | return "Clipperz.Crypto.PRNG.EntropyAccumulator"; |
55 | }, | 53 | }, |
56 | 54 | ||
57 | //------------------------------------------------------------------------- | 55 | //------------------------------------------------------------------------- |
58 | 56 | ||
59 | 'stack': function() { | 57 | 'stack': function() { |
60 | return this._stack; | 58 | return this._stack; |
61 | }, | 59 | }, |
62 | 60 | ||
63 | 'setStack': function(aValue) { | 61 | 'setStack': function(aValue) { |
64 | this._stack = aValue; | 62 | this._stack = aValue; |
65 | }, | 63 | }, |
66 | 64 | ||
67 | 'resetStack': function() { | 65 | 'resetStack': function() { |
68 | this.stack().reset(); | 66 | this.stack().reset(); |
69 | }, | 67 | }, |
70 | 68 | ||
71 | 'maxStackLengthBeforeHashing': function() { | 69 | 'maxStackLengthBeforeHashing': function() { |
72 | return this._maxStackLengthBeforeHashing; | 70 | return this._maxStackLengthBeforeHashing; |
73 | }, | 71 | }, |
74 | 72 | ||
75 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
76 | 74 | ||
77 | 'addRandomByte': function(aValue) { | 75 | 'addRandomByte': function(aValue) { |
78 | this.stack().appendByte(aValue); | 76 | this.stack().appendByte(aValue); |
79 | 77 | ||
80 | if (this.stack().length() > this.maxStackLengthBeforeHashing()) { | 78 | if (this.stack().length() > this.maxStackLengthBeforeHashing()) { |
81 | this.setStack(Clipperz.Crypto.SHA.sha_d256(this.stack())); | 79 | this.setStack(Clipperz.Crypto.SHA.sha_d256(this.stack())); |
82 | } | 80 | } |
83 | }, | 81 | }, |
84 | 82 | ||
85 | //------------------------------------------------------------------------- | 83 | //------------------------------------------------------------------------- |
86 | __syntaxFix__: "syntax fix" | 84 | __syntaxFix__: "syntax fix" |
87 | }); | 85 | }); |
88 | 86 | ||
89 | //############################################################################# | 87 | //############################################################################# |
90 | 88 | ||
91 | Clipperz.Crypto.PRNG.RandomnessSource = function(args) { | 89 | Clipperz.Crypto.PRNG.RandomnessSource = function(args) { |
92 | args = args || {}; | 90 | args = args || {}; |
93 | MochiKit.Base.bindMethods(this); | 91 | MochiKit.Base.bindMethods(this); |
94 | 92 | ||
95 | this._generator = args.generator || null; | 93 | this._generator = args.generator || null; |
96 | this._sourceId = args.sourceId || null; | 94 | this._sourceId = args.sourceId || null; |
97 | this._boostMode = args.boostMode || false; | 95 | this._boostMode = args.boostMode || false; |
98 | 96 | ||
99 | this._nextPoolIndex = 0; | 97 | this._nextPoolIndex = 0; |
100 | 98 | ||
101 | return this; | 99 | return this; |
102 | } | 100 | } |
103 | 101 | ||
104 | Clipperz.Crypto.PRNG.RandomnessSource.prototype = MochiKit.Base.update(null, { | 102 | Clipperz.Crypto.PRNG.RandomnessSource.prototype = MochiKit.Base.update(null, { |
105 | 103 | ||
106 | 'generator': function() { | 104 | 'generator': function() { |
107 | return this._generator; | 105 | return this._generator; |
108 | }, | 106 | }, |
109 | 107 | ||
110 | 'setGenerator': function(aValue) { | 108 | 'setGenerator': function(aValue) { |
111 | this._generator = aValue; | 109 | this._generator = aValue; |
112 | }, | 110 | }, |
113 | 111 | ||
114 | //------------------------------------------------------------------------- | 112 | //------------------------------------------------------------------------- |
115 | 113 | ||
116 | 'boostMode': function() { | 114 | 'boostMode': function() { |
117 | return this._boostMode; | 115 | return this._boostMode; |
118 | }, | 116 | }, |
diff --git a/frontend/beta/js/Clipperz/Crypto/RSA.js b/frontend/beta/js/Clipperz/Crypto/RSA.js index 6844dba..5a480f1 100644 --- a/frontend/beta/js/Clipperz/Crypto/RSA.js +++ b/frontend/beta/js/Clipperz/Crypto/RSA.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.RSA depends on Clipperz.Crypto.BigInt!"; | 25 | throw "Clipperz.Crypto.RSA depends on Clipperz.Crypto.BigInt!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.Crypto.RSA) == 'undefined') { Clipperz.Crypto.RSA = {}; } | 28 | if (typeof(Clipperz.Crypto.RSA) == 'undefined') { Clipperz.Crypto.RSA = {}; } |
31 | 29 | ||
32 | Clipperz.Crypto.RSA.VERSION = "0.1"; | 30 | Clipperz.Crypto.RSA.VERSION = "0.1"; |
33 | Clipperz.Crypto.RSA.NAME = "Clipperz.RSA"; | 31 | Clipperz.Crypto.RSA.NAME = "Clipperz.RSA"; |
34 | 32 | ||
35 | //############################################################################# | 33 | //############################################################################# |
36 | 34 | ||
37 | MochiKit.Base.update(Clipperz.Crypto.RSA, { | 35 | MochiKit.Base.update(Clipperz.Crypto.RSA, { |
38 | 36 | ||
39 | //------------------------------------------------------------------------- | 37 | //------------------------------------------------------------------------- |
40 | 38 | ||
41 | 'publicKeyWithValues': function (e, d, n) { | 39 | 'publicKeyWithValues': function (e, d, n) { |
42 | varresult; | 40 | varresult; |
43 | 41 | ||
44 | result = {}; | 42 | result = {}; |
45 | 43 | ||
46 | if (e.isBigInt) { | 44 | if (e.isBigInt) { |
47 | result.e = e; | 45 | result.e = e; |
48 | } else { | 46 | } else { |
49 | result.e = new Clipperz.Crypto.BigInt(e, 16); | 47 | result.e = new Clipperz.Crypto.BigInt(e, 16); |
50 | } | 48 | } |
51 | 49 | ||
52 | if (d.isBigInt) { | 50 | if (d.isBigInt) { |
53 | result.d = d; | 51 | result.d = d; |
54 | } else { | 52 | } else { |
55 | result.d = new Clipperz.Crypto.BigInt(d, 16); | 53 | result.d = new Clipperz.Crypto.BigInt(d, 16); |
56 | } | 54 | } |
57 | 55 | ||
58 | if (n.isBigInt) { | 56 | if (n.isBigInt) { |
59 | result.n = n; | 57 | result.n = n; |
60 | } else { | 58 | } else { |
61 | result.n = new Clipperz.Crypto.BigInt(n, 16); | 59 | result.n = new Clipperz.Crypto.BigInt(n, 16); |
62 | } | 60 | } |
63 | 61 | ||
64 | return result; | 62 | return result; |
65 | }, | 63 | }, |
66 | 64 | ||
67 | 'privateKeyWithValues': function(e, d, n) { | 65 | 'privateKeyWithValues': function(e, d, n) { |
68 | return Clipperz.Crypto.RSA.publicKeyWithValues(e, d, n); | 66 | return Clipperz.Crypto.RSA.publicKeyWithValues(e, d, n); |
69 | }, | 67 | }, |
70 | 68 | ||
71 | //----------------------------------------------------------------------------- | 69 | //----------------------------------------------------------------------------- |
72 | 70 | ||
73 | 'encryptUsingPublicKey': function (aKey, aMessage) { | 71 | 'encryptUsingPublicKey': function (aKey, aMessage) { |
74 | varmessageValue; | 72 | varmessageValue; |
75 | varresult; | 73 | varresult; |
76 | 74 | ||
77 | messageValue = new Clipperz.Crypto.BigInt(aMessage, 16); | 75 | messageValue = new Clipperz.Crypto.BigInt(aMessage, 16); |
78 | result = messageValue.powerModule(aKey.e, aKey.n); | 76 | result = messageValue.powerModule(aKey.e, aKey.n); |
79 | 77 | ||
80 | return result.asString(16); | 78 | return result.asString(16); |
81 | }, | 79 | }, |
82 | 80 | ||
83 | //............................................................................. | 81 | //............................................................................. |
84 | 82 | ||
85 | 'decryptUsingPublicKey': function (aKey, aMessage) { | 83 | 'decryptUsingPublicKey': function (aKey, aMessage) { |
86 | return Clipperz.Crypto.RSA.encryptUsingPublicKey(aKey, aMessage); | 84 | return Clipperz.Crypto.RSA.encryptUsingPublicKey(aKey, aMessage); |
87 | }, | 85 | }, |
88 | 86 | ||
89 | //----------------------------------------------------------------------------- | 87 | //----------------------------------------------------------------------------- |
90 | 88 | ||
91 | 'encryptUsingPrivateKey': function (aKey, aMessage) { | 89 | 'encryptUsingPrivateKey': function (aKey, aMessage) { |
92 | varmessageValue; | 90 | varmessageValue; |
93 | varresult; | 91 | varresult; |
94 | 92 | ||
95 | messageValue = new Clipperz.Crypto.BigInt(aMessage, 16); | 93 | messageValue = new Clipperz.Crypto.BigInt(aMessage, 16); |
96 | result = messageValue.powerModule(aKey.d, aKey.n); | 94 | result = messageValue.powerModule(aKey.d, aKey.n); |
97 | 95 | ||
98 | return result.asString(16); | 96 | return result.asString(16); |
99 | }, | 97 | }, |
100 | 98 | ||
101 | //............................................................................. | 99 | //............................................................................. |
102 | 100 | ||
103 | 'decryptUsingPrivateKey': function (aKey, aMessage) { | 101 | 'decryptUsingPrivateKey': function (aKey, aMessage) { |
104 | return Clipperz.Crypto.RSA.encryptUsingPrivateKey(aKey, aMessage); | 102 | return Clipperz.Crypto.RSA.encryptUsingPrivateKey(aKey, aMessage); |
105 | }, | 103 | }, |
106 | 104 | ||
107 | //----------------------------------------------------------------------------- | 105 | //----------------------------------------------------------------------------- |
108 | 106 | ||
109 | 'generatePublicKey': function(aNumberOfBits) { | 107 | 'generatePublicKey': function(aNumberOfBits) { |
110 | varresult; | 108 | varresult; |
111 | vare; | 109 | vare; |
112 | vard; | 110 | vard; |
113 | varn; | 111 | varn; |
114 | 112 | ||
115 | e = new Clipperz.Crypto.BigInt("10001", 16); | 113 | e = new Clipperz.Crypto.BigInt("10001", 16); |
116 | 114 | ||
117 | { | 115 | { |
118 | var p, q; | 116 | var p, q; |
diff --git a/frontend/beta/js/Clipperz/Crypto/SHA.js b/frontend/beta/js/Clipperz/Crypto/SHA.js index 635eb90..9605d1c 100644 --- a/frontend/beta/js/Clipperz/Crypto/SHA.js +++ b/frontend/beta/js/Clipperz/Crypto/SHA.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } | 28 | if (typeof(Clipperz.Crypto) == 'undefined') { Clipperz.Crypto = {}; } |
31 | if (typeof(Clipperz.Crypto.SHA) == 'undefined') { Clipperz.Crypto.SHA = {}; } | 29 | if (typeof(Clipperz.Crypto.SHA) == 'undefined') { Clipperz.Crypto.SHA = {}; } |
32 | 30 | ||
33 | Clipperz.Crypto.SHA.VERSION = "0.3"; | 31 | Clipperz.Crypto.SHA.VERSION = "0.3"; |
34 | Clipperz.Crypto.SHA.NAME = "Clipperz.Crypto.SHA"; | 32 | Clipperz.Crypto.SHA.NAME = "Clipperz.Crypto.SHA"; |
35 | 33 | ||
36 | MochiKit.Base.update(Clipperz.Crypto.SHA, { | 34 | MochiKit.Base.update(Clipperz.Crypto.SHA, { |
37 | 35 | ||
38 | '__repr__': function () { | 36 | '__repr__': function () { |
39 | return "[" + this.NAME + " " + this.VERSION + "]"; | 37 | return "[" + this.NAME + " " + this.VERSION + "]"; |
40 | }, | 38 | }, |
41 | 39 | ||
42 | 'toString': function () { | 40 | 'toString': function () { |
43 | return this.__repr__(); | 41 | return this.__repr__(); |
44 | }, | 42 | }, |
45 | 43 | ||
46 | //----------------------------------------------------------------------------- | 44 | //----------------------------------------------------------------------------- |
47 | 45 | ||
48 | 'rotateRight': function(aValue, aNumberOfBits) { | 46 | 'rotateRight': function(aValue, aNumberOfBits) { |
49 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.rotateRight"); | 47 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.rotateRight"); |
50 | var result; | 48 | var result; |
51 | 49 | ||
52 | result = (aValue >>> aNumberOfBits) | (aValue << (32 - aNumberOfBits)); | 50 | result = (aValue >>> aNumberOfBits) | (aValue << (32 - aNumberOfBits)); |
53 | 51 | ||
54 | //Clipperz.Profile.stop("Clipperz.Crypto.SHA.rotateRight"); | 52 | //Clipperz.Profile.stop("Clipperz.Crypto.SHA.rotateRight"); |
55 | return result; | 53 | return result; |
56 | }, | 54 | }, |
57 | 55 | ||
58 | 'shiftRight': function(aValue, aNumberOfBits) { | 56 | 'shiftRight': function(aValue, aNumberOfBits) { |
59 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.shiftRight"); | 57 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.shiftRight"); |
60 | var result; | 58 | var result; |
61 | 59 | ||
62 | result = aValue >>> aNumberOfBits; | 60 | result = aValue >>> aNumberOfBits; |
63 | 61 | ||
64 | //Clipperz.Profile.stop("Clipperz.Crypto.SHA.shiftRight"); | 62 | //Clipperz.Profile.stop("Clipperz.Crypto.SHA.shiftRight"); |
65 | return result; | 63 | return result; |
66 | }, | 64 | }, |
67 | 65 | ||
68 | //----------------------------------------------------------------------------- | 66 | //----------------------------------------------------------------------------- |
69 | 67 | ||
70 | 'safeAdd': function() { | 68 | 'safeAdd': function() { |
71 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.safeAdd"); | 69 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.safeAdd"); |
72 | varresult; | 70 | varresult; |
73 | vari, c; | 71 | vari, c; |
74 | 72 | ||
75 | result = arguments[0]; | 73 | result = arguments[0]; |
76 | c = arguments.length; | 74 | c = arguments.length; |
77 | for (i=1; i<c; i++) { | 75 | for (i=1; i<c; i++) { |
78 | varlowerBytesSum; | 76 | varlowerBytesSum; |
79 | 77 | ||
80 | lowerBytesSum = (result & 0xffff) + (arguments[i] & 0xffff); | 78 | lowerBytesSum = (result & 0xffff) + (arguments[i] & 0xffff); |
81 | result = (((result >> 16) + (arguments[i] >> 16) + (lowerBytesSum >> 16)) << 16) | (lowerBytesSum & 0xffff); | 79 | result = (((result >> 16) + (arguments[i] >> 16) + (lowerBytesSum >> 16)) << 16) | (lowerBytesSum & 0xffff); |
82 | } | 80 | } |
83 | 81 | ||
84 | //Clipperz.Profile.stop("Clipperz.Crypto.SHA.safeAdd"); | 82 | //Clipperz.Profile.stop("Clipperz.Crypto.SHA.safeAdd"); |
85 | return result; | 83 | return result; |
86 | }, | 84 | }, |
87 | 85 | ||
88 | //----------------------------------------------------------------------------- | 86 | //----------------------------------------------------------------------------- |
89 | 87 | ||
90 | 'sha256_array': function(aValue) { | 88 | 'sha256_array': function(aValue) { |
91 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.sha256_array"); | 89 | //Clipperz.Profile.start("Clipperz.Crypto.SHA.sha256_array"); |
92 | varresult; | 90 | varresult; |
93 | varmessage; | 91 | varmessage; |
94 | var h0, h1, h2, h3, h4, h5, h6, h7; | 92 | var h0, h1, h2, h3, h4, h5, h6, h7; |
95 | vark; | 93 | vark; |
96 | varmessageLength; | 94 | varmessageLength; |
97 | varmessageLengthInBits; | 95 | varmessageLengthInBits; |
98 | var_i, _c; | 96 | var_i, _c; |
99 | var charBits; | 97 | var charBits; |
100 | var rotateRight; | 98 | var rotateRight; |
101 | var shiftRight; | 99 | var shiftRight; |
102 | var safeAdd; | 100 | var safeAdd; |
103 | varbytesPerBlock; | 101 | varbytesPerBlock; |
104 | var currentMessageIndex; | 102 | var currentMessageIndex; |
105 | 103 | ||
106 | bytesPerBlock = 512/8; | 104 | bytesPerBlock = 512/8; |
107 | rotateRight = Clipperz.Crypto.SHA.rotateRight; | 105 | rotateRight = Clipperz.Crypto.SHA.rotateRight; |
108 | shiftRight = Clipperz.Crypto.SHA.shiftRight; | 106 | shiftRight = Clipperz.Crypto.SHA.shiftRight; |
109 | safeAdd = Clipperz.Crypto.SHA.safeAdd; | 107 | safeAdd = Clipperz.Crypto.SHA.safeAdd; |
110 | 108 | ||
111 | charBits = 8; | 109 | charBits = 8; |
112 | 110 | ||
113 | h0 = 0x6a09e667; | 111 | h0 = 0x6a09e667; |
114 | h1 = 0xbb67ae85; | 112 | h1 = 0xbb67ae85; |
115 | h2 = 0x3c6ef372; | 113 | h2 = 0x3c6ef372; |
116 | h3 = 0xa54ff53a; | 114 | h3 = 0xa54ff53a; |
117 | h4 = 0x510e527f; | 115 | h4 = 0x510e527f; |
118 | h5 = 0x9b05688c; | 116 | h5 = 0x9b05688c; |
diff --git a/frontend/beta/js/Clipperz/Crypto/SRP.js b/frontend/beta/js/Clipperz/Crypto/SRP.js index 3b25275..8cc80ba 100644 --- a/frontend/beta/js/Clipperz/Crypto/SRP.js +++ b/frontend/beta/js/Clipperz/Crypto/SRP.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
27 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; | 25 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; |
28 | } | 26 | } |
29 | 27 | ||
30 | try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { | 28 | try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { |
31 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.BigInt!"; | 29 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.BigInt!"; |
32 | } | 30 | } |
33 | 31 | ||
34 | try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { | 32 | try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { |
35 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.PRNG!"; | 33 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.PRNG!"; |
36 | } | 34 | } |
37 | 35 | ||
38 | if (typeof(Clipperz.Crypto.SRP) == 'undefined') { Clipperz.Crypto.SRP = {}; } | 36 | if (typeof(Clipperz.Crypto.SRP) == 'undefined') { Clipperz.Crypto.SRP = {}; } |
39 | 37 | ||
40 | Clipperz.Crypto.SRP.VERSION = "0.1"; | 38 | Clipperz.Crypto.SRP.VERSION = "0.1"; |
41 | Clipperz.Crypto.SRP.NAME = "Clipperz.Crypto.SRP"; | 39 | Clipperz.Crypto.SRP.NAME = "Clipperz.Crypto.SRP"; |
42 | 40 | ||
43 | //############################################################################# | 41 | //############################################################################# |
44 | 42 | ||
45 | MochiKit.Base.update(Clipperz.Crypto.SRP, { | 43 | MochiKit.Base.update(Clipperz.Crypto.SRP, { |
46 | 44 | ||
47 | '_n': null, | 45 | '_n': null, |
48 | '_g': null, | 46 | '_g': null, |
49 | //------------------------------------------------------------------------- | 47 | //------------------------------------------------------------------------- |
50 | 48 | ||
51 | 'n': function() { | 49 | 'n': function() { |
52 | if (Clipperz.Crypto.SRP._n == null) { | 50 | if (Clipperz.Crypto.SRP._n == null) { |
53 | Clipperz.Crypto.SRP._n = new Clipperz.Crypto.BigInt("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16); | 51 | Clipperz.Crypto.SRP._n = new Clipperz.Crypto.BigInt("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16); |
54 | } | 52 | } |
55 | 53 | ||
56 | return Clipperz.Crypto.SRP._n; | 54 | return Clipperz.Crypto.SRP._n; |
57 | }, | 55 | }, |
58 | 56 | ||
59 | //------------------------------------------------------------------------- | 57 | //------------------------------------------------------------------------- |
60 | 58 | ||
61 | 'g': function() { | 59 | 'g': function() { |
62 | if (Clipperz.Crypto.SRP._g == null) { | 60 | if (Clipperz.Crypto.SRP._g == null) { |
63 | Clipperz.Crypto.SRP._g = new Clipperz.Crypto.BigInt(2); //eventually 5 (as suggested on the Diffi-Helmann documentation) | 61 | Clipperz.Crypto.SRP._g = new Clipperz.Crypto.BigInt(2); //eventually 5 (as suggested on the Diffi-Helmann documentation) |
64 | } | 62 | } |
65 | 63 | ||
66 | return Clipperz.Crypto.SRP._g; | 64 | return Clipperz.Crypto.SRP._g; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //----------------------------------------------------------------------------- | 67 | //----------------------------------------------------------------------------- |
70 | 68 | ||
71 | 'exception': { | 69 | 'exception': { |
72 | 'InvalidValue': new MochiKit.Base.NamedError("Clipperz.Crypto.SRP.exception.InvalidValue") | 70 | 'InvalidValue': new MochiKit.Base.NamedError("Clipperz.Crypto.SRP.exception.InvalidValue") |
73 | }, | 71 | }, |
74 | 72 | ||
75 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
76 | __syntaxFix__: "syntax fix" | 74 | __syntaxFix__: "syntax fix" |
77 | 75 | ||
78 | }); | 76 | }); |
79 | 77 | ||
80 | //############################################################################# | 78 | //############################################################################# |
81 | // | 79 | // |
82 | // S R P C o n n e c t i o n version 1.0 | 80 | // S R P C o n n e c t i o n version 1.0 |
83 | // | 81 | // |
84 | //============================================================================= | 82 | //============================================================================= |
85 | Clipperz.Crypto.SRP.Connection = function (args) { | 83 | Clipperz.Crypto.SRP.Connection = function (args) { |
86 | args = args || {}; | 84 | args = args || {}; |
87 | 85 | ||
88 | this._C = args.C; | 86 | this._C = args.C; |
89 | this._P = args.P; | 87 | this._P = args.P; |
90 | this.hash = args.hash; | 88 | this.hash = args.hash; |
91 | 89 | ||
92 | this._a = null; | 90 | this._a = null; |
93 | this._A = null; | 91 | this._A = null; |
94 | 92 | ||
95 | this._s = null; | 93 | this._s = null; |
96 | this._B = null; | 94 | this._B = null; |
97 | 95 | ||
98 | this._x = null; | 96 | this._x = null; |
99 | 97 | ||
100 | this._u = null; | 98 | this._u = null; |
101 | this._K = null; | 99 | this._K = null; |
102 | this._M1 = null; | 100 | this._M1 = null; |
103 | this._M2 = null; | 101 | this._M2 = null; |
104 | 102 | ||
105 | this._sessionKey = null; | 103 | this._sessionKey = null; |
106 | 104 | ||
107 | return this; | 105 | return this; |
108 | } | 106 | } |
109 | 107 | ||
110 | Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { | 108 | Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { |
111 | 109 | ||
112 | 'toString': function () { | 110 | 'toString': function () { |
113 | return "Clipperz.Crypto.SRP.Connection (username: " + this.username() + "). Status: " + this.statusDescription(); | 111 | return "Clipperz.Crypto.SRP.Connection (username: " + this.username() + "). Status: " + this.statusDescription(); |
114 | }, | 112 | }, |
115 | 113 | ||
116 | //------------------------------------------------------------------------- | 114 | //------------------------------------------------------------------------- |
117 | 115 | ||
118 | 'C': function () { | 116 | 'C': function () { |