summaryrefslogtreecommitdiff
path: root/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
Unidiff
Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html1
1 files changed, 0 insertions, 1 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html b/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
index d0ee153..ba842a9 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
@@ -1,125 +1,124 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 it and/or modify it under the terms of the GNU Affero General Public 11 it and/or modify it under the terms of the GNU Affero General Public
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* You should have received a copy of the GNU Affero General Public 20* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
35 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
37 36
38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
44</head> 43</head>
45<body> 44<body>
46<pre id="test"> 45<pre id="test">
47<script type="text/javascript"> 46<script type="text/javascript">
48hashString = function(aValue) { 47hashString = function(aValue) {
49 return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aValue)).toHexString().substring(2) 48 return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aValue)).toHexString().substring(2)
50} 49}
51try { 50try {
52 varusername; 51 varusername;
53 varpassphrase; 52 varpassphrase;
54 53
55 var C; 54 var C;
56 var P; 55 var P;
57 var encryptedText_1; 56 var encryptedText_1;
58 var encryptedText_2; 57 var encryptedText_2;
59 varsalt; 58 varsalt;
60 varx; 59 varx;
61 var v; 60 var v;
62 var v1; 61 var v1;
63 62
64 username = "giulio.cesare"; 63 username = "giulio.cesare";
65 passphrase = "trustno1"; 64 passphrase = "trustno1";
66 65
67 C = hashString(username); 66 C = hashString(username);
68 is (C, "bde3c7b5fdcd9d6ce72782ca1ae912fc4397d668fcb3a73a04e5d47852670c4a", "C"); 67 is (C, "bde3c7b5fdcd9d6ce72782ca1ae912fc4397d668fcb3a73a04e5d47852670c4a", "C");
69 68
70 P = hashString(passphrase + username); 69 P = hashString(passphrase + username);
71 is (P, "d79f5c5a04e91e1c85fb64cb6ee9481cb52c181047f69da02cd6c3ce6d058a76", "P"); 70 is (P, "d79f5c5a04e91e1c85fb64cb6ee9481cb52c181047f69da02cd6c3ce6d058a76", "P");
72 71
73 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988"; 72 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988";
74 73
75 x = hashString(salt + P); 74 x = hashString(salt + P);
76 is(x, "21fe88a158e420aade86e00b5eb12a4c19bf15482fa34c542c90b1afdbd5b5fd", "x"); 75 is(x, "21fe88a158e420aade86e00b5eb12a4c19bf15482fa34c542c90b1afdbd5b5fd", "x");
77 76
78 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); 77 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
79 is(v.asString(10), "33816467430011076413789931449607305355248467973000153409872503376381719918118", "v"); 78 is(v.asString(10), "33816467430011076413789931449607305355248467973000153409872503376381719918118", "v");
80 is(v.asString(16), "4ac37139dbf32ebabd2c43f91dd085066d3c457d059efd5902d32ed247fcb626", "v (base 16)"); 79 is(v.asString(16), "4ac37139dbf32ebabd2c43f91dd085066d3c457d059efd5902d32ed247fcb626", "v (base 16)");
81 80
82 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 81 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
83 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 82 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
84 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result"); 83 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result");
85 84
86 //------------------------------------------------------------------------- 85 //-------------------------------------------------------------------------
87 86
88 username = "giulio.cesare.debug"; 87 username = "giulio.cesare.debug";
89 passphrase = "trustno1"; 88 passphrase = "trustno1";
90 89
91 C = hashString(username); 90 C = hashString(username);
92 is (C, "fa1af609123b97a10d676158ed538d4657a89ac33a102b22bd9a66712039e208", "C"); 91 is (C, "fa1af609123b97a10d676158ed538d4657a89ac33a102b22bd9a66712039e208", "C");
93 92
94 P = hashString(passphrase + username); 93 P = hashString(passphrase + username);
95 is (P, "e1bfba03dd626b12f29458a6ad63fb2c01b4765548504e1e2f6b1503c82e4253", "P"); 94 is (P, "e1bfba03dd626b12f29458a6ad63fb2c01b4765548504e1e2f6b1503c82e4253", "P");
96 95
97 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988"; 96 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988";
98 97
99 x = hashString(salt + P); 98 x = hashString(salt + P);
100 is(x, "93d4af3cdcd2447a745d309826dff3161feed4b15f32db8e909ff032a2bc8fb8", "x"); 99 is(x, "93d4af3cdcd2447a745d309826dff3161feed4b15f32db8e909ff032a2bc8fb8", "x");
101 100
102 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); 101 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
103 is(v.asString(10), "115049747015252903452664067168789229427785288458366249918596663144588656606556", "v"); 102 is(v.asString(10), "115049747015252903452664067168789229427785288458366249918596663144588656606556", "v");
104 103
105 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 104 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
106 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 105 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
107 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result"); 106 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result");
108 107
109 //------------------------------------------------------------------------- 108 //-------------------------------------------------------------------------
110 109
111 var srpConnection; 110 var srpConnection;
112 var C, P, salt; 111 var C, P, salt;
113 112
114 C = "da8602c2f847306f4eb9acdaad925277d1fad1408f173f128a078aea15e60b1e"; 113 C = "da8602c2f847306f4eb9acdaad925277d1fad1408f173f128a078aea15e60b1e";
115 P = "77643559beca49dd21c1c31db10bb0a9009662cb504413dc3fa3b7303c7e02ba"; 114 P = "77643559beca49dd21c1c31db10bb0a9009662cb504413dc3fa3b7303c7e02ba";
116 salt ="000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1"; 115 salt ="000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1";
117 116
118 srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256}); 117 srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256});
119 srpConnection._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); 118 srpConnection._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10);
120 srpConnection.set_s(new Clipperz.Crypto.BigInt(salt, 16)); 119 srpConnection.set_s(new Clipperz.Crypto.BigInt(salt, 16));
121 is (srpConnection.s().asString(16, 64), salt, "salt read/write is coherent"); 120 is (srpConnection.s().asString(16, 64), salt, "salt read/write is coherent");
122 srpConnection.set_B(new Clipperz.Crypto.BigInt("123541032067854367017620977654446651448957899464139861291542193929199957895435", 10)); 121 srpConnection.set_B(new Clipperz.Crypto.BigInt("123541032067854367017620977654446651448957899464139861291542193929199957895435", 10));
123 122
124 is(srpConnection.serverSideCredentialsWithSalt(salt).v, 123 is(srpConnection.serverSideCredentialsWithSalt(salt).v,
125 "c73169c8236d37bf9ef11a2349e3064b7dc6e883a58d64443ea9235677520030", 124 "c73169c8236d37bf9ef11a2349e3064b7dc6e883a58d64443ea9235677520030",