summaryrefslogtreecommitdiff
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2013-04-19 15:09:28 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2013-04-19 15:09:28 (UTC)
commit074e70457c90344b3c1cb236105638d692a0066b (patch) (side-by-side diff)
treec5ffabd3eaf74cbeb69974beacdb5a5f8c235adc
parent48c9280c9a255f2a85ad5729830df884e64a9c5d (diff)
downloadclipperz-074e70457c90344b3c1cb236105638d692a0066b.zip
clipperz-074e70457c90344b3c1cb236105638d692a0066b.tar.gz
clipperz-074e70457c90344b3c1cb236105638d692a0066b.tar.bz2
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).
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/Crypto/AES_2.js829
-rw-r--r--frontend/beta/js/Clipperz/PM/Crypto.js91
-rw-r--r--frontend/beta/properties/beta.properties.json1
-rw-r--r--frontend/gamma/js/Clipperz/Crypto/AES_2.js843
-rw-r--r--frontend/gamma/js/Clipperz/PM/Crypto.js106
-rw-r--r--frontend/gamma/js/Clipperz/PM/DataModel/User.js4
-rw-r--r--frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js4
-rw-r--r--frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js5
-rw-r--r--frontend/gamma/properties/gamma.properties.json1
-rw-r--r--frontend/gamma/properties/mobile.properties.json25
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html57
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js85
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/index.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html60
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js50
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/DataModel/DirectLogin.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/DataModel/EncryptedRemoteObject.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/DataModel/Record.test.js8
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/DataModel/User.test.js2
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/index.html1
22 files changed, 2098 insertions, 79 deletions
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
--- a/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<c; i++) {
+ result[i] = aWord[i] ^ aKey.byteAtIndex(aPreviousWordIndex + i);
+ }
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'sboxShakeup': function(aWord) {
+ var result;
+ var sbox;
+ var i,c;
+
+ result = [];
+ sbox = Clipperz.Crypto.AES_2.sbox();
+ c =4;
+ for (i=0; i<c; i++) {
+ result[i] = sbox[aWord[i]];
+ }
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'stretchKey': function(aKey) {
+ var currentWord;
+ var keyLength;
+ var previousStretchIndex;
+ var i,c;
+
+ keyLength = aKey.length();
+ previousStretchIndex = keyLength - this.keySize();
+
+ currentWord = [ aKey.byteAtIndex(keyLength - 4),
+ aKey.byteAtIndex(keyLength - 3),
+ aKey.byteAtIndex(keyLength - 2),
+ aKey.byteAtIndex(keyLength - 1) ];
+ currentWord = this.keyScheduleCore(currentWord, keyLength / this.keySize());
+
+ if (this.keySize() == 256/8) {
+ c = 8;
+ } else if (this.keySize() == 128/8){
+ c = 4;
+ }
+
+ for (i=0; i<c; i++) {
+ if (i == 4) {
+ // fifth streatch word
+ currentWord = this.sboxShakeup(currentWord);
+ }
+
+ currentWord = this.xorWithPreviousStretchValues(aKey, currentWord, previousStretchIndex + (i*4));
+ aKey.appendBytes(currentWord);
+ }
+
+ return aKey;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'stretchedKey': function() {
+ if (this._stretchedKey == null) {
+ var stretchedKey;
+
+ stretchedKey = this.key().clone();
+
+ while (stretchedKey.length() < this.keySize()) {
+ stretchedKey.appendByte(0);
+ }
+
+ while (stretchedKey.length() < this.b()) {
+ stretchedKey = this.stretchKey(stretchedKey);
+ }
+
+ this._stretchedKey = stretchedKey.split(0, this.b());
+ }
+
+ return this._stretchedKey;
+ },
+
+ //=========================================================================
+ __syntaxFix__: "syntax fix"
+});
+
+//#############################################################################
+
+Clipperz.Crypto.AES_2.State = function(args) {
+ args = args || {};
+
+ this._data = args.block.slice(0);
+ this._key = args.key;
+
+ return this;
+}
+
+Clipperz.Crypto.AES_2.State.prototype = MochiKit.Base.update(null, {
+
+ 'key': function() {
+ return this._key;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'data': function() {
+ return this._data;
+ },
+
+ 'setData': function(aValue) {
+ this._data = aValue;
+ },
+
+ //=========================================================================
+
+ 'addRoundKey': function(aRoundNumber) {
+ // each byte of the state is combined with the round key; each round key is derived from the cipher key using a key schedule.
+ var data;
+ var stretchedKey;
+ var firstStretchedKeyIndex;
+ var i,c;
+
+ data = this.data();
+ stretchedKey = this.key().stretchedKey();
+ firstStretchedKeyIndex = aRoundNumber * (128/8);
+ c = 128/8;
+ for (i=0; i<c; i++) {
+ data[i] = data[i] ^ stretchedKey.byteAtIndex(firstStretchedKeyIndex + i);
+ }
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'subBytes': function() {
+ // a non-linear substitution step where each byte is replaced with another according to a lookup table.
+ var i,c;
+ var data;
+ var sbox;
+
+ data = this.data();
+ sbox = Clipperz.Crypto.AES_2.sbox();
+
+ c = 16;
+ for (i=0; i<c; i++) {
+ data[i] = sbox[data[i]];
+ }
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'shiftRows': function() {
+ // a transposition step where each row of the state is shifted cyclically a certain number of steps.
+ var newValue;
+ var data;
+ var shiftMapping;
+ var i,c;
+
+ newValue = new Array(16);
+ data = this.data();
+ shiftMapping = Clipperz.Crypto.AES_2.shiftRowMapping();
+// [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11];
+ c = 16;
+ for (i=0; i<c; i++) {
+ newValue[i] = data[shiftMapping[i]];
+ }
+ for (i=0; i<c; i++) {
+ data[i] = newValue[i];
+ }
+ },
+
+ //-----------------------------------------------------------------------------
+/*
+ 'mixColumnsWithValues': function(someValues) {
+ var result;
+ var a;
+ var i,c;
+
+ c = 4;
+ result = [];
+ a = [];
+ for (i=0; i<c; i++) {
+ a[i] = [];
+ a[i][1] = someValues[i]
+ if ((a[i][1] & 0x80) == 0x80) {
+ a[i][2] = (a[i][1] << 1) ^ 0x11b;
+ } else {
+ a[i][2] = a[i][1] << 1;
+ }
+
+ a[i][3] = a[i][2] ^ a[i][1];
+ }
+
+ for (i=0; i<c; i++) {
+ var x;
+
+ x = Clipperz.Crypto.AES_2.mixColumnsMatrix()[i];
+ result[i] = a[0][x[0]] ^ a[1][x[1]] ^ a[2][x[2]] ^ a[3][x[3]];
+ }
+
+ return result;
+ },
+
+ 'mixColumns': function() {
+ // a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation.
+ var data;
+ var i, c;
+
+ data = this.data();
+ c = 4;
+ for(i=0; i<c; i++) {
+ var blockIndex;
+ var mixedValues;
+
+ blockIndex = i * 4;
+ mixedValues = this.mixColumnsWithValues([ data[blockIndex + 0],
+ data[blockIndex + 1],
+ data[blockIndex + 2],
+ data[blockIndex + 3]]);
+ data[blockIndex + 0] = mixedValues[0];
+ data[blockIndex + 1] = mixedValues[1];
+ data[blockIndex + 2] = mixedValues[2];
+ data[blockIndex + 3] = mixedValues[3];
+ }
+ },
+*/
+
+ 'mixColumns': function() {
+ // a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation.
+ var data;
+ var i, c;
+ var a_1;
+ var a_2;
+
+ a_1 = new Array(4);
+ a_2 = new Array(4);
+
+ data = this.data();
+ c = 4;
+ for(i=0; i<c; i++) {
+ var blockIndex;
+ var ii, cc;
+
+ blockIndex = i * 4;
+
+ cc = 4;
+ for (ii=0; ii<cc; ii++) {
+ var value;
+
+ value = data[blockIndex + ii];
+ a_1[ii] = value;
+ a_2[ii] = (value & 0x80) ? ((value << 1) ^ 0x011b) : (value << 1);
+ }
+
+ data[blockIndex + 0] = a_2[0] ^ a_1[1] ^ a_2[1] ^ a_1[2] ^ a_1[3];
+ data[blockIndex + 1] = a_1[0] ^ a_2[1] ^ a_1[2] ^ a_2[2] ^ a_1[3];
+ data[blockIndex + 2] = a_1[0] ^ a_1[1] ^ a_2[2] ^ a_1[3] ^ a_2[3];
+ data[blockIndex + 3] = a_1[0] ^ a_2[0] ^ a_1[1] ^ a_1[2] ^ a_2[3];
+ }
+ },
+
+ //=========================================================================
+
+ 'spinRound': function(aRoundNumber) {
+ this.addRoundKey(aRoundNumber);
+ this.subBytes();
+ this.shiftRows();
+ this.mixColumns();
+ },
+
+ 'spinLastRound': function() {
+ this.addRoundKey(this.key().numberOfRounds() - 1);
+ this.subBytes();
+ this.shiftRows();
+ this.addRoundKey(this.key().numberOfRounds());
+ },
+
+ //=========================================================================
+
+ 'encrypt': function() {
+ var i,c;
+
+ c = this.key().numberOfRounds() - 1;
+ for (i=0; i<c; i++) {
+ this.spinRound(i);
+ }
+
+ this.spinLastRound();
+ },
+
+ //=========================================================================
+ __syntaxFix__: "syntax fix"
+});
+
+//#############################################################################
+
+Clipperz.Crypto.AES_2.VERSION = "0.1";
+Clipperz.Crypto.AES_2.NAME = "Clipperz.Crypto.AES_2";
+
+MochiKit.Base.update(Clipperz.Crypto.AES_2, {
+
+// http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-AES.html
+// http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
+// http://en.wikipedia.org/wiki/Rijndael_key_schedule
+// http://en.wikipedia.org/wiki/Rijndael_S-box
+
+ '__repr__': function () {
+ return "[" + this.NAME + " " + this.VERSION + "]";
+ },
+
+ 'toString': function () {
+ return this.__repr__();
+ },
+
+ //=============================================================================
+
+ '_sbox': null,
+ 'sbox': function() {
+ if (Clipperz.Crypto.AES_2._sbox == null) {
+ Clipperz.Crypto.AES_2._sbox = [
+0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
+ ];
+ }
+
+ return Clipperz.Crypto.AES_2._sbox;
+ },
+
+ //-----------------------------------------------------------------------------
+ //
+ // 0 4 8 12 0 4 8 12
+ // 1 5 9 13 => 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<c; i++) {
+ result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i];
+ }
+
+ messageIndex += blockSize;
+ self.incrementNonce(nonce);
+ }
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'encrypt': function(aKey, someData, aNonce) {
+ var result;
+ var nonce;
+ var encryptedData;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+ nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8);
+
+ encryptedData = Clipperz.Crypto.AES_2.encryptBlocks(key, someData.arrayValues(), nonce.arrayValues());
+
+ result = nonce.appendBytes(encryptedData);
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'decrypt': function(aKey, someData) {
+ var result;
+ var nonce;
+ var encryptedData;
+ var decryptedData;
+ var dataIterator;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+
+ encryptedData = someData.arrayValues();
+ nonce = encryptedData.slice(0, (128/8));
+ encryptedData = encryptedData.slice(128/8);
+ decryptedData = Clipperz.Crypto.AES_2.encryptBlocks(key, encryptedData, nonce);
+
+ result = new Clipperz.ByteArray(decryptedData);
+
+ return result;
+ },
+
+ //=============================================================================
+
+ 'deferredEncryptExecutionChunk': function(anExecutionContext) {
+ var result;
+ var nonce;
+ var self;
+ var messageIndex;
+ var messageLength;
+ var blockSize;
+ var executionLimit;
+
+ self = Clipperz.Crypto.AES_2;
+ blockSize = 128/8;
+ messageLength = anExecutionContext.messageArray().length;
+ nonce = anExecutionContext.nonceArray();
+ result = anExecutionContext.resultArray();
+
+ messageIndex = anExecutionContext.executionStep();
+ executionLimit = messageIndex + anExecutionContext.elaborationChunkSize();
+ executionLimit = Math.min(executionLimit, messageLength);
+
+ while (messageIndex < executionLimit) {
+ var encryptedBlock;
+ var i,c;
+
+ encryptedBlock = self.encryptBlock(anExecutionContext.key(), nonce);
+
+ if ((executionLimit - messageIndex) > blockSize) {
+ c = blockSize;
+ } else {
+ c = executionLimit - messageIndex;
+ }
+
+ for (i=0; i<c; i++) {
+ result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i];
+ }
+
+ messageIndex += blockSize;
+ self.incrementNonce(nonce);
+ }
+ anExecutionContext.setExecutionStep(messageIndex);
+
+ return anExecutionContext;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'deferredEncryptBlocks': function(anExecutionContext) {
+ var deferredResult;
+ var messageSize;
+ var i,c;
+ var now;
+
+ messageSize = anExecutionContext.messageLength();
+
+ deferredResult = new MochiKit.Async.Deferred();
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncryptBlocks - START: " + res); return res;});
+// deferredResult.addCallback(MochiKit.Base.method(anExecutionContext, 'pause'));
+
+ c = Math.ceil(messageSize / anExecutionContext.elaborationChunkSize());
+ for (i=0; i<c; i++) {
+//deferredResult.addBoth(function(res) {now = new Date(); return res;});
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncryptBlocks - : (" + i + ") - " + res); return res;});
+ deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptExecutionChunk);
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "]Clipperz.Crypto.AES_2.deferredEncryptBlocks"); return res;});
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncryptBlocks - : (" + i + ") -- " + res); return res;});
+ deferredResult.addCallback(MochiKit.Base.method(anExecutionContext, 'pause'));
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncryptBlocks - : (" + i + ") --- " + res); return res;});
+ }
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncryptBlocks - END: " + res); return res;});
+
+ deferredResult.callback(anExecutionContext);
+
+ return deferredResult;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'deferredEncrypt': function(aKey, someData, aNonce) {
+ var deferredResult;
+ var executionContext;
+ var result;
+ var nonce;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+ nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8);
+
+ executionContext = new Clipperz.Crypto.AES_2.DeferredExecutionContext({key:key, message:someData, nonce:nonce});
+
+ deferredResult = new MochiKit.Async.Deferred();
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncrypt - 1: " + res); return res;});
+ deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptBlocks);
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncrypt - 2: " + res); return res;});
+ deferredResult.addCallback(function(anExecutionContext) {
+ var result;
+
+ result = anExecutionContext.nonce().clone();
+ result.appendBytes(anExecutionContext.resultArray());
+
+ return result;
+ });
+//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.Crypto.AES_2.deferredEncrypt - 3: " + res); return res;});
+ deferredResult.callback(executionContext)
+
+ return deferredResult;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'deferredDecrypt': function(aKey, someData) {
+ var deferredResult
+ var nonce;
+ var message;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+ nonce = someData.split(0, (128/8));
+ message = someData.split(128/8);
+ executionContext = new Clipperz.Crypto.AES_2.DeferredExecutionContext({key:key, message:message, nonce:nonce});
+
+ deferredResult = new MochiKit.Async.Deferred();
+ deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptBlocks);
+ deferredResult.addCallback(function(anExecutionContext) {
+ return anExecutionContext.result();
+ });
+ deferredResult.callback(executionContext);
+
+ return deferredResult;
+ },
+
+ //-----------------------------------------------------------------------------
+ __syntaxFix__: "syntax fix"
+
+});
+
+//#############################################################################
+
+Clipperz.Crypto.AES_2.DeferredExecution = {
+ 'chunkSize': 4096, // 1024 4096 8192 16384 32768;
+ 'pauseTime': 0.2
+}
+
+Clipperz.Crypto.AES_2.exception = {
+ 'UnsupportedKeySize': new MochiKit.Base.NamedError("Clipperz.Crypto.AES_2.exception.UnsupportedKeySize")
+};
diff --git a/frontend/beta/js/Clipperz/PM/Crypto.js b/frontend/beta/js/Clipperz/PM/Crypto.js
index ad16ff0..e1e87ec 100644
--- a/frontend/beta/js/Clipperz/PM/Crypto.js
+++ b/frontend/beta/js/Clipperz/PM/Crypto.js
@@ -1,498 +1,525 @@
/*
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/.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
if (typeof(Clipperz.PM.Crypto) == 'undefined') { Clipperz.PM.Crypto = {}; }
Clipperz.PM.Crypto.VERSION = "0.2";
Clipperz.PM.Crypto.NAME = "Clipperz.PM.Crypto";
MochiKit.Base.update(Clipperz.PM.Crypto, {
'__repr__': function () {
return "[" + this.NAME + " " + this.VERSION + "]";
},
//-------------------------------------------------------------------------
'toString': function () {
return this.__repr__();
},
//-------------------------------------------------------------------------
'communicationProtocol': {
'currentVersion': '0.2',
'versions': {
'0.1': Clipperz.PM.Connection.SRP['1.0'], //Clipperz.Crypto.SRP.versions['1.0'].Connection,
'0.2': Clipperz.PM.Connection.SRP['1.1'] //Clipperz.Crypto.SRP.versions['1.1'].Connection,
},
'fallbackVersions': {
'current': '0.1',
'0.2': '0.1',
'0.1': null
}
},
//-------------------------------------------------------------------------
'encryptingFunctions': {
- 'currentVersion': '0.3',
+ 'currentVersion': '0.4',
'versions': {
//#####################################################################
'0.1': {
'encrypt': function(aKey, aValue) {
return Clipperz.Crypto.Base.encryptUsingSecretKey(aKey, Clipperz.Base.serializeJSON(aValue));
},
'deferredEncrypt': function(aKey, aValue) {
var deferredResult;
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].encrypt, aKey, aValue);
deferredResult.callback();
return deferredResult;
},
'decrypt': function(aKey, aValue) {
var result;
if (aValue != null) {
result = Clipperz.Base.evalJSON(Clipperz.Crypto.Base.decryptUsingSecretKey(aKey, aValue));
} else {
result = null;
}
return result;
},
'deferredDecrypt': function(aKey, aValue) {
var deferredResult;
deferredResult = new MochiKit.Async.Deferred();
deferredResult.addCallback(Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].decrypt, aKey, aValue);
deferredResult.callback();
return deferredResult;
},
'hash': function(aValue) {
var result;
var strngResult;
stringResult = Clipperz.Crypto.Base.computeHashValue(aValue.asString()); // !!!!!!!
result = new Clipperz.ByteArray("0x" + stringResult);
return result;
}
},
//#####################################################################
'0.2': {
'encrypt': function(aKey, aValue, aNonce) {
var result;
var key, value;
var dataToEncrypt;
var encryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray(Clipperz.Base.serializeJSON(aValue));
dataToEncrypt = Clipperz.Crypto.SHA.sha_d256(value).appendBlock(value);
encryptedData = Clipperz.Crypto.AES.encrypt(key, dataToEncrypt, aNonce);
result = encryptedData.toBase64String();
return result;
},
'deferredEncrypt': function(aKey, aValue, aNonce) {
var deferredResult;
var key, value;
var dataToEncrypt;
var encryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray(Clipperz.Base.serializeJSON(aValue));
dataToEncrypt = Clipperz.Crypto.SHA.sha_d256(value).appendBlock(value);
deferredResult = new MochiKit.Async.Deferred()
deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, dataToEncrypt, aNonce);
deferredResult.addCallback(function(aResult) {
return aResult.toBase64String();
})
deferredResult.callback();
return deferredResult;
},
'decrypt': function(aKey, aValue) {
var result;
if (aValue != null) {
var key, value;
var decryptedData;
var decryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray().appendBase64String(aValue);
decryptedData = Clipperz.Crypto.AES.decrypt(key, value);
decryptedData = decryptedData.split((256/8));
try {
result = Clipperz.Base.evalJSON(decryptedData.asString());
} catch (exception) {
MochiKit.Logging.logError("Error while decrypting data");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}
} else {
result = null;
}
return result;
},
'deferredDecrypt': function(aKey, aValue) {
var result;
if (aValue != null) {
var deferredResult;
var key, value;
var decryptedData;
result = new MochiKit.Async.Deferred();
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray().appendBase64String(aValue);
deferredResult = new MochiKit.Async.Deferred()
deferredResult.addCallback(Clipperz.Crypto.AES.deferredDecrypt, key, value);
deferredResult.addCallback(function(aResult) {
var result;
var decryptedData;
decryptedData = aResult.split((256/8));
try {
result = Clipperz.Base.evalJSON(decryptedData.asString());
} catch (exception) {
MochiKit.Logging.logError("Error while decrypting data");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}
return result;
})
deferredResult.callback();
result = deferredResult;
} else {
result = MochiKit.Async.succeed(null);
}
return result;
},
'hash': Clipperz.Crypto.SHA.sha_d256
},
//#####################################################################
'0.3': {
'encrypt': function(aKey, aValue, aNonce) {
var result;
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);
encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce);
result = encryptedData.toBase64String();
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.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Crypto.deferredEncrypt - 1: " + res); return res;});
deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, data, aNonce);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Crypto.deferredEncrypt - 2: " + res); return res;});
deferredResult.addCallback(function(aResult) {
return aResult.toBase64String();
})
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Clipperz.PM.Crypto.deferredEncrypt - 3: " + res); return res;});
deferredResult.callback();
return deferredResult;
},
'decrypt': function(aKey, aValue) {
var result;
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);
decryptedData = Clipperz.Crypto.AES.decrypt(key, value);
value = decryptedData.asString();
try {
result = Clipperz.Base.evalJSON(value);
} catch (exception) {
MochiKit.Logging.logError("Error while decrypting data");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}
} else {
result = null;
}
return result;
},
'deferredDecrypt': function(aKey, aValue) {
var deferredResult;
// var now;
deferredResult = new MochiKit.Async.Deferred();
- now = new Date;
+// now = new Date;
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 1: " + res); return res;});
if (aValue != null) {
var key, value;
var decryptedData;
var decryptedValue;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
//MochiKit.Logging.logDebug("[" + (new Date() - now) + "] computed key");
value = new Clipperz.ByteArray().appendBase64String(aValue);
//MochiKit.Logging.logDebug("[" + (new Date() - now) + "] appendedBase64String");
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 1.1: " /* + res*/); return res;});
deferredResult.addCallback(Clipperz.Crypto.AES.deferredDecrypt, key, value);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 2: " /* + res*/); return res;});
deferredResult.addCallback(MochiKit.Async.wait, 0.1);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 3: " /* + res*/); return res;});
deferredResult.addCallback(function(aResult) {
return aResult.asString();
});
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 4: " /* + res*/); return res;});
deferredResult.addCallback(MochiKit.Async.wait, 0.1);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 5: " /* + res*/); return res;});
deferredResult.addCallback(Clipperz.Base.evalJSON);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 6: " /* + res*/); return res;});
deferredResult.addErrback(function(anError) {
MochiKit.Logging.logError("Error while decrypting data");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
})
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + (new Date() - now) + "] Clipperz.PM.Crypto.deferredDecrypt - 7: " /* + res*/); return res;});
} else {
deferredResult.addCallback(function() {
return null;
});
}
deferredResult.callback();
return deferredResult;
},
'hash': Clipperz.Crypto.SHA.sha_d256
},
//#####################################################################
-/*
+
'0.4': {
'encrypt': function(aKey, aValue, aNonce) {
var result;
var key, value;
var data;
var dataToEncrypt;
var encryptedData;
-//MochiKit.Logging.logDebug(">>> [" + (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;
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);
- 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;
}
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"
}
},
//-------------------------------------------------------------------------
'encrypt': function(aKey, aValue, aVersion) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].encrypt(aKey, aValue);
},
'deferredEncrypt': function(aKey, aValue, aVersion) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].deferredEncrypt(aKey, aValue);
},
'encryptWithCurrentVersion': function(aKey, aValue) {
return Clipperz.PM.Crypto.encrypt(aKey, aValue, Clipperz.PM.Crypto.encryptingFunctions.currentVersion);
},
'deferredEncryptWithCurrentVersion': function(aKey, aValue) {
return Clipperz.PM.Crypto.deferredEncrypt(aKey, aValue, Clipperz.PM.Crypto.encryptingFunctions.currentVersion);
},
//.........................................................................
'decrypt': function(aKey, aValue, aVersion) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].decrypt(aKey, aValue);
},
'deferredDecrypt': function(aKey, aValue, aVersion) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].deferredDecrypt(aKey, aValue);
},
//-------------------------------------------------------------------------
'randomKey': function() {
return Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
},
//-------------------------------------------------------------------------
'passwordEntropy': function(aValue) {
var result;
var bitPerChar;
bitPerChar = 4;
if (/[a-z]/.test(aValue)) {
bitPerChar ++;
}
if (/[A-Z]/.test(aValue)) {
bitPerChar ++;
}
if (/[^a-zA-Z0-9]/.test(aValue)) {
bitPerChar ++;
}
//MochiKit.Logging.logDebug("--- bitPerChar: " + bitPerChar);
result = aValue.length * bitPerChar;
return result;
},
//-------------------------------------------------------------------------
'nullValue': "####",
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
//*****************************************************************************
MochiKit.Base.update(Clipperz.PM.Crypto.communicationProtocol.versions, {
'current': Clipperz.PM.Crypto.communicationProtocol.versions[Clipperz.PM.Crypto.communicationProtocol.currentVersion]
});
MochiKit.Base.update(Clipperz.PM.Crypto.encryptingFunctions.versions, {
'current': Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion]
});
//*****************************************************************************
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
@@ -1,194 +1,195 @@
{
"copyright.values": {
"mochikit.repository": "http://svn.mochikit.com/mochikit/trunk/",
"mochikit.version": "1249"
},
"html.template": "index_template.html",
"js": [
"MochiKit/Base.js",
"MochiKit/Iter.js",
"MochiKit/DOM.js",
"MochiKit/Style.js",
"MochiKit/Signal.js",
"MochiKit/Format.js",
"MochiKit/Async.js",
"MochiKit/Selector.js",
"MochiKit/Logging.js",
"MochiKit/LoggingPane.js",
"YUI/yahoo.js",
"YUI/animation.js",
"YUI/event.js",
"YUI/dom.js",
"YUI/dragdrop.js",
"YUI/logger.js",
"YUI-extensions/yutil.js",
"YUI-extensions/Bench.js",
"YUI-extensions/Date.js",
"YUI-extensions/DomHelper.js",
"YUI-extensions/Element.js",
"YUI-extensions/CompositeElement.js",
"YUI-extensions/State.js",
"YUI-extensions/EventManager.js",
"YUI-extensions/KeyMap.js",
"YUI-extensions/Layer.js",
"YUI-extensions/MixedCollection.js",
"YUI-extensions/State.js",
"YUI-extensions/UpdateManager.js",
"YUI-extensions/anim/Actor.js",
"YUI-extensions/anim/Animator.js",
"YUI-extensions/dd/Registry.js",
"YUI-extensions/dd/ScrollManager.js",
"YUI-extensions/dd/StatusProxy.js",
"YUI-extensions/layout/ContentPanels.js",
"YUI-extensions/layout/LayoutManager.js",
"YUI-extensions/layout/BorderLayout.js",
"YUI-extensions/layout/BasicLayoutRegion.js",
"YUI-extensions/layout/LayoutRegion.js",
"YUI-extensions/layout/LayoutStateManager.js",
"YUI-extensions/layout/SplitLayoutRegion.js",
"YUI-extensions/layout/BorderLayoutRegions.js",
"YUI-extensions/widgets/BasicDialog.js",
"YUI-extensions/widgets/Button.js",
"YUI-extensions/widgets/MessageBox.js",
"YUI-extensions/widgets/Resizable.js",
"YUI-extensions/widgets/SplitBar.js",
"YUI-extensions/widgets/TabPanel.js",
"YUI-extensions/widgets/TemplateView.js",
"YUI-extensions/widgets/Toolbar.js",
"YUI-extensions/widgets/InlineEditor.js",
"YUI-extensions/widgets/QuickTips.js",
"YUI-extensions/CSS.js",
"JSON/json2.js",
"Clipperz/ByteArray.js",
"Clipperz/Base.js",
"Clipperz/CSVProcessor.js",
"Clipperz/KeePassExportProcessor.js",
"Clipperz/Date.js",
"Clipperz/DOM.js",
"Clipperz/Signal.js",
"Clipperz/Style.js",
"Clipperz/Set.js",
"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",
"Clipperz/Crypto/SRP.js",
"Clipperz/Crypto/RSA.js",
"Clipperz/PM/Strings/Strings_en-US.js",
"Clipperz/PM/Strings/Strings_it-IT.js",
"Clipperz/PM/Strings/Strings_pt-BR.js",
"Clipperz/PM/Strings/Strings_ja-JP.js",
"Clipperz/PM/Strings/Strings_zh-CN.js",
"Clipperz/PM/Strings/Strings_es-ES.js",
"Clipperz/PM/Strings/Strings_fr-FR.js",
"Clipperz/PM/Strings/Strings_ru-RU.js",
"Clipperz/PM/Strings.js",
"Clipperz/PM/Strings/MessagePanelConfigurations.js",
"Clipperz/PM/Date.js",
"Clipperz/PM/Components/BaseComponent.js",
"Clipperz/PM/Components/MessageBox.js",
"Clipperz/PM/Components/TextFormField.js",
"Clipperz/PM/Components/PasswordEntropyDisplay.js",
"Clipperz/PM/Components/PasswordGenerator.js",
"Clipperz/PM/Components/Panels/BasePanel.js",
"Clipperz/PM/Components/Panels/LoginPanel.js",
"Clipperz/PM/Components/Panels/MainPanel.js",
"Clipperz/PM/Components/Panels/AccountPanel.js",
"Clipperz/PM/Components/Panels/DataPanel.js",
"Clipperz/PM/Components/Panels/ContactsPanel.js",
"Clipperz/PM/Components/Panels/ToolsPanel.js",
"Clipperz/PM/Components/Panels/LogoutPanel.js",
"Clipperz/PM/Components/RecordDetail/MainComponent.js",
"Clipperz/PM/Components/RecordDetail/AbstractComponent.js",
"Clipperz/PM/Components/RecordDetail/HeaderComponent.js",
"Clipperz/PM/Components/RecordDetail/TitleComponent.js",
"Clipperz/PM/Components/RecordDetail/NotesComponent.js",
"Clipperz/PM/Components/RecordDetail/FieldComponent.js",
"Clipperz/PM/Components/RecordDetail/AbstractFieldSubComponent.js",
"Clipperz/PM/Components/RecordDetail/FieldButtonComponent.js",
"Clipperz/PM/Components/RecordDetail/FieldLabelComponent.js",
"Clipperz/PM/Components/RecordDetail/FieldDragHandler.js",
"Clipperz/PM/Components/RecordDetail/FieldValueComponent.js",
"Clipperz/PM/Components/RecordDetail/FieldTypeComponent.js",
"Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js",
"Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js",
"Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js",
"Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js",
"Clipperz/PM/Components/RecordDetail/CreationWizard.js",
"Clipperz/PM/Components/TabPanel/TabPanelController.js",
"Clipperz/PM/Components/Import/MainComponent.js",
"Clipperz/PM/Components/Import/GenericImportComponent.js",
"Clipperz/PM/Components/Import/CSVImportComponent.js",
"Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js",
"Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js",
"Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js",
"Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js",
"Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js",
"Clipperz/PM/Components/Import/ExcelImportComponent.js",
"Clipperz/PM/Components/Import/PasswordPlusImportComponent.js",
"Clipperz/PM/Components/Import/ClipperzImportComponent.js",
"Clipperz/PM/Components/Import/RoboFormImportComponent.js",
"Clipperz/PM/Components/Import/KeePassImportComponent.js",
"Clipperz/PM/Components/Printing/Header.js",
"Clipperz/PM/Components/Printing/Record.js",
"Clipperz/PM/Components/Printing/Footer.js",
"Clipperz/PM/Components/OTP/MainComponent.js",
"Clipperz/PM/Components/Compact/CompactHeader.js",
"Clipperz/PM/Components/Compact/LoginForm.js",
"Clipperz/PM/Components/Compact/CompactInterface.js",
"Clipperz/PM/Toll.js",
"Clipperz/PM/Proxy.js",
"Clipperz/PM/Proxy/Proxy.JSON.js",
"Clipperz/PM/Proxy/Proxy.Offline.js",
"Clipperz/PM/Proxy/Proxy.Offline.DataStore.js",
"Clipperz/PM/Connection.js",
"Clipperz/PM/Crypto.js",
"Clipperz/PM/BookmarkletProcessor.js",
"Clipperz/PM/DataModel/User.js",
"Clipperz/PM/DataModel/UserPreferences.js",
"Clipperz/PM/DataModel/Header.js",
"Clipperz/PM/DataModel/Statistics.js",
"Clipperz/PM/DataModel/Record.js",
"Clipperz/PM/DataModel/RecordField.js",
"Clipperz/PM/DataModel/RecordVersion.js",
"Clipperz/PM/DataModel/DirectLogin.js",
"Clipperz/PM/DataModel/DirectLoginReference.js",
"Clipperz/PM/DataModel/DirectLoginInput.js",
"Clipperz/PM/DataModel/DirectLoginBinding.js",
"Clipperz/PM/DataModel/OneTimePasswordManager.js",
"Clipperz/PM/DataModel/OneTimePassword.js",
"Clipperz/YUI/IBLayoutManager.js",
"Clipperz/YUI/IBLayoutRegion.js",
"Clipperz/YUI/Drawer.js",
"Clipperz/YUI/Collapser.js",
"Clipperz/YUI/MessageBox.js",
"Clipperz/YUI/DomHelper.js",
"Clipperz/PM/Main.js"
],
"css": [
"yui-extensions/reset-min.css",
"yui-extensions/core.css",
"yui-extensions/basic-dialog.css",
"yui-extensions/button.css",
"clipperz/clipperz.css",
"clipperz/compact.css",
"clipperz/ytheme-clipperz.css"
],
"staticResources": [
"accountDeleted.html",
"error.html",
"logout.html",
"static.css"
]
}
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
--- a/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<c; i++) {
+ result[i] = aWord[i] ^ aKey.byteAtIndex(aPreviousWordIndex + i);
+ }
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'sboxShakeup': function(aWord) {
+ var result;
+ var sbox;
+ var i,c;
+
+ result = [];
+ sbox = Clipperz.Crypto.AES_2.sbox();
+ c =4;
+ for (i=0; i<c; i++) {
+ result[i] = sbox[aWord[i]];
+ }
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'stretchKey': function(aKey) {
+ var currentWord;
+ var keyLength;
+ var previousStretchIndex;
+ var i,c;
+
+ keyLength = aKey.length();
+ previousStretchIndex = keyLength - this.keySize();
+
+ currentWord = [ aKey.byteAtIndex(keyLength - 4),
+ aKey.byteAtIndex(keyLength - 3),
+ aKey.byteAtIndex(keyLength - 2),
+ aKey.byteAtIndex(keyLength - 1) ];
+ currentWord = this.keyScheduleCore(currentWord, keyLength / this.keySize());
+
+ if (this.keySize() == 256/8) {
+ c = 8;
+ } else if (this.keySize() == 128/8){
+ c = 4;
+ }
+
+ for (i=0; i<c; i++) {
+ if (i == 4) {
+ // fifth streatch word
+ currentWord = this.sboxShakeup(currentWord);
+ }
+
+ currentWord = this.xorWithPreviousStretchValues(aKey, currentWord, previousStretchIndex + (i*4));
+ aKey.appendBytes(currentWord);
+ }
+
+ return aKey;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'stretchedKey': function() {
+ if (this._stretchedKey == null) {
+ var stretchedKey;
+
+ stretchedKey = this.key().clone();
+
+ while (stretchedKey.length() < this.keySize()) {
+ stretchedKey.appendByte(0);
+ }
+
+ while (stretchedKey.length() < this.b()) {
+ stretchedKey = this.stretchKey(stretchedKey);
+ }
+
+ this._stretchedKey = stretchedKey.split(0, this.b());
+ }
+
+ return this._stretchedKey;
+ },
+
+ //=========================================================================
+ __syntaxFix__: "syntax fix"
+});
+
+//#############################################################################
+
+Clipperz.Crypto.AES_2.State = function(args) {
+ args = args || {};
+
+ this._data = args.block.slice(0);
+ this._key = args.key;
+
+ return this;
+}
+
+Clipperz.Crypto.AES_2.State.prototype = MochiKit.Base.update(null, {
+
+ 'key': function() {
+ return this._key;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'data': function() {
+ return this._data;
+ },
+
+ 'setData': function(aValue) {
+ this._data = aValue;
+ },
+
+ //=========================================================================
+
+ 'addRoundKey': function(aRoundNumber) {
+ // each byte of the state is combined with the round key; each round key is derived from the cipher key using a key schedule.
+ var data;
+ var stretchedKey;
+ var firstStretchedKeyIndex;
+ var i,c;
+
+ data = this.data();
+ stretchedKey = this.key().stretchedKey();
+ firstStretchedKeyIndex = aRoundNumber * (128/8);
+ c = 128/8;
+ for (i=0; i<c; i++) {
+ data[i] = data[i] ^ stretchedKey.byteAtIndex(firstStretchedKeyIndex + i);
+ }
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'subBytes': function() {
+ // a non-linear substitution step where each byte is replaced with another according to a lookup table.
+ var i,c;
+ var data;
+ var sbox;
+
+ data = this.data();
+ sbox = Clipperz.Crypto.AES_2.sbox();
+
+ c = 16;
+ for (i=0; i<c; i++) {
+ data[i] = sbox[data[i]];
+ }
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'shiftRows': function() {
+ // a transposition step where each row of the state is shifted cyclically a certain number of steps.
+ var newValue;
+ var data;
+ var shiftMapping;
+ var i,c;
+
+ newValue = new Array(16);
+ data = this.data();
+ shiftMapping = Clipperz.Crypto.AES_2.shiftRowMapping();
+// [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11];
+ c = 16;
+ for (i=0; i<c; i++) {
+ newValue[i] = data[shiftMapping[i]];
+ }
+ for (i=0; i<c; i++) {
+ data[i] = newValue[i];
+ }
+ },
+
+ //-----------------------------------------------------------------------------
+/*
+ 'mixColumnsWithValues': function(someValues) {
+ var result;
+ var a;
+ var i,c;
+
+ c = 4;
+ result = [];
+ a = [];
+ for (i=0; i<c; i++) {
+ a[i] = [];
+ a[i][1] = someValues[i]
+ if ((a[i][1] & 0x80) == 0x80) {
+ a[i][2] = (a[i][1] << 1) ^ 0x11b;
+ } else {
+ a[i][2] = a[i][1] << 1;
+ }
+
+ a[i][3] = a[i][2] ^ a[i][1];
+ }
+
+ for (i=0; i<c; i++) {
+ var x;
+
+ x = Clipperz.Crypto.AES_2.mixColumnsMatrix()[i];
+ result[i] = a[0][x[0]] ^ a[1][x[1]] ^ a[2][x[2]] ^ a[3][x[3]];
+ }
+
+ return result;
+ },
+
+ 'mixColumns': function() {
+ // a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation.
+ var data;
+ var i, c;
+
+ data = this.data();
+ c = 4;
+ for(i=0; i<c; i++) {
+ var blockIndex;
+ var mixedValues;
+
+ blockIndex = i * 4;
+ mixedValues = this.mixColumnsWithValues([ data[blockIndex + 0],
+ data[blockIndex + 1],
+ data[blockIndex + 2],
+ data[blockIndex + 3]]);
+ data[blockIndex + 0] = mixedValues[0];
+ data[blockIndex + 1] = mixedValues[1];
+ data[blockIndex + 2] = mixedValues[2];
+ data[blockIndex + 3] = mixedValues[3];
+ }
+ },
+*/
+
+ 'mixColumns': function() {
+ // a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation.
+ var data;
+ var i, c;
+ var a_1;
+ var a_2;
+
+ a_1 = new Array(4);
+ a_2 = new Array(4);
+
+ data = this.data();
+ c = 4;
+ for(i=0; i<c; i++) {
+ var blockIndex;
+ var ii, cc;
+
+ blockIndex = i * 4;
+
+ cc = 4;
+ for (ii=0; ii<cc; ii++) {
+ var value;
+
+ value = data[blockIndex + ii];
+ a_1[ii] = value;
+ a_2[ii] = (value & 0x80) ? ((value << 1) ^ 0x011b) : (value << 1);
+ }
+
+ data[blockIndex + 0] = a_2[0] ^ a_1[1] ^ a_2[1] ^ a_1[2] ^ a_1[3];
+ data[blockIndex + 1] = a_1[0] ^ a_2[1] ^ a_1[2] ^ a_2[2] ^ a_1[3];
+ data[blockIndex + 2] = a_1[0] ^ a_1[1] ^ a_2[2] ^ a_1[3] ^ a_2[3];
+ data[blockIndex + 3] = a_1[0] ^ a_2[0] ^ a_1[1] ^ a_1[2] ^ a_2[3];
+ }
+ },
+
+ //=========================================================================
+
+ 'spinRound': function(aRoundNumber) {
+ this.addRoundKey(aRoundNumber);
+ this.subBytes();
+ this.shiftRows();
+ this.mixColumns();
+ },
+
+ 'spinLastRound': function() {
+ this.addRoundKey(this.key().numberOfRounds() - 1);
+ this.subBytes();
+ this.shiftRows();
+ this.addRoundKey(this.key().numberOfRounds());
+ },
+
+ //=========================================================================
+
+ 'encrypt': function() {
+ var i,c;
+
+ c = this.key().numberOfRounds() - 1;
+ for (i=0; i<c; i++) {
+ this.spinRound(i);
+ }
+
+ this.spinLastRound();
+ },
+
+ //=========================================================================
+ __syntaxFix__: "syntax fix"
+});
+
+//#############################################################################
+
+Clipperz.Crypto.AES_2.VERSION = "0.1";
+Clipperz.Crypto.AES_2.NAME = "Clipperz.Crypto.AES_2";
+
+MochiKit.Base.update(Clipperz.Crypto.AES_2, {
+
+// http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-AES.html
+// http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
+// http://en.wikipedia.org/wiki/Rijndael_key_schedule
+// http://en.wikipedia.org/wiki/Rijndael_S-box
+
+ '__repr__': function () {
+ return "[" + this.NAME + " " + this.VERSION + "]";
+ },
+
+ 'toString': function () {
+ return this.__repr__();
+ },
+
+ //=============================================================================
+
+ '_sbox': null,
+ 'sbox': function() {
+ if (Clipperz.Crypto.AES_2._sbox == null) {
+ Clipperz.Crypto.AES_2._sbox = [
+0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
+ ];
+ }
+
+ return Clipperz.Crypto.AES_2._sbox;
+ },
+
+ //-----------------------------------------------------------------------------
+ //
+ // 0 4 8 12 0 4 8 12
+ // 1 5 9 13 => 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<c; i++) {
+ result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i];
+ }
+
+ messageIndex += blockSize;
+// nonce = self.incrementNonce(nonce);
+ self.incrementNonce(nonce)
+ }
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'encrypt': function(aKey, someData, aNonce) {
+ var result;
+ var nonce;
+ var encryptedData;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+ nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8);
+
+ encryptedData = Clipperz.Crypto.AES_2.encryptBlocks(key, someData.arrayValues(), nonce.arrayValues());
+
+ result = nonce.appendBytes(encryptedData);
+
+ return result;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'decrypt': function(aKey, someData) {
+ var result;
+ var nonce;
+ var encryptedData;
+ var decryptedData;
+ var dataIterator;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+
+ encryptedData = someData.arrayValues();
+ nonce = encryptedData.slice(0, (128/8));
+ encryptedData = encryptedData.slice(128/8);
+ decryptedData = Clipperz.Crypto.AES_2.encryptBlocks(key, encryptedData, nonce);
+
+ result = new Clipperz.ByteArray(decryptedData);
+
+ return result;
+ },
+
+ //=============================================================================
+
+ 'deferredEncryptExecutionChunk': function(anExecutionContext) {
+ var result;
+ var nonce;
+ var self;
+ var messageIndex;
+ var messageLength;
+ var blockSize;
+ var executionLimit;
+ var startTime, endTime;
+
+ self = Clipperz.Crypto.AES_2;
+ startTime = new Date();
+ blockSize = 128/8;
+ messageLength = anExecutionContext.messageArray().length;
+ nonce = anExecutionContext.nonceArray();
+ result = anExecutionContext.resultArray();
+
+ messageIndex = anExecutionContext.executionStep();
+ executionLimit = messageIndex + anExecutionContext.elaborationChunkSize();
+ executionLimit = Math.min(executionLimit, messageLength);
+
+ while (messageIndex < executionLimit) {
+ var encryptedBlock;
+ var i,c;
+
+//console.log("+++ nonce: [" + nonce + "]")
+ encryptedBlock = self.encryptBlock(anExecutionContext.key(), nonce);
+
+ if ((executionLimit - messageIndex) > blockSize) {
+ c = blockSize;
+ } else {
+ c = executionLimit - messageIndex;
+ }
+
+ for (i=0; i<c; i++) {
+ result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i];
+ }
+
+ messageIndex += blockSize;
+// nonce = self.incrementNonce(nonce);
+ self.incrementNonce(nonce);
+ }
+ anExecutionContext.setExecutionStep(messageIndex);
+ endTime = new Date();
+ anExecutionContext.tuneExecutionParameters(endTime - startTime);
+
+ return anExecutionContext;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'deferredEncryptBlocks': function(anExecutionContext) {
+ var deferredResult;
+
+//console.log("executionContext", anExecutionContext)
+//console.log(" --- nonce: " + anExecutionContext.nonceArray())
+ if (! anExecutionContext.isDone()) {
+ deferredResult = Clipperz.Async.callbacks("Clipperz.Crypto.AES_2.deferredEncryptBloks", [
+ Clipperz.Crypto.AES_2.deferredEncryptExecutionChunk,
+ MochiKit.Base.method(anExecutionContext, 'pause'),
+ Clipperz.Crypto.AES_2.deferredEncryptBlocks
+ ], {trace:false}, anExecutionContext);
+ } else {
+ deferredResult = MochiKit.Async.succeed(anExecutionContext);
+ }
+
+ return deferredResult;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'deferredEncrypt': function(aKey, someData, aNonce) {
+ var deferredResult;
+ var executionContext;
+ var result;
+ var nonce;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+ nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8);
+
+ executionContext = new Clipperz.Crypto.AES_2.DeferredExecutionContext({key:key, message:someData, nonce:nonce});
+
+ deferredResult = new Clipperz.Async.Deferred("AES.deferredEncrypt");
+ deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptBlocks);
+ deferredResult.addCallback(function(anExecutionContext) {
+ var result;
+
+ result = anExecutionContext.nonce().clone();
+ result.appendBytes(anExecutionContext.resultArray());
+
+ return result;
+ });
+ deferredResult.callback(executionContext)
+
+ return deferredResult;
+ },
+
+ //-----------------------------------------------------------------------------
+
+ 'deferredDecrypt': function(aKey, someData) {
+ var deferredResult
+ var nonce;
+ var message;
+ var key;
+
+ key = new Clipperz.Crypto.AES_2.Key({key:aKey});
+ nonce = someData.split(0, (128/8));
+//console.log("nonce: [" + nonce.arrayValues() + "]")
+ message = someData.split(128/8);
+//console.log("message: [" + message.arrayValues() + "]")
+ executionContext = new Clipperz.Crypto.AES_2.DeferredExecutionContext({key:key, message:message, nonce:nonce});
+
+ deferredResult = new Clipperz.Async.Deferred("AES.deferredDecrypt");
+ deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptBlocks);
+ deferredResult.addCallback(function(anExecutionContext) {
+ return anExecutionContext.result();
+ });
+ deferredResult.callback(executionContext);
+
+ return deferredResult;
+ },
+
+ //-----------------------------------------------------------------------------
+ __syntaxFix__: "syntax fix"
+
+});
+
+//#############################################################################
+
+//Clipperz.Crypto.AES_2.DeferredExecution = {
+// 'chunkSize': 16384, // 4096, // 1024 4096 8192 16384 32768;
+// 'pauseTime': 0.02 // 0.2
+//}
+
+Clipperz.Crypto.AES_2.exception = {
+ 'UnsupportedKeySize': new MochiKit.Base.NamedError("Clipperz.Crypto.AES_2.exception.UnsupportedKeySize")
+};
diff --git a/frontend/gamma/js/Clipperz/PM/Crypto.js b/frontend/gamma/js/Clipperz/PM/Crypto.js
index cd10e33..7edf17f 100644
--- a/frontend/gamma/js/Clipperz/PM/Crypto.js
+++ b/frontend/gamma/js/Clipperz/PM/Crypto.js
@@ -1,191 +1,191 @@
/*
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/.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
if (typeof(Clipperz.PM.Crypto) == 'undefined') { Clipperz.PM.Crypto = {}; }
Clipperz.PM.Crypto.VERSION = "0.2";
Clipperz.PM.Crypto.NAME = "Clipperz.PM.Crypto";
Clipperz.PM.Crypto.encryptingFunctions = {};
MochiKit.Base.update(Clipperz.PM.Crypto, {
'__repr__': function () {
return "[" + this.NAME + " " + this.VERSION + "]";
},
//-------------------------------------------------------------------------
'toString': function () {
return this.__repr__();
},
//-------------------------------------------------------------------------
/*
'communicationProtocol': {
'currentVersion': '0.2',
'versions': {
'0.1': Clipperz.PM.Connection.SRP['1.0'], //Clipperz.Crypto.SRP.versions['1.0'].Connection,
'0.2': Clipperz.PM.Connection.SRP['1.1'] //Clipperz.Crypto.SRP.versions['1.1'].Connection
},
'fallbackVersions': {
'current': '0.1',
'0.2': '0.1',
'0.1': null
}
},
*/
//-------------------------------------------------------------------------
'encryptingFunctions': {
- 'currentVersion': '0.3',
+ 'currentVersion': '0.4',
'versions': {
//#####################################################################
'0.1': {
'encrypt': function(aKey, aValue) {
return Clipperz.Crypto.Base.encryptUsingSecretKey(aKey, Clipperz.Base.serializeJSON(aValue));
},
'deferredEncrypt': function(aKey, aValue) {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("Crypto[0.1].deferredEncrypt");
deferredResult.addCallback(Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].encrypt, aKey, aValue);
deferredResult.callback();
return deferredResult;
},
'decrypt': function(aKey, aValue) {
var result;
if (aValue != null) {
result = Clipperz.Base.evalJSON(Clipperz.Crypto.Base.decryptUsingSecretKey(aKey, aValue));
} else {
result = null;
}
return result;
},
'deferredDecrypt': function(aKey, aValue) {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("Crypto.[0.1].deferredDecrypt");
deferredResult.addCallback(Clipperz.PM.Crypto.encryptingFunctions.versions['0.1'].decrypt, aKey, aValue);
deferredResult.callback();
return deferredResult;
},
'hash': function(aValue) {
var result;
var strngResult;
stringResult = Clipperz.Crypto.Base.computeHashValue(aValue.asString()); // !!!!!!!
result = new Clipperz.ByteArray("0x" + stringResult);
return result;
},
'deriveKey': function(aStringValue) {
return Clipperz.Crypto.Base.computeHashValue(aStringValue);
}
},
//#####################################################################
'0.2': {
'encrypt': function(aKey, aValue, aNonce) {
var result;
var key, value;
var dataToEncrypt;
var encryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray(Clipperz.Base.serializeJSON(aValue));
dataToEncrypt = Clipperz.Crypto.SHA.sha_d256(value).appendBlock(value);
encryptedData = Clipperz.Crypto.AES.encrypt(key, dataToEncrypt, aNonce);
result = encryptedData.toBase64String();
return result;
},
'deferredEncrypt': function(aKey, aValue, aNonce) {
var deferredResult;
var key, value;
var dataToEncrypt;
// var encryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray(Clipperz.Base.serializeJSON(aValue));
dataToEncrypt = Clipperz.Crypto.SHA.sha_d256(value).appendBlock(value);
deferredResult = new Clipperz.Async.Deferred("Crypto[0.2].deferredEncrypt")
deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, dataToEncrypt, aNonce);
deferredResult.addCallback(function(aResult) {
return aResult.toBase64String();
})
deferredResult.callback();
return deferredResult;
},
'decrypt': function(aKey, aValue) {
var result;
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);
decryptedData = Clipperz.Crypto.AES.decrypt(key, value);
decryptedValue = decryptedData.split((256/8));
try {
result = Clipperz.Base.evalJSON(decryptedValue.asString());
} catch (exception) {
Clipperz.logError("Error while decrypting data [1]");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}
} else {
result = null;
}
return result;
},
'deferredDecrypt': function(aKey, aValue) {
var result;
if (aValue != null) {
var deferredResult;
var key, value;
// var decryptedData;
@@ -195,314 +195,352 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
deferredResult = new Clipperz.Async.Deferred("Crypto.[0.2].deferredDecrypt");
deferredResult.addCallback(Clipperz.Crypto.AES.deferredDecrypt, key, value);
deferredResult.addCallback(function(aResult) {
var result;
var decryptedData;
decryptedData = aResult.split((256/8));
try {
result = Clipperz.Base.evalJSON(decryptedData.asString());
} catch (exception) {
Clipperz.logError("Error while decrypting data [2]");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}
return result;
})
deferredResult.callback();
result = deferredResult;
} else {
result = MochiKit.Async.succeed(null);
}
return result;
},
'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;
}
},
//#####################################################################
'0.3': {
'encrypt': function(aKey, aValue, aNonce) {
var result;
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);
encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce);
result = encryptedData.toBase64String();
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.3].deferredEncrypt")
deferredResult.addCallback(Clipperz.Crypto.AES.deferredEncrypt, key, data, aNonce);
deferredResult.addCallback(function(aResult) {
return aResult.toBase64String();
})
deferredResult.callback();
return deferredResult;
},
'decrypt': function(aKey, aValue) {
var result;
if (aValue != null) {
var key, value;
var decryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray().appendBase64String(aValue);
decryptedData = Clipperz.Crypto.AES.decrypt(key, value);
value = decryptedData.asString();
try {
result = Clipperz.Base.evalJSON(value);
} catch (exception) {
Clipperz.logError("Error while decrypting data [3]");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}
} else {
result = null;
}
return result;
},
'deferredDecrypt': function(aKey, aValue) {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("Crypto[0.3].deferredDecrypt", {trace: false});
// now = new Date;
if (aValue != null) {
var key, value;
// var decryptedData;
key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey));
value = new Clipperz.ByteArray().appendBase64String(aValue);
deferredResult.addCallback(Clipperz.Crypto.AES.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) {
+console.log("PIPPO_1", 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;
}
-
},
//#####################################################################
-/*
+
'0.4': {
'encrypt': function(aKey, aValue, aNonce) {
var result;
var key, value;
var data;
var dataToEncrypt;
var encryptedData;
-//Clipperz.logDebug(">>> [" + (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;
if (aValue != null) {
var key, value;
var decryptedData;
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;
}
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"
}
},
//-------------------------------------------------------------------------
'encrypt': function(aKey, aValue, aVersion) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].encrypt(aKey, aValue);
},
'deferredEncrypt': function(someParameters) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters['version']].deferredEncrypt(someParameters['key'], someParameters['value']);
},
//.........................................................................
'decrypt': function(aKey, aValue, aVersion) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[aVersion].decrypt(aKey, aValue);
},
'deferredDecrypt': function(someParameters) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters['version']].deferredDecrypt(someParameters['key'], someParameters['value']);
},
//-------------------------------------------------------------------------
'hash': function(aValue) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion]['hash'](aValue);
},
//-------------------------------------------------------------------------
'randomKey': function() {
return Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2);
},
//-------------------------------------------------------------------------
'deriveKey': function(aValue) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion].deriveKey(aValue);
},
//-------------------------------------------------------------------------
'passwordEntropy': function(aValue) {
var result;
var bitPerChar;
bitPerChar = 4;
if (/[a-z]/.test(aValue)) {
bitPerChar ++;
}
if (/[A-Z]/.test(aValue)) {
bitPerChar ++;
}
if (/[^a-zA-Z0-9]/.test(aValue)) {
bitPerChar ++;
}
result = aValue.length * bitPerChar;
return result;
},
//-------------------------------------------------------------------------
'nullValue': '####',
//-------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
//*****************************************************************************
//MochiKit.Base.update(Clipperz.PM.Connection.communicationProtocol.versions, {
// 'current': Clipperz.PM.Connection.communicationProtocol.versions[Clipperz.PM.Connection.communicationProtocol.currentVersion]
//});
MochiKit.Base.update(Clipperz.PM.Crypto.encryptingFunctions.versions, {
'current': Clipperz.PM.Crypto.encryptingFunctions.versions[Clipperz.PM.Crypto.encryptingFunctions.currentVersion]
});
//*****************************************************************************
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
@@ -601,210 +601,210 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
return Clipperz.Async.collectResults("User.invokeMethodNamedOnHeader [" + aMethodName + "]", {
'recordIndex': [
MochiKit.Base.method(this, 'getHeaderIndex', 'recordsIndex'),
MochiKit.Base.methodcaller(aMethodName, aValue)
],
'preferences': [
MochiKit.Base.method(this, 'getHeaderIndex', 'preferences'),
MochiKit.Base.methodcaller(aMethodName, aValue)
],
'oneTimePasswords': [
MochiKit.Base.method(this, 'getHeaderIndex', 'oneTimePasswords'),
MochiKit.Base.methodcaller(aMethodName, aValue)
]//,
// 'statistics': [
// MochiKit.Base.method(this, 'getStatistics'),
// MochiKit.Base.methodcaller(aMethodName, aValue)
// ]
}, {trace:false})();
},
//-------------------------------------------------------------------------
'invokeMethodNamedOnRecords': function (aMethodName, aValue) {
return Clipperz.Async.callbacks("User.invokeMethodNamedOnRecords[" + aMethodName + "]", [
MochiKit.Base.method(this, 'getRecords'),
MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller(aMethodName, aValue)),
Clipperz.Async.collectAll
], {trace:false});
},
//=========================================================================
'hasPendingChanges': function () {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("User.hasPendingChanges", {trace:false});
deferredResult.collectResults({
'header': [
MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'hasPendingChanges'),
MochiKit.Base.values
],
'records': MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'hasPendingChanges')
});
deferredResult.addCallback(Clipperz.Async.or);
deferredResult.callback();
// recordsIndex = legacyHeader;
// preferences = legacyHeader;
// oneTimePasswords = legacyHeader;
return deferredResult;
},
//=========================================================================
'commitTransientState': function () {
return Clipperz.Async.callbacks("User.commitTransientState", [
MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'commitTransientState'),
MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'),
MochiKit.Base.method(this, 'transientState'),
// MochiKit.Base.itemgetter('lock'),
// MochiKit.Base.method(this, 'setServerLockValue'),
MochiKit.Base.method(this, 'resetTransientState', true)
], {trace:false});
},
//-------------------------------------------------------------------------
'revertChanges': function () {
return Clipperz.Async.callbacks("User.revertChanges", [
MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'revertChanges'),
MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'revertChanges'),
MochiKit.Base.method(this, 'resetTransientState', false)
], {trace:false});
},
//=========================================================================
'deleteAllCleanTextData': function () {
return Clipperz.Async.callbacks("User.deleteAllCleanTextData", [
MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'deleteAllCleanTextData'),
MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'deleteAllCleanTextData'),
MochiKit.Base.method(this.data(), 'removeAllData'),
MochiKit.Base.method(this, 'resetTransientState', false)
], {trace:false});
},
//-------------------------------------------------------------------------
'hasAnyCleanTextData': function () {
var deferredResult;
deferredResult = new Clipperz.Async.Deferred("User.hasAnyCleanTextData", {trace:false});
deferredResult.collectResults({
'header': [
MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'hasAnyCleanTextData'),
MochiKit.Base.values
],
'records': MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'hasAnyCleanTextData'),
'data': MochiKit.Base.bind(function () {
return MochiKit.Async.succeed(! this.data().isEmpty());
}, this),
'transientState': MochiKit.Base.bind(function () {
return MochiKit.Async.succeed(MochiKit.Base.keys(this.transientState()).length != 0);
}, this)
});
deferredResult.addCallback(Clipperz.Async.or);
deferredResult.callback();
return deferredResult;
},
//=========================================================================
'prepareRemoteDataWithKey': function (aKey /*, aCurrentKey*/) {
var deferredResult;
var result;
result = {};
deferredResult = new Clipperz.Async.Deferred("User.prepareRemoteDataWithKey", {trace:false});
deferredResult.addMethod(this, 'invokeMethodNamedOnHeader', 'prepareRemoteDataWithKey', aKey /*, aCurrentKey*/);
deferredResult.addCallback(MochiKit.Base.bind(function (aResult, someHeaderPackedData) {
var header;
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);
aResult['statistics'] = this._serverData['statistics']; // "someHeaderPackedData['statistics']['data']";
return aResult;
}, this), result);
deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion);
// deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue());
deferredResult.callback();
return deferredResult;
},
//=========================================================================
'saveChanges': function () {
var deferredResult;
var messageParameters;
messageParameters = {};
deferredResult = new Clipperz.Async.Deferred("User.saveChangaes", {trace:false});
deferredResult.addMethod(this, 'getHeaderIndex', 'recordsIndex');
deferredResult.addCallback(MochiKit.Base.methodcaller('prepareRemoteDataForChangedRecords'));
deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'records');
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
deferredResult.addMethod(this, 'getPassphrase');
deferredResult.addMethod(this, 'prepareRemoteDataWithKey');
deferredResult.addCallback(Clipperz.Async.setItem, messageParameters, 'user');
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
deferredResult.addCallback(MochiKit.Async.succeed, messageParameters);
deferredResult.addMethod(this.connection(), 'message', 'saveChanges');
deferredResult.addCallback(MochiKit.Base.update, this.transientState())
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
deferredResult.addMethod(this, 'commitTransientState');
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress');
deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'userDataSuccessfullySaved');
deferredResult.addErrbackPass(MochiKit.Base.method(this, 'revertChanges'));
deferredResult.addErrbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'failureWhileSavingUserData');
deferredResult.callback();
return deferredResult;
},
//=========================================================================
__syntaxFix__: "syntax fix"
});
//-----------------------------------------------------------------------------
Clipperz.PM.DataModel.User.registerNewAccount = function (anUsername, aPassphraseFunction) {
var deferredResult;
var user;
user = new Clipperz.PM.DataModel.User({'username':anUsername, 'getPassphraseFunction':aPassphraseFunction});
deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.User.registerNewAccount", {trace:false});
deferredResult.addMethod(user, 'registerAsNewAccount');
deferredResult.addMethod(user, 'login');
deferredResult.addCallback(MochiKit.Async.succeed, user);
deferredResult.callback();
return deferredResult;
}
//-----------------------------------------------------------------------------
Clipperz.PM.DataModel.User.exception = {
LoginFailed: new MochiKit.Base.NamedError("Clipperz.PM.DataModel.User.exception.LoginFailed"),
CredentialUpgradeFailed: new MochiKit.Base.NamedError("Clipperz.PM.DataModel.User.exception.CredentialUpgradeFailed")
};
//-----------------------------------------------------------------------------
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
@@ -156,257 +156,257 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
if (this.shouldPayTolls()) {
this.tolls()[targetValue] = result;
}
return result;
},
//-------------------------------------------------------------------------
'checkToll': function (aFunctionName, someParameters) {
if (this.shouldPayTolls()) {
var localToll;
var tollParameters;
tollParameters = someParameters['toll'];
localToll = this.tolls()[tollParameters['targetValue']];
if (localToll != null) {
if (! Clipperz.PM.Toll.validate(tollParameters['targetValue'], tollParameters['toll'], localToll['cost'])) {
throw "Toll value too low.";
};
} else {
throw "Missing toll";
}
}
},
//=========================================================================
'currentStaticConnection': function () {
if (this._currentStaticConnection == null) {
this._currentStaticConnection = {};
}
return this._currentStaticConnection;
},
//-------------------------------------------------------------------------
'getConnectionForRequest': function (aFunctionName, someParameters) {
var result;
if (this.shouldPayTolls()) {
if ((typeof(someParameters['toll']) != 'undefined') && (typeof(someParameters['toll']['targetValue']) != 'undefined')) {
result = this.tolls()[someParameters['toll']['targetValue']]['connection'];
if (typeof(result) == 'undefined') {
result = {};
}
} else {
result = {};
}
} else {
result = this.currentStaticConnection();
}
return result;
},
//-------------------------------------------------------------------------
'storeConnectionForRequestWithConnectionAndResponse': function (aFunctionName, someParameters, aConnection, aResponse) {
if (this.shouldPayTolls()) {
if ((typeof(aResponse['toll']) != 'undefined')
&& (typeof(aResponse['toll']['targetValue']) != 'undefined')
&& (typeof(this.tolls()[aResponse['toll']['targetValue']]) != 'undefined')
) {
this.tolls()[aResponse['toll']['targetValue']]['connection'] = aConnection;
}
}
},
//=========================================================================
'processMessage': function (aFunctionName, someParameters) {
var result;
var connection;
connection = this.getConnectionForRequest(aFunctionName, someParameters);
switch(aFunctionName) {
case 'knock':
result = this._knock(connection, someParameters);
break;
case 'registration':
this.checkToll(aFunctionName, someParameters);
result = this._registration(connection, someParameters.parameters);
break;
case 'handshake':
this.checkToll(aFunctionName, someParameters);
result = this._handshake(connection, someParameters.parameters);
break;
case 'message':
this.checkToll(aFunctionName, someParameters);
result = this._message(connection, someParameters.parameters);
break;
case 'logout':
this._currentStaticConnection = null;
result = this._logout(connection, someParameters.parameters);
break;
}
this.storeConnectionForRequestWithConnectionAndResponse(aFunctionName, someParameters, connection, result);
return MochiKit.Async.succeed(result);
},
//=========================================================================
'_knock': function(aConnection, someParameters) {
var result;
result = {
toll: this.getTollForRequestType(someParameters['requestType'])
}
return result;
},
//-------------------------------------------------------------------------
'_registration': function(aConnection, someParameters) {
if (this.isReadOnly() == false) {
if (typeof(this.data()['users'][someParameters['credentials']['C']]) == 'undefined') {
this.data()['users'][someParameters['credentials']['C']] = {
'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'],
'records': {}
}
} else {
throw "user already exists";
}
} else {
throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly;
}
result = {
result: {
'lock': this.data()['users'][someParameters['credentials']['C']]['lock'],
'result': 'done'
},
toll: this.getTollForRequestType('CONNECT')
}
return result;
},
//-------------------------------------------------------------------------
'_handshake': function(aConnection, someParameters) {
var result;
var nextTollRequestType;
result = {};
if (someParameters.message == "connect") {
var userData;
var randomBytes;
var v;
userData = this.data()['users'][someParameters.parameters.C];
if ((typeof(userData) != 'undefined') && (userData['version'] == someParameters.version)) {
aConnection['userData'] = userData;
aConnection['C'] = someParameters.parameters.C;
} else {
aConnection['userData'] = this.data()['users']['catchAllUser'];
}
randomBytes = Clipperz.Crypto.Base.generateRandomSeed();
aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16);
v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16);
aConnection['B'] = v.add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()));
aConnection['A'] = someParameters.parameters.A;
result['s'] = aConnection['userData']['s'];
result['B'] = aConnection['B'].asString(16);
nextTollRequestType = 'CONNECT';
} else if (someParameters.message == "credentialCheck") {
var v, u, S, A, K, M1;
v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16);
u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aConnection['B'].asString(10))).toHexString(), 16);
A = new Clipperz.Crypto.BigInt(aConnection['A'], 16);
S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n());
K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(S.asString(10))).toHexString().slice(2);
M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10) + K)).toHexString().slice(2);
if (someParameters.parameters.M1 == M1) {
var M2;
M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + someParameters.parameters.M1 + K)).toHexString().slice(2);
result['M2'] = M2;
} else {
throw new Error("Client checksum verification failed! Expected <" + M1 + ">, received <" + someParameters.parameters.M1 + ">.", "Error");
}
nextTollRequestType = 'MESSAGE';
} else if (someParameters.message == "oneTimePassword") {
var otpData;
otpData = this.data()['onetimePasswords'][someParameters.parameters.oneTimePasswordKey];
try {
if (typeof(otpData) != 'undefined') {
if (otpData['status'] == 'ACTIVE') {
if (otpData['key_checksum'] == someParameters.parameters.oneTimePasswordKeyChecksum) {
result = {
'data': otpData['data'],
'version': otpData['version']
}
otpData['status'] = 'REQUESTED';
} else {
otpData['status'] = 'DISABLED';
throw "The requested One Time Password has been disabled, due to a wrong keyChecksum";
}
} else {
throw "The requested One Time Password was not active";
}
} else {
throw "The requested One Time Password has not been found"
}
} catch (exception) {
result = {
'data': Clipperz.PM.Crypto.randomKey(),
'version': Clipperz.PM.Connection.communicationProtocol.currentVersion
}
}
nextTollRequestType = 'CONNECT';
} else {
Clipperz.logError("Clipperz.PM.Proxy.Test.handshake - unhandled message: " + someParameters.message);
}
result = {
result: result,
toll: this.getTollForRequestType(nextTollRequestType)
}
return result;
},
//-------------------------------------------------------------------------
'_message': function(aConnection, someParameters) {
var result;
result = {};
//=====================================================================
@@ -444,257 +444,257 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
//=====================================================================
} else if (someParameters.message == 'getRecordDetail') {
/*
var recordData;
var currentVersionData;
recordData = this.userData()['records'][someParameters['parameters']['reference']];
result['reference'] = someParameters['parameters']['reference'];
result['data'] = recordData['data'];
result['version'] = recordData['version'];
result['creationData'] = recordData['creationDate'];
result['updateDate'] = recordData['updateDate'];
result['accessDate'] = recordData['accessDate'];
currentVersionData = recordData['versions'][recordData['currentVersion']];
result['currentVersion'] = {};
result['currentVersion']['reference'] = recordData['currentVersion'];
result['currentVersion']['version'] = currentVersionData['version'];
result['currentVersion']['header'] = currentVersionData['header'];
result['currentVersion']['data'] = currentVersionData['data'];
result['currentVersion']['creationData'] = currentVersionData['creationDate'];
result['currentVersion']['updateDate'] = currentVersionData['updateDate'];
result['currentVersion']['accessDate'] = currentVersionData['accessDate'];
if (typeof(currentVersionData['previousVersion']) != 'undefined') {
result['currentVersion']['previousVersionKey'] = currentVersionData['previousVersionKey'];
result['currentVersion']['previousVersion'] = currentVersionData['previousVersion'];
}
*/
MochiKit.Base.update(result, aConnection['userData']['records'][someParameters['parameters']['reference']]);
result['reference'] = someParameters['parameters']['reference'];
//=====================================================================
//
// R E A D - W R I T E M e t h o d s
//
//=====================================================================
} else if (someParameters.message == 'upgradeUserCredentials') {
if (this.isReadOnly() == false) {
var parameters;
var credentials;
parameters = someParameters['parameters'];
credentials = parameters['credentials'];
if ((credentials['C'] == null)
|| (credentials['s'] == null)
|| (credentials['v'] == null)
|| (credentials['version'] != Clipperz.PM.Connection.communicationProtocol.currentVersion)
) {
result = Clipperz.PM.DataModel.User.exception.CredentialUpgradeFailed;
} else {
var oldCValue;
oldCValue = aConnection['C'];
this.data()['users'][credentials['C']] = aConnection['userData'];
aConnection['C'] = credentials['C'];
aConnection['userData']['s'] = credentials['s'];
aConnection['userData']['v'] = credentials['v'];
aConnection['userData']['version'] = credentials['version'];
aConnection['userData']['userDetails'] = parameters['user']['header'];
aConnection['userData']['userDetailsVersion'] = parameters['user']['version'];
aConnection['userData']['statistics'] = parameters['user']['statistics'];
aConnection['userData']['lock'] = parameters['user']['lock'];
delete this.data()['users'][oldCValue];
result = {result:"done", parameters:parameters};
}
} else {
throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly;
}
//=====================================================================
/* } else if (someParameters.message == 'updateData') {
if (this.isReadOnly() == false) {
var i, c;
if (this.userData()['lock'] != someParameters['parameters']['user']['lock']) {
throw "the lock attribute is not processed correctly"
}
this.userData()['userDetails'] = someParameters['parameters']['user']['header'];
this.userData()['statistics'] = someParameters['parameters']['user']['statistics'];
this.userData()['userDetailsVersions'] = someParameters['parameters']['user']['version'];
c = someParameters['parameters']['records'].length;
for (i=0; i<c; i++) {
var currentRecord;
var currentRecordData;
currentRecordData = someParameters['parameters']['records'][i];
currentRecord = this.userData()['records'][currentRecordData['record']['reference']];
if (currentRecord == null) {
}
currentRecord['data'] = currentRecordData['record']['data'];
currentRecord['version'] = currentRecordData['record']['version'];
currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference'];
currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = {
'data': currentRecordData['currentRecordVersion']['data'],
'version': currentRecordData['currentRecordVersion']['version'],
'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'],
'previousVersionKey': currentRecordData['currentRecordVersion']['previousVersionKey']
}
}
this.userData()['lock'] = Clipperz.PM.Crypto.randomKey();
result['lock'] = this.userData()['lock'];
result['result'] = 'done';
} else {
throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly;
}
*/ //=====================================================================
} else if (someParameters.message == 'saveChanges') {
if (this.isReadOnly() == false) {
var i, c;
if (aConnection['userData']['lock'] != someParameters['parameters']['user']['lock']) {
throw "the lock attribute is not processed correctly"
}
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<c; i++) {
var currentRecord;
var currentRecordData;
currentRecordData = someParameters['parameters']['records']['updated'][i];
currentRecord = aConnection['userData']['records'][currentRecordData['record']['reference']];
if (
(typeof(aConnection['userData']['records'][currentRecordData['record']['reference']]) == 'undefined')
&&
(typeof(currentRecordData['currentRecordVersion']) == 'undefined')
) {
throw "Record added without a recordVersion";
}
if (currentRecord == null) {
currentRecord = {};
currentRecord['versions'] = {};
currentRecord['creationDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date());
currentRecord['accessDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date());
aConnection['userData']['records'][currentRecordData['record']['reference']] = currentRecord;
}
currentRecord['data'] = currentRecordData['record']['data'];
currentRecord['version'] = currentRecordData['record']['version'];
currentRecord['updateDate'] = Clipperz.PM.Date.formatDateWithUTCFormat(new Date());
if (typeof(currentRecordData['currentRecordVersion']) != 'undefined') {
currentRecord['currentVersion'] = currentRecordData['currentRecordVersion']['reference'];
currentRecord['versions'][currentRecordData['currentRecordVersion']['reference']] = {
'data': currentRecordData['currentRecordVersion']['data'],
'version': currentRecordData['currentRecordVersion']['version'],
'previousVersion': currentRecordData['currentRecordVersion']['previousVersion'],
'previousVersionKey': currentRecordData['currentRecordVersion']['previousVersionKey'],
'creationDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()),
'updateDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date()),
'accessDate': Clipperz.PM.Date.formatDateWithUTCFormat(new Date())
}
}
}
c = someParameters['parameters']['records']['deleted'].length;
for (i=0; i<c; i++) {
var currentRecordReference;
currentRecordReference = someParameters['parameters']['records']['deleted'][i];
delete aConnection['userData']['records'][currentRecordReference];
}
aConnection['userData']['lock'] = Clipperz.PM.Crypto.randomKey();
result['lock'] = aConnection['userData']['lock'];
result['result'] = 'done';
} else {
throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly;
}
//=====================================================================
//
// U N H A N D L E D M e t h o d
//
//=====================================================================
} else {
Clipperz.logError("Clipperz.PM.Proxy.Test.message - unhandled message: " + someParameters.message);
}
result = {
result: result,
toll: this.getTollForRequestType('MESSAGE')
}
// return MochiKit.Async.succeed(result);
return result;
},
//-------------------------------------------------------------------------
'_logout': function(someParameters) {
// return MochiKit.Async.succeed({result: 'done'});
return {result: 'done'};
},
//=========================================================================
//#########################################################################
'isTestData': function(aConnection) {
return (typeof(aConnection['userData']['__masterkey_test_value__']) != 'undefined');
},
'userDetails': function(aConnection) {
var result;
if (this.isTestData(aConnection)) {
var serializedHeader;
var version;
//Clipperz.logDebug("### test data");
version = aConnection['userData']['userDetailsVersion'];
serializedHeader = Clipperz.Base.serializeJSON(aConnection['userData']['userDetails']);
result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedHeader);
} else {
//Clipperz.logDebug("### NOT test data");
result = aConnection['userData']['userDetails'];
}
return result;
},
'statistics': function(aConnection) {
var result;
if (aConnection['userData']['statistics'] != null) {
if (this.isTestData(aConnection)) {
var serializedStatistics;
var version;
version = aConnection['userData']['userDetailsVersion'];
serializedStatistics = Clipperz.Base.serializeJSON(aConnection['userData']['statistics']);
result = Clipperz.PM.Crypto.encryptingFunctions.versions[version].encrypt(aConnection['userData']['__masterkey_test_value__'], serializedStatistics);
} else {
result = aConnection['userData']['statistics'];
}
} else {
result = null;
}
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js
index d459726..1a860c5 100644
--- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js
+++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js
@@ -18,139 +18,144 @@ refer to http://www.clipperz.com.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
if (typeof(Clipperz.PM.Proxy) == 'undefined') { Clipperz.PM.Proxy = {}; }
//=============================================================================
Clipperz.PM.Proxy.Test = function(args) {
Clipperz.PM.Proxy.Test.superclass.constructor.call(this, args);
args = args || {};
this._expectedRequests = (args.shouldCheckExpectedRequests === true) ? [] : null;
this._isExpectingRequests = true;
this._unexpectedRequests = [];
this.dataStore().resetData();
return this;
}
Clipperz.Base.extend(Clipperz.PM.Proxy.Test, Clipperz.PM.Proxy.Offline, {
'toString': function() {
return "Clipperz.PM.Proxy.Test";
},
//=========================================================================
'expectedRequests': function () {
return this._expectedRequests;
},
//-------------------------------------------------------------------------
'shouldCheckExpectedRequests': function () {
return (this._expectedRequests != null);
},
'setShouldCheckExpectedRequests': function(aValue) {
if (aValue) {
this._expectedRequests = aValue;
} else {
this._expectedRequests = null;
}
},
//-------------------------------------------------------------------------
'shouldNotReceiveAnyFurtherRequest': function () {
this._isExpectingRequests = false;
},
'mayReceiveMoreRequests': function () {
this._isExpectingRequests = true;
this.resetUnexpectedRequests();
},
'isExpectingRequests': function () {
return this._isExpectingRequests;
},
//-------------------------------------------------------------------------
'unexpectedRequests': function () {
return this._unexpectedRequests;
},
'resetUnexpectedRequests': function () {
this._unexpectedRequests = [];
},
//-------------------------------------------------------------------------
'testExpectedRequestParameters': function (aPath, anActualRequest, anExpectedRequest) {
var aKey;
for (aKey in anExpectedRequest) {
if (typeof(anActualRequest[aKey]) == 'undefined') {
throw "the expected paramter [" + aKey + "] is missing from the actual request";
}
if (typeof(anExpectedRequest[aKey]) == 'object') {
this.testExpectedRequestParameters(aPath + "." + aKey, anActualRequest[aKey], anExpectedRequest[aKey])
} else {
if (! anExpectedRequest[aKey](anActualRequest[aKey])) {
throw "wrong value for paramter [" + aKey + "]; got '" + anActualRequest[aKey] + "'";
}
}
}
},
//-------------------------------------------------------------------------
'checkRequest': function(aFunctionName, someParameters) {
if (this.shouldCheckExpectedRequests()) {
var expectedRequest;
expectedRequest = this.expectedRequests().pop();
if (expectedRequest == null) {
throw "Proxy.Test.sentMessage: no expected result specified. Got request '" + aFunctionName + "': " + someParameters;
}
try {
if (aFunctionName != expectedRequest.functionName) {
throw "wrong function name. Got '" + aFunctionName + "', expected '" + expectedRequest.request.functionName + "'";
}
this.testExpectedRequestParameters("parameters", someParameters, expectedRequest.parameters);
} catch(exception) {
throw "Proxy.Test.sentMessage[" + expectedRequest.name + "]: " + exception;
}
}
},
//=========================================================================
'sendMessage': function(aFunctionName, someParameters) {
var result;
if (this.isExpectingRequests() == false) {
// throw Clipperz.PM.Connection.exception.UnexpectedRequest;
Clipperz.log("UNEXPECTED REQUEST " + aFunctionName /* + ": " + Clipperz.Base.serializeJSON(someParameters) */);
this.unexpectedRequests().push({'functionName':aFunctionName, 'someParameters': someParameters});
};
+//if (aFunctionName == 'knock') {
+// console.log(">>> 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);
return result;
},
//=========================================================================
__syntaxFix__: "syntax fix"
});
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
@@ -1,174 +1,175 @@
{
"copyright.values": {
"mochikit.repository": "https://github.com/mochi/mochikit.git",
"mochikit.version": "fe8d17bb9ac0a4e5ad4a8d5c2c94a6fac1c92d75"
},
"html.template": "index_template.html",
"js": [
"MochiKit/Base.js",
"MochiKit/Iter.js",
"-- MochiKit/Logging.js",
"-- MochiKit/DateTime.js",
"MochiKit/Format.js",
"MochiKit/Async.js",
"MochiKit/DOM.js",
"MochiKit/Style.js",
"-- MochiKit/LoggingPane.js",
"MochiKit/Color.js",
"MochiKit/Signal.js",
"MochiKit/Position.js",
"MochiKit/Selector.js",
"MochiKit/Visual.js",
"JSON/json2.js",
"Clipperz/YUI/Utils.js",
"Clipperz/YUI/DomHelper.js",
"Clipperz/ByteArray.js",
"Clipperz/Base.js",
"Clipperz/Async.js",
"Clipperz/CSVProcessor.js",
"Clipperz/KeePassExportProcessor.js",
"Clipperz/Date.js",
"Clipperz/DOM.js",
"Clipperz/Logging.js",
"Clipperz/Signal.js",
"Clipperz/Style.js",
"Clipperz/Visual.js",
"Clipperz/Set.js",
"-- Clipperz/Profile.js",
"Clipperz/KeyValueObjectStore.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",
"Clipperz/Crypto/SRP.js",
"Clipperz/Crypto/RSA.js",
"Clipperz/PM/Strings/Strings_defaults.js",
"Clipperz/PM/Strings/Strings_en-US.js",
"-- # Clipperz/PM/Strings/Strings_en-GB.js",
"-- # Clipperz/PM/Strings/Strings_en-CA.js",
"-- Clipperz/PM/Strings/Strings_it-IT.js",
"-- Clipperz/PM/Strings/Strings_pt-BR.js",
"-- # Clipperz/PM/Strings/Strings_pt-PT.js",
"-- Clipperz/PM/Strings/Strings_ja-JP.js",
"-- Clipperz/PM/Strings/Strings_zh-CN.js",
"-- Clipperz/PM/Strings/Strings_es-ES.js",
"-- Clipperz/PM/Strings/Strings_fr-FR.js",
"-- # Clipperz/PM/Strings/Strings_de-DE.js",
"-- # Clipperz/PM/Strings/Strings_el-GR.js",
"-- # Clipperz/PM/Strings/Strings_ru-RU.js",
"-- # Clipperz/PM/Strings/Strings_he-IL.js",
"Clipperz/PM/Strings.js",
"-- Clipperz/PM/Strings/MessagePanelConfigurations.js",
"Clipperz/PM/Date.js",
"Clipperz/PM/Toll.js",
"Clipperz/PM/Proxy.js",
"Clipperz/PM/Proxy/Proxy.JSON.js",
"Clipperz/PM/Proxy/Proxy.Offline.js",
"Clipperz/PM/Proxy/Proxy.Offline.DataStore.js",
"Clipperz/PM/Connection.js",
"Clipperz/PM/Crypto.js",
"Clipperz/PM/BookmarkletProcessor.js",
"Clipperz/PM/DataModel/EncryptedRemoteObject.js",
"Clipperz/PM/DataModel/User.js",
"Clipperz/PM/DataModel/User.Header.Legacy.js",
"Clipperz/PM/DataModel/User.Header.RecordIndex.js",
"Clipperz/PM/DataModel/User.Header.Preferences.js",
"Clipperz/PM/DataModel/User.Header.OneTimePasswords.js",
"Clipperz/PM/DataModel/Record.js",
"Clipperz/PM/DataModel/Record.Version.js",
"Clipperz/PM/DataModel/Record.Version.Field.js",
"Clipperz/PM/DataModel/DirectLogin.js",
"Clipperz/PM/DataModel/DirectLoginInput.js",
"Clipperz/PM/DataModel/DirectLoginBinding.js",
"Clipperz/PM/DataModel/DirectLoginFormValue.js",
"Clipperz/PM/DataModel/OneTimePassword.js",
"Clipperz/PM/UI/Canvas/Marks/exclamationMark.js",
"Clipperz/PM/UI/Canvas/Marks/questionMark.js",
"Clipperz/PM/UI/Canvas/Marks/info.js",
"Clipperz/PM/UI/Canvas/Features/store.js",
"Clipperz/PM/UI/Canvas/Features/protect.js",
"Clipperz/PM/UI/Canvas/Features/directLogin.js",
"Clipperz/PM/UI/Canvas/Features/share.js",
"Clipperz/PM/UI/Canvas/Star/normal.js",
"Clipperz/PM/UI/Canvas/CoverActions/look.js",
"Clipperz/PM/UI/Canvas/CoverActions/download.js",
"Clipperz/PM/UI/Canvas/Tips/open.js",
"Clipperz/PM/UI/Canvas/Tips/close.js",
"Clipperz/PM/UI/Canvas/RegisterButton/normal.js",
"Clipperz/PM/UI/Canvas/Logo/normal.js",
"Clipperz/PM/UI/Canvas/GraphicFunctions.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/FaviconComponent.js",
"Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.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/TabPanelController.js",
"Clipperz/PM/UI/Common/Controllers/WizardController.js",
"Clipperz/PM/UI/Web/Components/Page.js",
"Clipperz/PM/UI/Web/Components/PageHeader.js",
"Clipperz/PM/UI/Web/Components/PageFooter.js",
"Clipperz/PM/UI/Web/Components/LoginPage.js",
"Clipperz/PM/UI/Web/Components/LoginForm.js",
"Clipperz/PM/UI/Web/Components/LoginProgress.js",
"Clipperz/PM/UI/Web/Components/AppPage.js",
"Clipperz/PM/UI/Web/Components/UserInfoBox.js",
"Clipperz/PM/UI/Web/Components/TabSidePanel.js",
"Clipperz/PM/UI/Web/Components/GridComponent.js",
"Clipperz/PM/UI/Web/Components/ColumnManager.js",
"Clipperz/PM/UI/Web/Components/TextColumnManager.js",
"Clipperz/PM/UI/Web/Components/FaviconColumnManager.js",
"Clipperz/PM/UI/Web/Components/ImageColumnManager.js",
"Clipperz/PM/UI/Web/Components/DateColumnManager.js",
"Clipperz/PM/UI/Web/Components/LinkColumnManager.js",
"Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js",
"Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js",
"Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js",
"Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js",
"Clipperz/PM/UI/Web/Components/AccountPanel.js",
"Clipperz/PM/UI/Web/Components/DataPanel.js",
"Clipperz/PM/UI/Web/Components/ToolsPanel.js",
"Clipperz/PM/UI/Web/Components/RulerComponent.js",
"Clipperz/PM/UI/Web/Components/CardDialogComponent.js",
"Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js",
"Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js",
"Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js",
"Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js",
"Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js",
"Clipperz/PM/UI/Web/Components/BookmarkletComponent.js",
"Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js",
"Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js",
"Clipperz/PM/UI/Web/Components/PasswordTooltip.js",
"Clipperz/PM/UI/Web/Controllers/MainController.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
@@ -1,156 +1,165 @@
{
"copyright.values": {
"mochikit.repository": "https://github.com/mochi/mochikit.git",
"mochikit.version": "fe8d17bb9ac0a4e5ad4a8d5c2c94a6fac1c92d75"
},
"html.template": "mobile_template.html",
"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",
"Clipperz/ByteArray.js",
"Clipperz/Base.js",
"Clipperz/Async.js",
"-- Clipperz/CSVProcessor.js",
"-- Clipperz/KeePassExportProcessor.js",
"Clipperz/Date.js",
"Clipperz/DOM.js",
"Clipperz/Logging.js",
"Clipperz/Signal.js",
"-- Clipperz/Style.js",
"-- Clipperz/Visual.js",
"Clipperz/Set.js",
"Clipperz/KeyValueObjectStore.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",
"Clipperz/Crypto/SRP.js",
"Clipperz/Crypto/RSA.js",
"Clipperz/PM/Strings/Strings_defaults.js",
"Clipperz/PM/Strings/Strings_en-US.js",
"-- # Clipperz/PM/Strings/Strings_en-GB.js",
"-- # Clipperz/PM/Strings/Strings_en-CA.js",
"-- Clipperz/PM/Strings/Strings_it-IT.js",
"-- Clipperz/PM/Strings/Strings_pt-BR.js",
"-- # Clipperz/PM/Strings/Strings_pt-PT.js",
"-- Clipperz/PM/Strings/Strings_ja-JP.js",
"-- Clipperz/PM/Strings/Strings_zh-CN.js",
"-- Clipperz/PM/Strings/Strings_es-ES.js",
"-- Clipperz/PM/Strings/Strings_fr-FR.js",
"-- # Clipperz/PM/Strings/Strings_de-DE.js",
"-- # Clipperz/PM/Strings/Strings_el-GR.js",
"-- # Clipperz/PM/Strings/Strings_ru-RU.js",
"-- # Clipperz/PM/Strings/Strings_he-IL.js",
"Clipperz/PM/Strings.js",
"-- Clipperz/PM/Strings/MessagePanelConfigurations.js",
"Clipperz/PM/Date.js",
"Clipperz/PM/Toll.js",
"Clipperz/PM/Proxy.js",
"Clipperz/PM/Proxy/Proxy.JSON.js",
"-- Clipperz/PM/Proxy/Proxy.OfflineCache.js",
"Clipperz/PM/Proxy/Proxy.Offline.js",
"Clipperz/PM/Proxy/Proxy.Offline.DataStore.js",
"Clipperz/PM/Connection.js",
"Clipperz/PM/Crypto.js",
"Clipperz/PM/PIN.js",
"Clipperz/PM/DataModel/EncryptedRemoteObject.js",
"Clipperz/PM/DataModel/User.js",
"Clipperz/PM/DataModel/User.Header.Legacy.js",
"Clipperz/PM/DataModel/User.Header.RecordIndex.js",
"Clipperz/PM/DataModel/User.Header.Preferences.js",
"Clipperz/PM/DataModel/User.Header.OneTimePasswords.js",
"Clipperz/PM/DataModel/Record.js",
"Clipperz/PM/DataModel/Record.Version.js",
"Clipperz/PM/DataModel/Record.Version.Field.js",
"Clipperz/PM/DataModel/DirectLogin.js",
"Clipperz/PM/DataModel/DirectLoginInput.js",
"Clipperz/PM/DataModel/DirectLoginBinding.js",
"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",
"-- Zepto/data.js",
"-- Zepto/detect.js",
"-- Zepto/event.js",
"-- Zepto/form.js",
"-- Zepto/fx.js",
"-- Zepto/fx_methods.js",
"-- Zepto/gesture.js",
"-- Zepto/polyfill.js",
"-- Zepto/selector.js",
"-- Zepto/stack.js",
"-- Zepto/touch.js",
"-- JQTouch/jqtouch.js",
"-- Bootstrap/bootstrap-affix.js",
"-- Bootstrap/bootstrap-alert.js",
"-- Bootstrap/bootstrap-button.js",
"-- Bootstrap/bootstrap-carousel.js",
"-- Bootstrap/bootstrap-collapse.js",
"-- Bootstrap/bootstrap-dropdown.js",
"-- Bootstrap/bootstrap-modal.js",
"-- Bootstrap/bootstrap-popover.js",
"-- Bootstrap/bootstrap-scrollspy.js",
"-- Bootstrap/bootstrap-tab.js",
"-- Bootstrap/bootstrap-tooltip.js",
"-- 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",
"main.mobile.js"
],
"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
--- a/dev/null
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html
@@ -0,0 +1,57 @@
+<!--
+
+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/.
+
+-->
+
+<html>
+<head>
+ <title>Clipperz.Crypto.AES_2 - tests</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+
+ <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
+
+ <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
+
+ <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES_2.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
+
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
+
+</head>
+<body>
+<pre id="test">
+<script type="text/javascript" src="AES_2.test.js"></script>
+</pre>
+</body>
+</html>
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
--- a/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
@@ -1,53 +1,54 @@
<!--
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/.
-->
<html>
<head>
<title>Clipperz.Crypto.* - tests</title>
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="../../../SimpleTest/TestRunner.js"></script>
</head>
<body>
<script>
TestRunner.runTests(
'AES.html',
+// 'AES_2.html',
'AES.performance.html',
'Base.html',
'BigInt.html',
// 'ECC.B283.deferred.html',
// 'ECC.BinaryField.FiniteField.html',
// 'ECC.BinaryField.FiniteField.B283.html',
// 'ECC.BinaryField.Value.html',
//# 'ECC.K283.deferred.html',
'PRNG.html',
// 'RSA.html',
'SHA.html',
'SRP.html',
'Usage.html'
);
</script>
</body>
</html> \ No newline at end of file
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html b/frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html
new file mode 100644
index 0000000..1ed863a
--- a/dev/null
+++ b/frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html
@@ -0,0 +1,60 @@
+<!--
+
+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/.
+
+-->
+
+<html>
+<head>
+ <title>Clipperz.PM.Crypto [0.4] - tests</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+
+ <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
+
+ <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
+
+ <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES_2.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
+
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
+
+</head>
+<body>
+<pre id="test">
+<script type="text/javascript" src="Crypto_v0_4.test.js"></script>
+</pre>
+</body>
+</html>
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
--- a/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
@@ -1,98 +1,99 @@
<!--
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/.
-->
<html>
<head>
<title>Clipperz.PM.DataModel.DirectLogin - test</title>
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES_2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
<script>
Clipperz_IEisBroken = false;
</script>
<!--[if IE]><script>
Clipperz_IEisBroken = true;
Clipperz_normalizedNewLine = '\x0d\x0a';
</script><![endif]-->
</head>
<body>
<pre id="test">
<script>
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
</script>
<script type="text/javascript" src="User.data.js"></script>
<script type="text/javascript" src="User.data.old.js"></script>
<script type="text/javascript" src="DirectLogin.test.js"></script>
</pre>
</body>
</html>
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
@@ -1,61 +1,62 @@
<!--
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/.
-->
<html>
<head>
<title>Clipperz.PM.DataModel.EncryptedRemoteObject - test</title>
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES_2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
</head>
<body>
<pre id="test">
<script type="text/javascript" src="EncryptedRemoteObject.test.js"></script>
</pre>
</body>
</html>
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
@@ -1,93 +1,94 @@
<!--
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/.
-->
<html>
<head>
<title>Clipperz.PM.DataModel.Record - test</title>
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES_2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginFormValue.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
</head>
<body>
<pre id="test">
<script>
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
</script>
<script type="text/javascript" src="DirectLoginConfigurations.data.js"></script>
<script type="text/javascript" src="User.data.js"></script>
<script type="text/javascript" src="Record.test.js"></script>
</pre>
</body>
</html>
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
@@ -52,266 +52,274 @@ var tests = {
// 'encryptedDataKeypath': 'data',
// 'encryptedVersionKeypath': 'version',
'retrieveIndexDataFunction': function (aRecordReference) {
SimpleTest.is(aRecordReference, '<<< record reference >>>', "Record correctly passes its record reference when asking for index data");
return MochiKit.Async.succeed({
key: '<< key >>',
label: '<< label >>',
notes: '<< notes >>'
});
},
'updateIndexDataFunction': MochiKit.Base.noop
});
deferredResult = new Clipperz.Async.Deferred("recordUseOf_retrieveIndexDataFunction_and_getEncryptedDataFunction_test", someTestArgs);
deferredResult.addMethod(record, 'label');
deferredResult.addTest('<< label >>', "Record returns the right value for label");
deferredResult.addMethod(record, 'notes');
deferredResult.addTest('<< notes >>', "Record returns the right value for notes - even the legacy one, stored on the header");
deferredResult.addMethod(record, 'getRemoteData');
deferredResult.addCallback(Clipperz.Async.Test.isDeeply({ 'data': "#### fake encrypted data ####", 'version': "0.x", 'currentVersion': { 'reference': "<<< fake record version reference >>>", 'data': "#### fake encrypted data ####", 'version': "0.x" } }, "Record returns the expected encrypted data"));
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'createRecordWithoutAllRequiredParameters_test': function (someTestArgs) {
var record;
try {
//console.log("#### new Clipperz.PM.DataModel.Record [6]");
record = new Clipperz.PM.DataModel.Record({reference:'--'});
SimpleTest.ok(false, "creating a record without all parameters should raise an exception");
} catch(exception) {
// SimpleTest.is(exception.name, "Clipperz.Base.exception.MandatoryParameter", "creating a record without all parameters raises an exception");
SimpleTest.ok(/Clipperz\.Base\.exception\.MandatoryParameter.*/.test(exception.name), "creating a record without all parameters raises an exception");
}
},
//-------------------------------------------------------------------------
'recordFromOldData_version_0.1_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
var recordID;
//console.log("#### new Clipperz.PM.DataModel.Record [7]");
/*
record = new Clipperz.PM.DataModel.Record({
'reference': '05aad20ee399b11ddc923e601fcd1d096233634f2ad4c55db4f6435e5f9cc17a',
'retrieveKeyFunction': MochiKit.Base.partial(MochiKit.Async.succeed, 'e038652297f981d5ca917d88fa2c4c3251a12c0fa41bf7313a4d24a9738fe6c6'),
'retrieveRemoteDataFunction': MochiKit.Base.partial(MochiKit.Async.succeed, {
'data': '4ec19a7093534e7dcf7c796b889283c6cec224b1895720ba3ff43ce091dc72c61fd5ea56def418ba3f15239f73228c6c8558585311f5e6673efe57482a1f9c9fe71e921576989eace671ec543685e3ad8f976bbfa4c2dbc629fab936c227d4fd4da3a1561ea79e553bae7b758ff91762572c1448a2d18bec797e12721238ef5ba18ddf1fba8ae773a8debe1040b3b158220aec6be9c7190687139f589a30d9c8887792fd7040e3c7cf3f9999fb9dde1f9f334d17c996996d538a7e374ac93135acafdaf5fce738a1702182897b63d2cb8e308b94156473cba63dcc557d17dcbdb55fcff63d9ba5edf68c42855052e34207d6fabe94fe024c3db616b45f494da42c62224d3897e320080072cc442d4212e7b1e8d5b3d9e3c25d48f4e7c37112ef4c6b2c0c8aff0bd3ce05694370e4378701463dde26c7c0322f8a9eb5a724106039b16b35050a9a9b5717b2eec803efa962b88b9655742f5e7b180ea567449671fb5a2ce563d8b47bc25705821938192eae420391c208182a788dd06fb6448b9858a4104a14efd7717671c65cd08fd979a4da7c01712bc5d4e949a10ef1ea65caf1f07cee34b063bab01bfb7a59047fef30c3059ea652f1c92b9e72aac515ac8851756703772e1fa05384ee7f0d5c7a3c',
'version': '0.1',
'currentVersion': {
'reference': '05aad20ee399b11ddc923e601fcd1d096233634f2ad4c55db4f6435e5f9cc17a',
'data': '4ec19a7093534e7dcf7c796b889283c6cec224b1895720ba3ff43ce091dc72c61fd5ea56def418ba3f15239f73228c6c8558585311f5e6673efe57482a1f9c9fe71e921576989eace671ec543685e3ad8f976bbfa4c2dbc629fab936c227d4fd4da3a1561ea79e553bae7b758ff91762572c1448a2d18bec797e12721238ef5ba18ddf1fba8ae773a8debe1040b3b158220aec6be9c7190687139f589a30d9c8887792fd7040e3c7cf3f9999fb9dde1f9f334d17c996996d538a7e374ac93135acafdaf5fce738a1702182897b63d2cb8e308b94156473cba63dcc557d17dcbdb55fcff63d9ba5edf68c42855052e34207d6fabe94fe024c3db616b45f494da42c62224d3897e320080072cc442d4212e7b1e8d5b3d9e3c25d48f4e7c37112ef4c6b2c0c8aff0bd3ce05694370e4378701463dde26c7c0322f8a9eb5a724106039b16b35050a9a9b5717b2eec803efa962b88b9655742f5e7b180ea567449671fb5a2ce563d8b47bc25705821938192eae420391c208182a788dd06fb6448b9858a4104a14efd7717671c65cd08fd979a4da7c01712bc5d4e949a10ef1ea65caf1f07cee34b063bab01bfb7a59047fef30c3059ea652f1c92b9e72aac515ac8851756703772e1fa05384ee7f0d5c7a3c',
'version': '0.1'
}
}),
'retrieveIndexDataFunction': MochiKit.Base.partial(MochiKit.Async.succeed, {
// 'key': 'e038652297f981d5ca917d88fa2c4c3251a12c0fa41bf7313a4d24a9738fe6c6',
'label': '<< label >>',
'notes': '<< notes >>'
}),
'updateIndexDataFunction': MochiKit.Base.noop,
'updateDate': 'Mon Oct 02 10:01:52 CEST 2006'
});
*/
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:false, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
recordID = "05aad20ee399b11ddc923e601fcd1d096233634f2ad4c55db4f6435e5f9cc17a";
deferredResult = new Clipperz.Async.Deferred("recordFromOldData_version_0.1_test", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_someExtraOldData']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('hasAnyCleanTextData');
deferredResult.addTest(false, "When first loaded, the record has no clean text data");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('label');
deferredResult.addTest("Card encoded with an old algorithm", "Record returns the right value for label");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('notes');
deferredResult.addTest("", "Record returns the right value for notes - even the legacy one, stored on the header");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('hasAnyCleanTextData');
deferredResult.addTest(true, "After reading some values, the record has some clean text data");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('fields');
deferredResult.addCallback(function (someFields) {
SimpleTest.is(MochiKit.Base.values(someFields).length, 6, "the card has 6 fields");
});
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'removeDirectLogin': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
var recordID = 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'; // YAHOO (4)
var directLoginID = 'dba0db679802f0e6aa6d0b7a6aaf42350aabc5f057409edd99a268a92ebb6496';
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:false, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
user2 = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
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));
deferredResult.addMethodcaller('remove');
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('hasPendingChanges');
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");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.keys);
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(3, "after saving changes, the record should have only 3 direct logins");
deferredResult.addMethod(user2, 'login');
deferredResult.addMethod(user2, 'getRecord', recordID);
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.keys);
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(3, "also reloading all the data with a new user, the direct logins should always be 3");
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'removeDirectLoginAndRevertChanges': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
var recordID = 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d';
var directLoginID = 'dba0db679802f0e6aa6d0b7a6aaf42350aabc5f057409edd99a268a92ebb6496';
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:false, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
deferredResult = new Clipperz.Async.Deferred("Record.test.removeDirectLoginAndRevertChanges", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getDirectLogins');
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(22, "the user has 22 initially");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.keys);
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(4, "the selected record has 4 direct logins");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.itemgetter(directLoginID));
deferredResult.addMethodcaller('remove');
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('hasPendingChanges');
deferredResult.addTest(true, "removing a direct login to a record should result in pending changes on the record");
deferredResult.addMethod(user, 'revertChanges');
deferredResult.addMethod(user, 'hasPendingChanges');
deferredResult.addTest(false, "after reverting the changes, the user should not have pending changes");
deferredResult.addMethod(user, 'getDirectLogins');
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(22, "after reverting the changes, the user should still have 22 direct logins");
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.keys);
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(4, "after reverting the changes, the record should still have 4 direct logins");
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'addDirectLoginAndRevertChanges': function (someTestArgs) {
var deferredResult;
var proxy;
var user, user2;
var recordID = 'd5f700b9c3367c39551ea49e00a9ab20dae09dd79d46047b983fc7c4bfaa050d'; // YAHOO (4)
var directLoginReference;
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:false, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
user2 = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
deferredResult = new Clipperz.Async.Deferred("Record.test.addDirectLoginAndRevertChanges", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getRecord', recordID);
deferredResult.setValue('record');
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.keys);
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(4, "the record, when initially loaded, has 4 direct logins");
deferredResult.getValue('record');
deferredResult.addMethodcaller('createNewDirectLogin');
deferredResult.setValue('directLogin');
deferredResult.getValue('directLogin');
deferredResult.addMethodcaller('setLabel', "New direct login");
deferredResult.getValue('directLogin');
deferredResult.addMethodcaller('setBookmarkletConfiguration', '{"page": {"title": "Parallels Account"}, "form": {"attributes": {"action": "https://www.parallels.com/account/", "method": "post"}, "inputs": [{"type": "text", "name": "Email", "value": ""}, {"type": "password", "name": "Password", "value": ""}]}, "version": "0.2.3"}');
deferredResult.addMethod(user, 'revertChanges');
//deferredResult.addCallback(function () { console.log("###################################"); });
deferredResult.addMethod(user, 'hasPendingChanges');
deferredResult.addTest(false, "after reverting the changes, the user should NOT have pending changes");
deferredResult.getValue('record');
deferredResult.addMethodcaller('hasPendingChanges');
deferredResult.addTest(false, "after reverting the changes, the record should NOT have pending changes");
deferredResult.addMethod(user2, 'login');
deferredResult.addMethod(user2, 'getRecord', recordID);
deferredResult.setValue('record_2');
deferredResult.addMethodcaller('directLogins');
deferredResult.addCallback(MochiKit.Base.keys);
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(4, "the record, when reloaded from scratch, has still 4 direct logins");
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
@@ -1,101 +1,102 @@
<!--
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/.
-->
<html>
<head>
<title>Clipperz.PM.DataModel.User - test</title>
<script type="text/javascript" src="../../../../../js/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="../../../../SimpleTest/test.css">
<script type='text/javascript' src='../../../../../js/JSON/json2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/YUI/Utils.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/ByteArray.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Logging.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Async.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Signal.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/Base.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/BigInt.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES.js'></script>
+ <script type='text/javascript' src='../../../../../js/Clipperz/Crypto/AES_2.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SHA.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/PRNG.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/Crypto/SRP.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Toll.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Connection.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Crypto.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/Date.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginInput.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginBinding.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/DirectLoginFormValue.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.Preferences.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/User.Header.OneTimePasswords.js'></script>
<script type='text/javascript' src='../../../../../js/Clipperz/PM/DataModel/OneTimePassword.js'></script>
<script type="text/javascript" src="../../../../SimpleTest/SimpleTest.Async.js"></script>
<script>
Clipperz_IEisBroken = false;
</script>
<!--[if IE]><script>
Clipperz_IEisBroken = true;
Clipperz_normalizedNewLine = '\x0d\x0a';
</script><![endif]-->
</head>
<body>
<pre id="test">
<script>
Clipperz.PM.Strings.Languages.setSelectedLanguage('en-us');
</script>
<script type="text/javascript" src="User.data.js"></script>
<script type="text/javascript" src="User.data.old.js"></script>
<script type="text/javascript" src="User.test.js"></script>
</pre>
</body>
</html>
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
@@ -1797,257 +1797,257 @@ var tests = {
'logout_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
deferredResult = new Clipperz.Async.Deferred("logout_test", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_with_preferences_and_OTPs_data']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getRecords');
deferredResult.addCallback(function (someRecords) {
SimpleTest.is(MochiKit.Base.keys(someRecords).length, 18, "The user has 18 records");
});
deferredResult.addMethod(user, 'logout');
deferredResult.shouldSucceed("Logging out should not trigger an exception");
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'lock_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
var returnPassword = function () { return MochiKit.Async.succeed('clipperz'); };
var failPassword = function () { throw "Unexpected access to the password"; };
var currentPasswordFunction = returnPassword;
var passwordFunction = function () { return currentPasswordFunction(); };
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:passwordFunction});
deferredResult = new Clipperz.Async.Deferred("lock_test", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_with_preferences_and_OTPs_data']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getRecords');
deferredResult.addCallback(function (someRecords) {
SimpleTest.is(MochiKit.Base.keys(someRecords).length, 18, "The user has 18 records");
});
deferredResult.addMethod(user, 'getDirectLogins');
deferredResult.addCallback(function (someDirectLogins) {
SimpleTest.is(MochiKit.Base.keys(someDirectLogins).length, 22, "The user has 22 direct logins");
});
deferredResult.addMethod(proxy, 'shouldNotReceiveAnyFurtherRequest');
deferredResult.addCallback(function () { currentPasswordFunction = failPassword; });
deferredResult.addMethod(user, 'lock');
deferredResult.shouldSucceed("Locking out should not trigger an exception");
deferredResult.addMethod(proxy, 'unexpectedRequests');
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(0, "The proxy should have not received any extra request");
//deferredResult.addCallback(function (aValue) { console.log("PROXY.unexpectedRequests", Clipperz.Base.serializeJSON(proxy.unexpectedRequests())); return aValue; });
deferredResult.addMethod(proxy, 'mayReceiveMoreRequests');
deferredResult.addCallback(function () { currentPasswordFunction = returnPassword; });
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'registerNewUser_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user, user2;
var username;
var passphrase;
username = "new";
passphrase = "user";
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
// user2 = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return MochiKit.Async.succeed(passphrase);}});
user2 = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}});
deferredResult = new Clipperz.Async.Deferred("registerNewUser_test", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_with_preferences_and_OTPs_data']);
deferredResult.addCallback(Clipperz.PM.DataModel.User.registerNewAccount, username, function () { return MochiKit.Async.succeed(passphrase);});
deferredResult.setValue('user');
deferredResult.addMethodcaller('getRecords');
deferredResult.addCallback(function (someRecords) {
SimpleTest.is(MochiKit.Base.keys(someRecords).length, 0, "The newly created user has no records");
});
deferredResult.getValue('user');
deferredResult.addMethodcaller('logout');
deferredResult.addMethod(user2, 'login');
deferredResult.addMethod(user2, 'getDirectLogins');
deferredResult.addCallback(function (someDirectLogins) {
SimpleTest.is(MochiKit.Base.keys(someDirectLogins).length, 0, "The user has no direct logins");
});
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'registerNewUserAndAddARecord_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user, user2;
var username;
var passphrase;
username = "new";
passphrase = "user";
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']);
deferredResult.addCallback(Clipperz.PM.DataModel.User.registerNewAccount, username, function () { return MochiKit.Async.succeed(passphrase);});
deferredResult.setValue('user');
deferredResult.addMethodcaller('getRecords');
deferredResult.addCallback(function (someRecords) {
SimpleTest.is(MochiKit.Base.keys(someRecords).length, 0, "The newly created user has no records");
});
deferredResult.getValue('user');
deferredResult.addMethodcaller('createNewRecord');
deferredResult.addCallback(function (aNewRecord) {
var innerDeferredResult;
innerDeferredResult = new Clipperz.Async.Deferred("addRecordAndSaveChangesMultipleTimes_test <internal [1]>", {trace:false});
innerDeferredResult.addMethod(aNewRecord, 'setLabel', "New record 1");
innerDeferredResult.addMethod(aNewRecord, 'addField', {'label':'record number', 'value':"1", 'isHidden':false});
innerDeferredResult.addMethod(aNewRecord, 'addField', {'label':'field count', 'value':"2", 'isHidden':false});
innerDeferredResult.callback();
return innerDeferredResult;
})
deferredResult.getValue('user');
deferredResult.addMethodcaller('saveChanges');
deferredResult.addCallback(SimpleTest.ok, true, "Saving worked (apparently) fine");
deferredResult.getValue('user');
deferredResult.addMethodcaller('logout');
deferredResult.addMethod(user2, 'login');
deferredResult.addMethod(user2, 'getRecords');
deferredResult.addCallback(function (someDirectLogins) {
SimpleTest.is(MochiKit.Base.keys(someDirectLogins).length, 1, "The user - even after a brand new login - has the newly created record");
});
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
'changePassphrase_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
var user2;
var newPassphrase;
newPassphrase = 'zreppilc';
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return 'clipperz';}});
user2 = new Clipperz.PM.DataModel.User({username:'joe', getPassphraseFunction:function () { return newPassphrase;}});
deferredResult = new Clipperz.Async.Deferred("changePassphrase_test", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getRecords');
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(20, "This account has oly a single card");
deferredResult.addMethod(user, 'changePassphrase', newPassphrase);
deferredResult.addMethod(user, 'logout');
deferredResult.addMethod(user2, 'login');
deferredResult.addMethod(user2, 'getRecords');
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
deferredResult.addTest(20, "This account has oly a single card");
deferredResult.callback();
return deferredResult;
},
//-------------------------------------------------------------------------
/*
'rearrangeRecordFieldOrderAndSave_test': function (someTestArgs) {
var deferredResult;
var proxy;
var user;
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
user = new Clipperz.PM.DataModel.User({username:'test', getPassphraseFunction:function () { return 'test';}});
deferredResult = new Clipperz.Async.Deferred("simpleSaveChanges_test", someTestArgs);
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['test_test_offline_copy_data']);
deferredResult.addMethod(user, 'login');
deferredResult.addMethod(user, 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
deferredResult.addMethodcaller('fields');
deferredResult.addCallback(function (someFields) {
var fields;
fields = MochiKit.Base.values(someFields);
SimpleTest.is(fields.length, 3, "The record has initially 3 fields");
SimpleTest.is(fields[0].reference(), '6a84c414866dd6d266186f0255a595e9330fb34973c085a81a6e4906876c721b', "the first field is the expected one");
SimpleTest.is(fields[1].reference(), 'fde88847cdbae6f7ee7e38aca1a242492888ff430a79c997bc6ba4afd0540ca2', "the second field is the expected one");
SimpleTest.is(fields[2].reference(), 'bd4e3bb9d3497f63c4c3a507d4b80f489fdb57deb9d1b342a5e1cff65936a410', "the third field is the expected one");
});
// "6a84c414866dd6d266186f0255a595e9330fb34973c085a81a6e4906876c721b": {
// "label":"Label 1","value":"Value 1","type":"TXT","hidden":false
// },
// "fde88847cdbae6f7ee7e38aca1a242492888ff430a79c997bc6ba4afd0540ca2": {
// "label":"Label 2","value":"Value 2","type":"PWD","hidden":true
// },
// "bd4e3bb9d3497f63c4c3a507d4b80f489fdb57deb9d1b342a5e1cff65936a410": {
// "label":"Label 3","value":"http://www.example.com","type":"URL","hidden":false
// }
deferredResult.addMethod(user, 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
deferredResult.addCallback(MochiKit.Base.methodcaller('sortFieldReference', [
'bd4e3bb9d3497f63c4c3a507d4b80f489fdb57deb9d1b342a5e1cff65936a410',
'6a84c414866dd6d266186f0255a595e9330fb34973c085a81a6e4906876c721b',
'bd4e3bb9d3497f63c4c3a507d4b80f489fdb57deb9d1b342a5e1cff65936a410'
]));
deferredResult.addMethod(user, 'getRecord', '8280842f41162b673335b63860637e8472e8bbff0efa2bc78b0dbc5e09712e13');
deferredResult.addMethodcaller('hasPendingChanges');
deferredResult.addTest(true, "adding a field should mark the record as having pending changes");
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
@@ -1,52 +1,53 @@
<!--
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/.
-->
<html>
<head>
<title>Clipperz.PM.* - tests</title>
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="../../../SimpleTest/TestRunner.js"></script>
</head>
<body>
<script>
TestRunner.runTests(
//
// This is still a complete mess.
//
// 'BookmarkletProcessor.html',
'Connection.html',
'Crypto.html',
+ 'Crypto_v0_4.html',
// 'Crypto_other_implementation_comparison.html',
'Crypto_performanceEvaluation.html',
// 'CryptoPerformance_ByteArrayArray.html',
// 'CryptoPerformance_ByteArrayHex.html',
// 'CryptoPerformance_ByteArrayString.html',
'Date.html',
'PIN.html',
'Proxy.html',
'Toll.html'
);
</script>
</body>
</html> \ No newline at end of file