From 074e70457c90344b3c1cb236105638d692a0066b Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Fri, 19 Apr 2013 17:09:28 +0200 Subject: [PATCH] Fixed an issue on the AES-CTR block mode The previous version of the CTR encoding was incrementing the counter in a weird way, mixing up data from the previous block. The current fix can correctly decrypt data encoded with AES-CTR using other libraries/languages (currently tested only with Python). --- frontend/beta/js/Clipperz/Crypto/AES_2.js | 829 +++++++++++++++++ frontend/beta/js/Clipperz/PM/Crypto.js | 91 +- frontend/beta/properties/beta.properties.json | 1 + frontend/gamma/js/Clipperz/Crypto/AES_2.js | 843 ++++++++++++++++++ frontend/gamma/js/Clipperz/PM/Crypto.js | 106 ++- .../gamma/js/Clipperz/PM/DataModel/User.js | 4 +- .../PM/Proxy/Proxy.Offline.DataStore.js | 4 +- .../gamma/js/Clipperz/PM/Proxy/Proxy.Test.js | 5 + .../gamma/properties/gamma.properties.json | 1 + .../gamma/properties/mobile.properties.json | 25 +- .../tests/tests/Clipperz/Crypto/AES_2.html | 57 ++ .../tests/tests/Clipperz/Crypto/AES_2.test.js | 85 ++ .../tests/tests/Clipperz/Crypto/index.html | 1 + .../tests/tests/Clipperz/PM/Crypto_v0_4.html | 60 ++ .../tests/Clipperz/PM/Crypto_v0_4.test.js | 50 ++ .../Clipperz/PM/DataModel/DirectLogin.html | 1 + .../PM/DataModel/EncryptedRemoteObject.html | 1 + .../tests/Clipperz/PM/DataModel/Record.html | 1 + .../Clipperz/PM/DataModel/Record.test.js | 8 + .../tests/Clipperz/PM/DataModel/User.html | 1 + .../tests/Clipperz/PM/DataModel/User.test.js | 2 +- .../gamma/tests/tests/Clipperz/PM/index.html | 1 + 22 files changed, 2098 insertions(+), 79 deletions(-) create mode 100644 frontend/beta/js/Clipperz/Crypto/AES_2.js create mode 100644 frontend/gamma/js/Clipperz/Crypto/AES_2.js create mode 100644 frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html create mode 100644 frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js create mode 100644 frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html create mode 100644 frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js diff --git a/frontend/beta/js/Clipperz/Crypto/AES_2.js b/frontend/beta/js/Clipperz/Crypto/AES_2.js new file mode 100644 index 0000000..9735d17 --- /dev/null +++ b/frontend/beta/js/Clipperz/Crypto/AES_2.js @@ -0,0 +1,829 @@ +/* + +Copyright 2008-2013 Clipperz Srl + +This file is part of Clipperz, the online password manager. +For further information about its features and functionalities please +refer to http://www.clipperz.com. + +* Clipperz is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + +* Clipperz is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Clipperz. If not, see http://www.gnu.org/licenses/. + +*/ + +try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { + throw "Clipperz.Crypto.AES_2 depends on Clipperz.ByteArray!"; +} + +// Dependency commented to avoid a circular reference +//try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { +// throw "Clipperz.Crypto.AES_2 depends on Clipperz.Crypto.PRNG!"; +//} + +if (typeof(Clipperz.Crypto.AES_2) == 'undefined') { Clipperz.Crypto.AES_2 = {}; } + +//############################################################################# + +Clipperz.Crypto.AES_2.DeferredExecutionContext = function(args) { + args = args || {}; + + this._key = args.key; + this._message = args.message; + this._result = args.message.clone(); + this._nonce = args.nonce; + this._messageLength = this._message.length(); + + this._messageArray = this._message.arrayValues(); + this._resultArray = this._result.arrayValues(); + this._nonceArray = this._nonce.arrayValues(); + + this._executionStep = 0; + + return this; +} + +Clipperz.Crypto.AES_2.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { + + 'key': function() { + return this._key; + }, + + 'message': function() { + return this._message; + }, + + 'messageLength': function() { + return this._messageLength; + }, + + 'result': function() { + return new Clipperz.ByteArray(this.resultArray()); + }, + + 'nonce': function() { + return this._nonce; + }, + + 'messageArray': function() { + return this._messageArray; + }, + + 'resultArray': function() { + return this._resultArray; + }, + + 'nonceArray': function() { + return this._nonceArray; + }, + + 'elaborationChunkSize': function() { + return Clipperz.Crypto.AES_2.DeferredExecution.chunkSize; + }, + + 'executionStep': function() { + return this._executionStep; + }, + + 'setExecutionStep': function(aValue) { + this._executionStep = aValue; + }, + + 'pause': function(aValue) { + return MochiKit.Async.wait(Clipperz.Crypto.AES_2.DeferredExecution.pauseTime, aValue); + }, + + //----------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" + +}); + +//############################################################################# + +Clipperz.Crypto.AES_2.Key = function(args) { + args = args || {}; + + this._key = args.key; + this._keySize = args.keySize || this.key().length(); + + if (this.keySize() == 128/8) { + this._b = 176; + this._numberOfRounds = 10; + } else if (this.keySize() == 256/8) { + this._b = 240; + this._numberOfRounds = 14; + } else { + MochiKit.Logging.logError("AES unsupported key size: " + (this.keySize() * 8) + " bits"); + throw Clipperz.Crypto.AES_2.exception.UnsupportedKeySize; + } + + this._stretchedKey = null; + + return this; +} + +Clipperz.Crypto.AES_2.Key.prototype = MochiKit.Base.update(null, { + + 'asString': function() { + return "Clipperz.Crypto.AES_2.Key (" + this.key().toHexString() + ")"; + }, + + //----------------------------------------------------------------------------- + + 'key': function() { + return this._key; + }, + + 'keySize': function() { + return this._keySize; + }, + + 'b': function() { + return this._b; + }, + + 'numberOfRounds': function() { + return this._numberOfRounds; + }, + //========================================================================= + + 'keyScheduleCore': function(aWord, aRoundConstantsIndex) { + var result; + var sbox; + + sbox = Clipperz.Crypto.AES_2.sbox(); + + result = [ sbox[aWord[1]] ^ Clipperz.Crypto.AES_2.roundConstants()[aRoundConstantsIndex], + sbox[aWord[2]], + sbox[aWord[3]], + sbox[aWord[0]] ]; + + return result; + }, + + //----------------------------------------------------------------------------- + + 'xorWithPreviousStretchValues': function(aKey, aWord, aPreviousWordIndex) { + var result; + var i,c; + + result = []; + c = 4; + for (i=0; i 5 9 13 1 + // 2 6 10 14 10 14 2 6 + // 3 7 11 15 15 3 7 11 + // + '_shiftRowMapping': null, + 'shiftRowMapping': function() { + if (Clipperz.Crypto.AES_2._shiftRowMapping == null) { + Clipperz.Crypto.AES_2._shiftRowMapping = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]; + } + + return Clipperz.Crypto.AES_2._shiftRowMapping; + }, + + //----------------------------------------------------------------------------- + + '_mixColumnsMatrix': null, + 'mixColumnsMatrix': function() { + if (Clipperz.Crypto.AES_2._mixColumnsMatrix == null) { + Clipperz.Crypto.AES_2._mixColumnsMatrix = [ [2, 3, 1 ,1], + [1, 2, 3, 1], + [1, 1, 2, 3], + [3, 1, 1, 2] ]; + } + + return Clipperz.Crypto.AES_2._mixColumnsMatrix; + }, + + '_roundConstants': null, + 'roundConstants': function() { + if (Clipperz.Crypto.AES_2._roundConstants == null) { + Clipperz.Crypto.AES_2._roundConstants = [ , 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154]; +// Clipperz.Crypto.AES_2._roundConstants = [ , 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a]; + } + + return Clipperz.Crypto.AES_2._roundConstants; + }, + + //============================================================================= + + 'incrementNonce': function(nonce) { + var i; + var done; + + done = false; + i = nonce.length - 1; + + while ((i>=0) && (done == false)) { + var currentByteValue; + + currentByteValue = nonce[i]; + + if (currentByteValue == 0xff) { + nonce[i] = 0; + if (i>= 0) { + i --; + } else { + done = true; + } + } else { + nonce[i] = currentByteValue + 1; + done = true; + } + } + }, + + //----------------------------------------------------------------------------- + + 'encryptBlock': function(aKey, aBlock) { + var result; + var state; + + state = new Clipperz.Crypto.AES_2.State({block:aBlock, key:aKey}); +//is(state.data(), 'before'); + state.encrypt(); + result = state.data(); + + return result; + }, + + //----------------------------------------------------------------------------- + + 'encryptBlocks': function(aKey, aMessage, aNonce) { + var result; + var nonce; + var self; + var messageIndex; + var messageLength; + var blockSize; + + self = Clipperz.Crypto.AES_2; + blockSize = 128/8; + messageLength = aMessage.length; + nonce = aNonce; + + result = aMessage; + messageIndex = 0; + while (messageIndex < messageLength) { + var encryptedBlock; + var i,c; + + encryptedBlock = self.encryptBlock(aKey, nonce); + + if ((messageLength - messageIndex) > blockSize) { + c = blockSize; + } else { + c = messageLength - messageIndex; + } + + for (i=0; i blockSize) { + c = blockSize; + } else { + c = executionLimit - messageIndex; + } + + for (i=0; i>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1"); value = Clipperz.Base.serializeJSON(aValue); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2"); -/ * -//MochiKit.Logging.logDebug("--> encrypt.fullSize: " + value.length); - value = value.replace(/":{"label":"/g, '":{l:"'); - value = value.replace(/":{"key":"/g, '":{k:"'); - value = value.replace(/":{"notes":"/g, '":{n:"'); - value = value.replace(/":{"record":"/g, '":{r:"'); - value = value.replace(/", "label":"/g, '",l:"'); - value = value.replace(/", "favicon":"/g, '",f:"'); -//MochiKit.Logging.logDebug("<-- encrypt.compressed: " + value.length); -* / data = new Clipperz.ByteArray(value); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3"); - encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce); -//MochiKit.Logging.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4"); + encryptedData = Clipperz.Crypto.AES_2.encrypt(key, data, aNonce); result = encryptedData.toBase64String(); -//MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); return result; }, + + 'deferredEncrypt': function(aKey, aValue, aNonce) { + var deferredResult; + var key, value; + var data; + var dataToEncrypt; + var encryptedData; + + key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); + value = Clipperz.Base.serializeJSON(aValue); + data = new Clipperz.ByteArray(value); + + deferredResult = new MochiKit.Async.Deferred() + deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncrypt, key, data, aNonce); + deferredResult.addCallback(function(aResult) { + return aResult.toBase64String(); + }) + deferredResult.callback(); + + return deferredResult; + }, 'decrypt': function(aKey, aValue) { var result; @@ -385,25 +390,15 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); - decryptedData = Clipperz.Crypto.AES.decrypt(key, value); + decryptedData = Clipperz.Crypto.AES_2.decrypt(key, value); value = decryptedData.asString(); -/ * - value = value.replace(/":{l:"/g, '":{"label":"'); - value = value.replace(/":{k:"/g, '":{"key":"'); - value = value.replace(/":{n:"/g, '":{"notes":"'); - value = value.replace(/":{r:"/g, '":{"record":"'); - value = value.replace(/",l:"/g, '", "label":"'); - value = value.replace(/",f:"/g, '", "favicon":"'); -* / try { result = Clipperz.Base.evalJSON(value); } catch (exception) { MochiKit.Logging.logError("Error while decrypting data"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; } - - } else { result = null; } @@ -411,9 +406,41 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { return result; }, + 'deferredDecrypt': function(aKey, aValue) { + var deferredResult; + + deferredResult = new MochiKit.Async.Deferred(); + if (aValue != null) { + var key, value; + var decryptedData; + var decryptedValue; + + key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); + value = new Clipperz.ByteArray().appendBase64String(aValue); + deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredDecrypt, key, value); + deferredResult.addCallback(MochiKit.Async.wait, 0.1); + deferredResult.addCallback(function(aResult) { + return aResult.asString(); + }); + deferredResult.addCallback(MochiKit.Async.wait, 0.1); + deferredResult.addCallback(Clipperz.Base.evalJSON); + deferredResult.addErrback(function(anError) { + MochiKit.Logging.logError("Error while decrypting data"); + throw Clipperz.Crypto.Base.exception.CorruptedMessage; + }) + } else { + deferredResult.addCallback(function() { + return null; + }); + } + deferredResult.callback(); + + return deferredResult; + }, + 'hash': Clipperz.Crypto.SHA.sha_d256 }, -*/ + //##################################################################### __syntaxFix__: "syntax fix" } diff --git a/frontend/beta/properties/beta.properties.json b/frontend/beta/properties/beta.properties.json index bfa152d..7d34677 100644 --- a/frontend/beta/properties/beta.properties.json +++ b/frontend/beta/properties/beta.properties.json @@ -77,6 +77,7 @@ "Clipperz/NotificationCenter.js", "Clipperz/Crypto/SHA.js", "Clipperz/Crypto/AES.js", + "Clipperz/Crypto/AES_2.js", "Clipperz/Crypto/PRNG.js", "Clipperz/Crypto/BigInt.js", "Clipperz/Crypto/Base.js", diff --git a/frontend/gamma/js/Clipperz/Crypto/AES_2.js b/frontend/gamma/js/Clipperz/Crypto/AES_2.js new file mode 100644 index 0000000..1627f39 --- /dev/null +++ b/frontend/gamma/js/Clipperz/Crypto/AES_2.js @@ -0,0 +1,843 @@ +/* + +Copyright 2008-2013 Clipperz Srl + +This file is part of Clipperz, the online password manager. +For further information about its features and functionalities please +refer to http://www.clipperz.com. + +* Clipperz is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + +* Clipperz is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Clipperz. If not, see http://www.gnu.org/licenses/. + +*/ + +try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { + throw "Clipperz.Crypto.AES_2 depends on Clipperz.ByteArray!"; +} + +// Dependency commented to avoid a circular reference +//try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { +// throw "Clipperz.Crypto.AES_2 depends on Clipperz.Crypto.PRNG!"; +//} + +if (typeof(Clipperz.Crypto.AES_2) == 'undefined') { Clipperz.Crypto.AES_2 = {}; } + +//############################################################################# + +Clipperz.Crypto.AES_2.DeferredExecutionContext = function(args) { + args = args || {}; + + this._key = args.key; + this._message = args.message; + this._result = args.message.clone(); + this._nonce = args.nonce; + this._messageLength = this._message.length(); + + this._messageArray = this._message.arrayValues(); + this._resultArray = this._result.arrayValues(); + this._nonceArray = this._nonce.arrayValues(); + + this._executionStep = 0; + +// this._elaborationChunkSize = 1024; // 4096; // 16384; // 4096; + this._elaborationChunks = 10; + this._pauseTime = 0.02; // 0.02 // 0.2; + + return this; +} + +Clipperz.Crypto.AES_2.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { + + 'key': function() { + return this._key; + }, + + 'message': function() { + return this._message; + }, + + 'messageLength': function() { + return this._messageLength; + }, + + 'result': function() { + return new Clipperz.ByteArray(this.resultArray()); + }, + + 'nonce': function() { + return this._nonce; + }, + + 'messageArray': function() { + return this._messageArray; + }, + + 'resultArray': function() { + return this._resultArray; + }, + + 'nonceArray': function() { + return this._nonceArray; + }, + + 'elaborationChunkSize': function() { +// return Clipperz.Crypto.AES_2.DeferredExecution.chunkSize; +// return this._elaborationChunkSize; + return (this._elaborationChunks * 1024); + }, + + 'executionStep': function() { + return this._executionStep; + }, + + 'setExecutionStep': function(aValue) { + this._executionStep = aValue; + }, + + 'tuneExecutionParameters': function (anElapsedTime) { +//var originalChunks = this._elaborationChunks; + if (anElapsedTime > 0) { + this._elaborationChunks = Math.round(this._elaborationChunks * ((anElapsedTime + 1000)/(anElapsedTime * 2))); + } +//Clipperz.log("tuneExecutionParameters - elapsedTime: " + anElapsedTime + /*originalChunks,*/ " chunks # " + this._elaborationChunks + " [" + this._executionStep + " / " + this._messageLength + "]"); + }, + + 'pause': function(aValue) { +// return MochiKit.Async.wait(Clipperz.Crypto.AES_2.DeferredExecution.pauseTime, aValue); + return MochiKit.Async.wait(this._pauseTime, aValue); + }, + + 'isDone': function () { + return (this._executionStep >= this._messageLength); + }, + + //----------------------------------------------------------------------------- + __syntaxFix__: "syntax fix" + +}); + +//############################################################################# + +Clipperz.Crypto.AES_2.Key = function(args) { + args = args || {}; + + this._key = args.key; + this._keySize = args.keySize || this.key().length(); + + if (this.keySize() == 128/8) { + this._b = 176; + this._numberOfRounds = 10; + } else if (this.keySize() == 256/8) { + this._b = 240; + this._numberOfRounds = 14; + } else { + Clipperz.logError("AES unsupported key size: " + (this.keySize() * 8) + " bits"); + throw Clipperz.Crypto.AES_2.exception.UnsupportedKeySize; + } + + this._stretchedKey = null; + + return this; +} + +Clipperz.Crypto.AES_2.Key.prototype = MochiKit.Base.update(null, { + + 'asString': function() { + return "Clipperz.Crypto.AES_2.Key (" + this.key().toHexString() + ")"; + }, + + //----------------------------------------------------------------------------- + + 'key': function() { + return this._key; + }, + + 'keySize': function() { + return this._keySize; + }, + + 'b': function() { + return this._b; + }, + + 'numberOfRounds': function() { + return this._numberOfRounds; + }, + //========================================================================= + + 'keyScheduleCore': function(aWord, aRoundConstantsIndex) { + var result; + var sbox; + + sbox = Clipperz.Crypto.AES_2.sbox(); + + result = [ sbox[aWord[1]] ^ Clipperz.Crypto.AES_2.roundConstants()[aRoundConstantsIndex], + sbox[aWord[2]], + sbox[aWord[3]], + sbox[aWord[0]] ]; + + return result; + }, + + //----------------------------------------------------------------------------- + + 'xorWithPreviousStretchValues': function(aKey, aWord, aPreviousWordIndex) { + var result; + var i,c; + + result = []; + c = 4; + for (i=0; i 5 9 13 1 + // 2 6 10 14 10 14 2 6 + // 3 7 11 15 15 3 7 11 + // + '_shiftRowMapping': null, + 'shiftRowMapping': function() { + if (Clipperz.Crypto.AES_2._shiftRowMapping == null) { + Clipperz.Crypto.AES_2._shiftRowMapping = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]; + } + + return Clipperz.Crypto.AES_2._shiftRowMapping; + }, + + //----------------------------------------------------------------------------- + + '_mixColumnsMatrix': null, + 'mixColumnsMatrix': function() { + if (Clipperz.Crypto.AES_2._mixColumnsMatrix == null) { + Clipperz.Crypto.AES_2._mixColumnsMatrix = [ [2, 3, 1 ,1], + [1, 2, 3, 1], + [1, 1, 2, 3], + [3, 1, 1, 2] ]; + } + + return Clipperz.Crypto.AES_2._mixColumnsMatrix; + }, + + '_roundConstants': null, + 'roundConstants': function() { + if (Clipperz.Crypto.AES_2._roundConstants == null) { + Clipperz.Crypto.AES_2._roundConstants = [ , 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154]; +// Clipperz.Crypto.AES_2._roundConstants = [ , 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a]; + } + + return Clipperz.Crypto.AES_2._roundConstants; + }, + + //============================================================================= + + 'incrementNonce': function(nonce) { + var i; + var done; + + done = false; + i = nonce.length - 1; + + while ((i>=0) && (done == false)) { + var currentByteValue; + + currentByteValue = nonce[i]; + + if (currentByteValue == 0xff) { + nonce[i] = 0; + if (i>= 0) { + i --; + } else { + done = true; + } + } else { + nonce[i] = currentByteValue + 1; + done = true; + } + } + }, + + //----------------------------------------------------------------------------- + + 'encryptBlock': function(aKey, aBlock) { + var result; + var state; + + state = new Clipperz.Crypto.AES_2.State({block:aBlock, key:aKey}); +//is(state.data(), 'before'); + state.encrypt(); + result = state.data(); + + return result; + }, + + //----------------------------------------------------------------------------- + + 'encryptBlocks': function(aKey, aMessage, aNonce) { + var result; + var nonce; + var self; + var messageIndex; + var messageLength; + var blockSize; + + self = Clipperz.Crypto.AES_2; + blockSize = 128/8; + messageLength = aMessage.length; + nonce = aNonce; + + result = aMessage; + messageIndex = 0; + while (messageIndex < messageLength) { + var encryptedBlock; + var i,c; + + encryptedBlock = self.encryptBlock(aKey, nonce); + + if ((messageLength - messageIndex) > blockSize) { + c = blockSize; + } else { + c = messageLength - messageIndex; + } + + for (i=0; i blockSize) { + c = blockSize; + } else { + c = executionLimit - messageIndex; + } + + for (i=0; i>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); -//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1"); value = Clipperz.Base.serializeJSON(aValue); -//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2"); -/ * -//Clipperz.logDebug("--> encrypt.fullSize: " + value.length); - value = value.replace(/":{"label":"/g, '":{l:"'); - value = value.replace(/":{"key":"/g, '":{k:"'); - value = value.replace(/":{"notes":"/g, '":{n:"'); - value = value.replace(/":{"record":"/g, '":{r:"'); - value = value.replace(/", "label":"/g, '",l:"'); - value = value.replace(/", "favicon":"/g, '",f:"'); -//Clipperz.logDebug("<-- encrypt.compressed: " + value.length); -* / data = new Clipperz.ByteArray(value); -//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3"); - encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce); -//Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4"); + encryptedData = Clipperz.Crypto.AES_2.encrypt(key, data, aNonce); result = encryptedData.toBase64String(); -//Clipperz.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); return result; }, + + 'deferredEncrypt': function(aKey, aValue, aNonce) { + var deferredResult; + var key, value; + var data; + var dataToEncrypt; + var encryptedData; + + key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); + value = Clipperz.Base.serializeJSON(aValue); + data = new Clipperz.ByteArray(value); + + deferredResult = new Clipperz.Async.Deferred("Crypto[0.4].deferredEncrypt") + deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncrypt, key, data, aNonce); + deferredResult.addCallback(function(aResult) { + return aResult.toBase64String(); + }) + deferredResult.callback(); + + return deferredResult; + }, 'decrypt': function(aKey, aValue) { var result; @@ -392,25 +397,16 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); value = new Clipperz.ByteArray().appendBase64String(aValue); - decryptedData = Clipperz.Crypto.AES.decrypt(key, value); + decryptedData = Clipperz.Crypto.AES_2.decrypt(key, value); value = decryptedData.asString(); -/ * - value = value.replace(/":{l:"/g, '":{"label":"'); - value = value.replace(/":{k:"/g, '":{"key":"'); - value = value.replace(/":{n:"/g, '":{"notes":"'); - value = value.replace(/":{r:"/g, '":{"record":"'); - value = value.replace(/",l:"/g, '", "label":"'); - value = value.replace(/",f:"/g, '", "favicon":"'); -* / try { result = Clipperz.Base.evalJSON(value); } catch (exception) { - Clipperz.logError("Error while decrypting data"); + console.log("PIPPO_2", anError) + Clipperz.logError("Error while decrypting data [4]"); throw Clipperz.Crypto.Base.exception.CorruptedMessage; } - - } else { result = null; } @@ -418,9 +414,51 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { return result; }, - 'hash': Clipperz.Crypto.SHA.sha_d256 + 'deferredDecrypt': function(aKey, aValue) { + var deferredResult; + + deferredResult = new Clipperz.Async.Deferred("Crypto[0.4].deferredDecrypt", {trace: false}); + + if (aValue != null) { + var key, value; + + key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); + value = new Clipperz.ByteArray().appendBase64String(aValue); + + deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredDecrypt, key, value); + deferredResult.addCallback(MochiKit.Async.wait, 0.1); + deferredResult.addCallback(function(aResult) { + return aResult.asString(); + }); + deferredResult.addCallback(MochiKit.Async.wait, 0.1); + deferredResult.addCallback(Clipperz.Base.evalJSON); + deferredResult.addErrback(function(anError) { + Clipperz.logError("Error while decrypting data [4]"); + throw Clipperz.Crypto.Base.exception.CorruptedMessage; + }) + } else { + deferredResult.addCallback(function() { + return null; + }); + } + deferredResult.callback(); + + return deferredResult; + }, + + 'hash': Clipperz.Crypto.SHA.sha_d256, + + 'deriveKey': function(aStringValue) { + var byteData; + var result; + + byteData = new Clipperz.ByteArray(aStringValue); + result = Clipperz.Crypto.SHA.sha_d256(byteData); + + return result; + } }, -*/ + //##################################################################### __syntaxFix__: "syntax fix" } diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index fd18faf..b94fe4c 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js @@ -726,8 +726,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { header = {}; header['records'] = someHeaderPackedData['recordIndex']['records']; header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; - header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; // ??????????? - header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; // ??????????? + header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; + header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; header['version'] = '0.1'; aResult['header'] = Clipperz.Base.serializeJSON(header); diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js index 326022c..b806cb7 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js @@ -281,7 +281,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { 's': someParameters['credentials']['s'], 'v': someParameters['credentials']['v'], 'version': someParameters['credentials']['version'], - 'lock': Clipperz.Crypto.Base.generateRandomSeed(), +// 'lock': Clipperz.Crypto.Base.generateRandomSeed(), 'userDetails': someParameters['user']['header'], 'statistics': someParameters['user']['statistics'], 'userDetailsVersion': someParameters['user']['version'], @@ -569,7 +569,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { aConnection['userData']['userDetails'] = someParameters['parameters']['user']['header']; aConnection['userData']['statistics'] = someParameters['parameters']['user']['statistics']; - aConnection['userData']['userDetailsVersions'] = someParameters['parameters']['user']['version']; + aConnection['userData']['userDetailsVersion'] = someParameters['parameters']['user']['version']; c = someParameters['parameters']['records']['updated'].length; for (i=0; i>> send message - " + aFunctionName, someParameters); +//} else { +// console.log(">>> SEND MESSAGE - " + aFunctionName + " [" + someParameters['parameters']['message'] + "]", someParameters['parameters']['parameters']); +//} this.checkRequest(aFunctionName, someParameters); result = Clipperz.PM.Proxy.Test.superclass.sendMessage.call(this, aFunctionName, someParameters); diff --git a/frontend/gamma/properties/gamma.properties.json b/frontend/gamma/properties/gamma.properties.json index d00e03a..1bc9e27 100644 --- a/frontend/gamma/properties/gamma.properties.json +++ b/frontend/gamma/properties/gamma.properties.json @@ -44,6 +44,7 @@ "Clipperz/Crypto/SHA.js", "Clipperz/Crypto/AES.js", + "Clipperz/Crypto/AES_2.js", "Clipperz/Crypto/PRNG.js", "Clipperz/Crypto/BigInt.js", "Clipperz/Crypto/Base.js", diff --git a/frontend/gamma/properties/mobile.properties.json b/frontend/gamma/properties/mobile.properties.json index 0127ce6..2b3b49d 100644 --- a/frontend/gamma/properties/mobile.properties.json +++ b/frontend/gamma/properties/mobile.properties.json @@ -9,20 +9,20 @@ "js": [ "MochiKit/Base.js", "MochiKit/Iter.js", - "MochiKit/Logging.js", + "-- MochiKit/Logging.js", "MochiKit/DateTime.js", "MochiKit/Format.js", "MochiKit/Async.js", "MochiKit/DOM.js", "MochiKit/Style.js", - "MochiKit/LoggingPane.js", + "-- MochiKit/LoggingPane.js", "-- MochiKit/Color.js", "MochiKit/Signal.js", "-- MochiKit/Position.js", "MochiKit/Selector.js", "-- MochiKit/Visual.js", - "JSON/json2.js", + "-- JSON/json2.js", "Clipperz/YUI/Utils.js", "Clipperz/YUI/DomHelper.js", @@ -43,6 +43,7 @@ "Clipperz/Crypto/SHA.js", "Clipperz/Crypto/AES.js", + "Clipperz/Crypto/AES_2.js", "Clipperz/Crypto/PRNG.js", "Clipperz/Crypto/BigInt.js", "Clipperz/Crypto/Base.js", @@ -95,6 +96,10 @@ "Clipperz/PM/DataModel/DirectLoginFormValue.js", "Clipperz/PM/DataModel/OneTimePassword.js", + "JQuery/1.9.1/jquery.js", + "Clipperz/PM/UI/Mobile/CustomizeJQueryMobile.js", + "JQuery/Mobile/1.3.0-rc.1/jquery.mobile.js", + "-- Zepto/zepto.js", "-- Zepto/ajax.js", "-- Zepto/assets.js", @@ -126,23 +131,26 @@ "-- Bootstrap/bootstrap-transition.js", "-- Bootstrap/bootstrap-typeahead.js", - "Clipperz/PM/UI/Common/Components/BaseComponent.js", + "-- Clipperz/PM/UI/Common/Components/BaseComponent.js", "-- Clipperz/PM/UI/Common/Components/Button.js", - "Clipperz/PM/UI/Common/Components/ComponentSlot.js", + "-- Clipperz/PM/UI/Common/Components/ComponentSlot.js", "-- Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js", - "Clipperz/PM/UI/Common/Components/ProgressBar.js", + "-- Clipperz/PM/UI/Common/Components/ProgressBar.js", "-- Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js", "-- Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js", "-- Clipperz/PM/UI/Common/Components/TabPanelComponent.js", "-- Clipperz/PM/UI/Common/Components/Tooltip.js", "-- Clipperz/PM/UI/Common/Components/TranslatorWidget.js", - "Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js", - "Clipperz/PM/UI/Common/Controllers/ProgressBarController.js", + "-- Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js", + "-- Clipperz/PM/UI/Common/Controllers/ProgressBarController.js", "-- Clipperz/PM/UI/Common/Controllers/TabPanelController.js", + "Clipperz/PM/UI/Mobile/Components/BaseComponent.js", + "Clipperz/PM/UI/Mobile/Components/Overlay.js", "Clipperz/PM/UI/Mobile/Components/LoginForm.js", "Clipperz/PM/UI/Mobile/Components/CardList.js", + "Clipperz/PM/UI/Mobile/Components/Preferences.js", "-- Clipperz/PM/UI/Mobile/Components/CardDetail.js", "Clipperz/PM/UI/Mobile/Controllers/MainController.js", @@ -151,6 +159,7 @@ ], "css": [ + "jquery.mobile-1.3.0-rc.1.css", "mobile.css" ] } \ No newline at end of file diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html b/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html new file mode 100644 index 0000000..8f922fb --- /dev/null +++ b/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html @@ -0,0 +1,57 @@ + + + + + Clipperz.Crypto.AES_2 - tests + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js b/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js new file mode 100644 index 0000000..f753747 --- /dev/null +++ b/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js @@ -0,0 +1,85 @@ +/* + +Copyright 2008-2013 Clipperz Srl + +This file is part of Clipperz, the online password manager. +For further information about its features and functionalities please +refer to http://www.clipperz.com. + +* Clipperz is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + +* Clipperz is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Clipperz. If not, see http://www.gnu.org/licenses/. + +*/ + +function testEncryptedData (tool, keyValue, encryptedText, expectedCleanText, someTestArgs) { + key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(keyValue)); + value = new Clipperz.ByteArray().appendBase64String(encryptedText); + + deferredResult = new Clipperz.Async.Deferred("pythonCompatibility_test", someTestArgs); + deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredDecrypt, key, value); + deferredResult.addCallback(function(aResult) { + return aResult.asString(); + }); + deferredResult.addTest(expectedCleanText, tool); + deferredResult.callback(); + + return deferredResult; +} + +//============================================================================= + +var tests = { + + 'incrementNonce_test': function (someTestArgs) { + var nonce; + + nonce = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + Clipperz.Crypto.AES_2.incrementNonce(nonce) + SimpleTest.eq(nonce, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], "increment 0 based nonce"); + + nonce = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] + Clipperz.Crypto.AES_2.incrementNonce(nonce) + SimpleTest.eq(nonce, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], "increment '1' nonce"); + + nonce = [58,231,19,199,48,86,154,169,188,141,46,196,83,34,37,89] + Clipperz.Crypto.AES_2.incrementNonce(nonce) + SimpleTest.eq(nonce, [58,231,19,199,48,86,154,169,188,141,46,196,83,34,37,90], "increment '1' nonce"); + return + }, + + 'pythonCompatibility_test': function (someTestArgs) { + var keyValue = "clipperz" + var cleanText = "Lorem īpsum dōlōr siÞ ǽmēt, stet voluptatum ei eum, quō pērfecto lobortis eā, vel ċu deserūisse comprehēƿsam. Eu sed cībō veniam effīciendi, Þe legere ðominġ est, ðuō ċu saperet inermis pērfeċto. Vim ei essent consetētūr, quo etīam saepē æpeirian in, et atqūi velīÞ sǣepe his? Æn porrō putanÞ sinġulis mei, ēx sonet noster mea, tē alterum praesent percipitur qūo. ViÞaē neċessitatibus ne vim, per ex communē sentēntiǣe! Qui stet ǽdhūċ uÞ." + +// def testEncrypt (keyValue, cleanText): +// key = keyDerivation(keyValue) +// iv = random.getrandbits(128) +// ctr = Crypto.Util.Counter.new(128, initial_value=iv) +// cipher = AES.new(key, Crypto.Cipher.AES.MODE_CTR, counter=ctr) +// encryptedValue = cipher.encrypt(cleanText.encode('utf-8')) +// data = base64.b64encode(base64.b16decode(hex(iv).upper()[2:-1]) + encryptedValue) +// +// return data + + var pythonEncryptedData = "9AFIXRO2nY0mkLJI6Xd4bd+Ov1g+kYUh73nICEVUM8OGt5FnfV/w2BfmTvdMGZjs+rF8w0ksrS9Ny8j2+2zPUUrKnVRXO6eGVPSN5VfuYFSHucV98msINH0FpOZHftuKCuJkB/orjQhoIbj9SXT0yUwB3b4R2bk48Br7R8G2bhxqrHRmnYQn22AQVA83UstNvCOdXT7ArfwJZbVSSMkdmvcziZ8ObMvaH+FXD/K8i7dzS1yP03MMBtIkYN8PnyUMS2uAHKiR11jGuha9QfXjLJlWUQWZgNB9NKyOKf7tN+OgtAoWmHmKlpTshfwbfFD8wBPR0kkhR0cC+7queIjpCDnBJ+Nod78zWgPDR8g64sph7OB686HkP03cO66aH/LNuAt03gxaVyE8ufvoStRjlIthOuys5xYWP+hTFYDC7OhCOLKvhZoY4Tr/FP+TjporX3ivCJUEEvwvXeftAxFVRl4JDin0ys0iPTQ7QlbtVa+iep2n9FUG1NOn5boD9y+iw64UJAcex4MqEIdpCHne9LjpiqshcwLmfEeLlFab28LHnvYPGkXDrSRjCujx8ZmmTw96sAIDqER8p1AqaSojwvONYBGrq+f5/f4xjzZJAknMmxYEN14Phbxc8WEhpe5omWdB80C1Kv6CLsoQnGAIshURSZryToXL" + return testEncryptedData("python", keyValue, pythonEncryptedData, cleanText, someTestArgs) + }, + + //------------------------------------------------------------------------- + 'syntaxFix': MochiKit.Base.noop +} + +//============================================================================= + +Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose(); +SimpleTest.runDeferredTests("Clipperz.Crypto.AES_2", tests, {trace:false}); diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/index.html b/frontend/gamma/tests/tests/Clipperz/Crypto/index.html index 5ee8b8c..0679739 100644 --- a/frontend/gamma/tests/tests/Clipperz/Crypto/index.html +++ b/frontend/gamma/tests/tests/Clipperz/Crypto/index.html @@ -32,6 +32,7 @@ refer to http://www.clipperz.com. + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js b/frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js new file mode 100644 index 0000000..ecfbec3 --- /dev/null +++ b/frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js @@ -0,0 +1,50 @@ +/* + +Copyright 2008-2013 Clipperz Srl + +This file is part of Clipperz, the online password manager. +For further information about its features and functionalities please +refer to http://www.clipperz.com. + +* Clipperz is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + +* Clipperz is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + +* You should have received a copy of the GNU Affero General Public + License along with Clipperz. If not, see http://www.gnu.org/licenses/. + +*/ + +var tests = { + + 'decryptDataEncryptedUsingPythonLibrary_test': function (someTestArgs) { + var deferredResult; + + passphrase = 'trustno1'; + encryptedData = 'OucTxzBWmqm8jS7EUyIlWUWDPSFKvulL5iM4WwLPbNVIH7jtaK9pmzpm9w5ioVy2/tyebVwWr36t7QXSBOPwUPo2SlGmARCozA=='; + + deferredResult = new Clipperz.Async.Deferred("decryptDataEncryptedUsingPythonLibrary_test", someTestArgs); + deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, {key:passphrase, value:encryptedData, version:'0.4'}); + deferredResult.addCallback(MochiKit.Base.itemgetter('message')); + deferredResult.addTest("The quick brown fox jumps over the lazy dog", "expected value"); + + deferredResult.callback(); + + return deferredResult; + + }, + + //------------------------------------------------------------------------- + 'syntaxFix': MochiKit.Base.noop +} + +//============================================================================= + +Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose(); +SimpleTest.runDeferredTests("Clipperz.PM.Crypto [0.4]", tests, {trace:false}); diff --git a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/DirectLogin.html b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/DirectLogin.html index 73b8225..74d1a07 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/DirectLogin.html +++ b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/DirectLogin.html @@ -43,6 +43,7 @@ refer to http://www.clipperz.com. + diff --git a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/EncryptedRemoteObject.html b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/EncryptedRemoteObject.html index a711ba9..c264ff7 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/EncryptedRemoteObject.html +++ b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/EncryptedRemoteObject.html @@ -42,6 +42,7 @@ refer to http://www.clipperz.com. + diff --git a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.html b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.html index 0332008..4d6bc5d 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.html +++ b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.html @@ -43,6 +43,7 @@ refer to http://www.clipperz.com. + diff --git a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.test.js b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.test.js index 3478743..af1ffe8 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.test.js +++ b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.test.js @@ -177,6 +177,13 @@ var tests = { deferredResult = new Clipperz.Async.Deferred("Record.test.removeDirectLogin", someTestArgs); deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']); deferredResult.addMethod(user, 'login'); + + deferredResult.addMethod(user, 'getRecord', recordID); + deferredResult.addMethodcaller('directLogins'); + deferredResult.addCallback(MochiKit.Base.keys); + deferredResult.addCallback(MochiKit.Base.itemgetter('length')); + deferredResult.addTest(4, "The record initially has 4 direct logins"); + deferredResult.addMethod(user, 'getRecord', recordID); deferredResult.addMethodcaller('directLogins'); deferredResult.addCallback(MochiKit.Base.itemgetter(directLoginID)); @@ -187,6 +194,7 @@ var tests = { deferredResult.addTest(true, "removing a direct login to a record should result in pending changes on the record"); deferredResult.addMethod(user, 'saveChanges'); + deferredResult.addMethod(user, 'hasPendingChanges'); deferredResult.addTest(false, "after saving there should be not any pending changes"); diff --git a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.html b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.html index 793f763..3a0eda8 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.html +++ b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.html @@ -43,6 +43,7 @@ refer to http://www.clipperz.com. + diff --git a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.test.js b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.test.js index 45f3297..545580f 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.test.js +++ b/frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.test.js @@ -1922,7 +1922,7 @@ var tests = { proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false}); user2 = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}}); - +console.log("PROXY", proxy); deferredResult = new Clipperz.Async.Deferred("registerNewUserAndAddARecord_test", someTestArgs); deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_with_preferences_and_OTPs_data']); diff --git a/frontend/gamma/tests/tests/Clipperz/PM/index.html b/frontend/gamma/tests/tests/Clipperz/PM/index.html index eeda692..6eb6622 100644 --- a/frontend/gamma/tests/tests/Clipperz/PM/index.html +++ b/frontend/gamma/tests/tests/Clipperz/PM/index.html @@ -37,6 +37,7 @@ TestRunner.runTests( // 'BookmarkletProcessor.html', 'Connection.html', 'Crypto.html', + 'Crypto_v0_4.html', // 'Crypto_other_implementation_comparison.html', 'Crypto_performanceEvaluation.html', // 'CryptoPerformance_ByteArrayArray.html',