summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/Crypto.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/Crypto.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/Crypto.js48
1 files changed, 23 insertions, 25 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Crypto.js b/frontend/gamma/js/Clipperz/PM/Crypto.js
index 31fe349..cd10e33 100644
--- a/frontend/gamma/js/Clipperz/PM/Crypto.js
+++ b/frontend/gamma/js/Clipperz/PM/Crypto.js
@@ -1,25 +1,23 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
@@ -174,7 +172,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
174 try { 172 try {
175 result = Clipperz.Base.evalJSON(decryptedValue.asString()); 173 result = Clipperz.Base.evalJSON(decryptedValue.asString());
176 } catch (exception) { 174 } catch (exception) {
177 MochiKit.Logging.logError("Error while decrypting data [1]"); 175 Clipperz.logError("Error while decrypting data [1]");
178 throw Clipperz.Crypto.Base.exception.CorruptedMessage; 176 throw Clipperz.Crypto.Base.exception.CorruptedMessage;
179 } 177 }
180 } else { 178 } else {
@@ -206,7 +204,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
206 try { 204 try {
207 result = Clipperz.Base.evalJSON(decryptedData.asString()); 205 result = Clipperz.Base.evalJSON(decryptedData.asString());
208 } catch (exception) { 206 } catch (exception) {
209 MochiKit.Logging.logError("Error while decrypting data [2]"); 207 Clipperz.logError("Error while decrypting data [2]");
210 throw Clipperz.Crypto.Base.exception.CorruptedMessage; 208 throw Clipperz.Crypto.Base.exception.CorruptedMessage;
211 } 209 }
212 210
@@ -291,7 +289,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
291 try { 289 try {
292 result = Clipperz.Base.evalJSON(value); 290 result = Clipperz.Base.evalJSON(value);
293 } catch (exception) { 291 } catch (exception) {
294 MochiKit.Logging.logError("Error while decrypting data [3]"); 292 Clipperz.logError("Error while decrypting data [3]");
295 throw Clipperz.Crypto.Base.exception.CorruptedMessage; 293 throw Clipperz.Crypto.Base.exception.CorruptedMessage;
296 } 294 }
297 } else { 295 } else {
@@ -322,7 +320,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
322 deferredResult.addCallback(MochiKit.Async.wait, 0.1); 320 deferredResult.addCallback(MochiKit.Async.wait, 0.1);
323 deferredResult.addCallback(Clipperz.Base.evalJSON); 321 deferredResult.addCallback(Clipperz.Base.evalJSON);
324 deferredResult.addErrback(function(anError) { 322 deferredResult.addErrback(function(anError) {
325 MochiKit.Logging.logError("Error while decrypting data [4]"); 323 Clipperz.logError("Error while decrypting data [4]");
326 throw Clipperz.Crypto.Base.exception.CorruptedMessage; 324 throw Clipperz.Crypto.Base.exception.CorruptedMessage;
327 }) 325 })
328 } else { 326 } else {
@@ -359,27 +357,27 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
359 var dataToEncrypt; 357 var dataToEncrypt;
360 var encryptedData; 358 var encryptedData;
361 359
362//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); 360//Clipperz.logDebug(">>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt");
363 key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); 361 key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
364//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1"); 362//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1");
365 value = Clipperz.Base.serializeJSON(aValue); 363 value = Clipperz.Base.serializeJSON(aValue);
366//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2"); 364//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2");
367/ * 365/ *
368//MochiKit.Logging.logDebug("--> encrypt.fullSize: " + value.length); 366//Clipperz.logDebug("--> encrypt.fullSize: " + value.length);
369 value = value.replace(/":{"label":"/g, '":{l:"'); 367 value = value.replace(/":{"label":"/g, '":{l:"');
370 value = value.replace(/":{"key":"/g, '":{k:"'); 368 value = value.replace(/":{"key":"/g, '":{k:"');
371 value = value.replace(/":{"notes":"/g, '":{n:"'); 369 value = value.replace(/":{"notes":"/g, '":{n:"');
372 value = value.replace(/":{"record":"/g, '":{r:"'); 370 value = value.replace(/":{"record":"/g, '":{r:"');
373 value = value.replace(/", "label":"/g, '",l:"'); 371 value = value.replace(/", "label":"/g, '",l:"');
374 value = value.replace(/", "favicon":"/g,'",f:"'); 372 value = value.replace(/", "favicon":"/g,'",f:"');
375//MochiKit.Logging.logDebug("<-- encrypt.compressed: " + value.length); 373//Clipperz.logDebug("<-- encrypt.compressed: " + value.length);
376* / 374* /
377 data = new Clipperz.ByteArray(value); 375 data = new Clipperz.ByteArray(value);
378//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3"); 376//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3");
379 encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce); 377 encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce);
380//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4"); 378//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4");
381 result = encryptedData.toBase64String(); 379 result = encryptedData.toBase64String();
382//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); 380//Clipperz.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt");
383 381
384 return result; 382 return result;
385 }, 383 },
@@ -408,7 +406,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
408 try { 406 try {
409 result = Clipperz.Base.evalJSON(value); 407 result = Clipperz.Base.evalJSON(value);
410 } catch (exception) { 408 } catch (exception) {
411 MochiKit.Logging.logError("Error while decrypting data"); 409 Clipperz.logError("Error while decrypting data");
412 throw Clipperz.Crypto.Base.exception.CorruptedMessage; 410 throw Clipperz.Crypto.Base.exception.CorruptedMessage;
413 } 411 }
414 412