mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2025-10-24 17:27:35 +02:00
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).
This commit is contained in:
57
frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html
Normal file
57
frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.html
Normal file
@@ -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>
|
||||
85
frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js
Normal file
85
frontend/gamma/tests/tests/Clipperz/Crypto/AES_2.test.js
Normal file
@@ -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});
|
||||
@@ -32,6 +32,7 @@ refer to http://www.clipperz.com.
|
||||
<script>
|
||||
TestRunner.runTests(
|
||||
'AES.html',
|
||||
// 'AES_2.html',
|
||||
'AES.performance.html',
|
||||
'Base.html',
|
||||
'BigInt.html',
|
||||
|
||||
60
frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html
Normal file
60
frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.html
Normal file
@@ -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>
|
||||
50
frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js
Normal file
50
frontend/gamma/tests/tests/Clipperz/PM/Crypto_v0_4.test.js
Normal file
@@ -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});
|
||||
@@ -43,6 +43,7 @@ refer to http://www.clipperz.com.
|
||||
<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>
|
||||
|
||||
@@ -42,6 +42,7 @@ refer to http://www.clipperz.com.
|
||||
<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>
|
||||
|
||||
@@ -43,6 +43,7 @@ refer to http://www.clipperz.com.
|
||||
<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>
|
||||
|
||||
@@ -177,6 +177,13 @@ var tests = {
|
||||
deferredResult = new Clipperz.Async.Deferred("Record.test.removeDirectLogin", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_data']);
|
||||
deferredResult.addMethod(user, 'login');
|
||||
|
||||
deferredResult.addMethod(user, 'getRecord', recordID);
|
||||
deferredResult.addMethodcaller('directLogins');
|
||||
deferredResult.addCallback(MochiKit.Base.keys);
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter('length'));
|
||||
deferredResult.addTest(4, "The record initially has 4 direct logins");
|
||||
|
||||
deferredResult.addMethod(user, 'getRecord', recordID);
|
||||
deferredResult.addMethodcaller('directLogins');
|
||||
deferredResult.addCallback(MochiKit.Base.itemgetter(directLoginID));
|
||||
@@ -187,6 +194,7 @@ var tests = {
|
||||
deferredResult.addTest(true, "removing a direct login to a record should result in pending changes on the record");
|
||||
|
||||
deferredResult.addMethod(user, 'saveChanges');
|
||||
|
||||
deferredResult.addMethod(user, 'hasPendingChanges');
|
||||
deferredResult.addTest(false, "after saving there should be not any pending changes");
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ refer to http://www.clipperz.com.
|
||||
<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>
|
||||
|
||||
@@ -1922,7 +1922,7 @@ var tests = {
|
||||
|
||||
proxy = new Clipperz.PM.Proxy.Test({shouldPayTolls:true, isDefault:true, readOnly:false});
|
||||
user2 = new Clipperz.PM.DataModel.User({username:username, getPassphraseFunction:function () { return passphrase;}});
|
||||
|
||||
console.log("PROXY", proxy);
|
||||
deferredResult = new Clipperz.Async.Deferred("registerNewUserAndAddARecord_test", someTestArgs);
|
||||
deferredResult.addMethod(proxy.dataStore(), 'setupWithEncryptedData', testData['joe_clipperz_offline_copy_with_preferences_and_OTPs_data']);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ TestRunner.runTests(
|
||||
// 'BookmarkletProcessor.html',
|
||||
'Connection.html',
|
||||
'Crypto.html',
|
||||
'Crypto_v0_4.html',
|
||||
// 'Crypto_other_implementation_comparison.html',
|
||||
'Crypto_performanceEvaluation.html',
|
||||
// 'CryptoPerformance_ByteArrayArray.html',
|
||||
|
||||
Reference in New Issue
Block a user