Merge branch 'master-wraith' into v1.0.4-work

This commit is contained in:
Graham Eades 2018-11-28 17:40:24 +00:00
commit efa0e80186
22 changed files with 5244 additions and 138 deletions

View File

@ -1,5 +1,5 @@
{ {
"request.path": "../index.php", "request.path": "../index.php",
"dump.path": "../dump.php", "dump.path": "/../dump.php?frontend=",
"should.pay.toll": "false" "should.pay.toll": "false"
} }

View File

@ -11,7 +11,22 @@ header('Content-Disposition: attachment; filename=Clipperz_'.date("Ymd").'.html'
include "./objects/class.onetimepassword.php"; include "./objects/class.onetimepassword.php";
include "./objects/class.onetimepasswordstatus.php"; include "./objects/class.onetimepasswordstatus.php";
$htmlContent = file_get_contents("../index.html"); //$htmlContent = file_get_contents("../index.html");
switch ($_GET["frontend"]) {
case 'beta':
$htmlContent = file_get_contents("beta/index.html");
break;
case 'gamma':
$htmlContent = file_get_contents("gamma/index.html");
break;
case 'delta':
$htmlContent = file_get_contents("delta/index.html");
break;
default:
exit ("Invalid Frontend");
}
session_start(); session_start();

View File

@ -108,6 +108,7 @@ function digits($base) {
function clipperz_hash($value) { function clipperz_hash($value) {
return hash("sha256", hash("sha256", $value, true)); return hash("sha256", hash("sha256", $value, true));
//return hash("sha256", $value, false);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -251,6 +252,8 @@ error_log("registration");
error_log("handshake"); error_log("handshake");
$srp_g = "2"; $srp_g = "2";
$srp_n = base2dec("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16); $srp_n = base2dec("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16);
// Define k: k = H(N, g) in SRP-6a
$srp_k = base2dec(clipperz_hash($srp_n . $srp_g), 16);
$message = $parameters["message"]; $message = $parameters["message"];
@ -287,9 +290,13 @@ error_log("handshake");
$_SESSION["v"] = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00"; $_SESSION["v"] = "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00";
} }
$_SESSION["b"] = clipperz_randomSeed(); // This should now work with a random seed. Need to check.
// $_SESSION["b"] = clipperz_randomSeed();
// $_SESSION["b"] = "5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53"; // $_SESSION["b"] = "5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53";
$_SESSION["B"] = dec2base(bcadd(base2dec($_SESSION["v"], 16), bcpowmod($srp_g, base2dec($_SESSION["b"], 16), $srp_n)), 16); $_SESSION["b"] = "23309839184091712110293815740584558132927982490099443826709662564655631314481";
// B = kv + g^b
$_SESSION["B"] = dec2base(bcmod( bcadd( bcmod( bcmul( $srp_k, base2dec($_SESSION["v"], 16)), $srp_n), bcpowmod( $srp_g, $_SESSION["b"], $srp_n) ), $srp_n), 16);
$result["s"] = $_SESSION["s"]; $result["s"] = $_SESSION["s"];
$result["B"] = $_SESSION["B"]; $result["B"] = $_SESSION["B"];
@ -297,11 +304,13 @@ error_log("handshake");
//============================================================= //=============================================================
} else if ($message == "credentialCheck") { } else if ($message == "credentialCheck") {
error_log("credentialCheck"); error_log("credentialCheck");
$u = clipperz_hash(base2dec($_SESSION["B"],16));
$A = base2dec($_SESSION["A"], 16); $A = base2dec($_SESSION["A"], 16);
$S = bcpowmod(bcmul($A, bcpowmod(base2dec($_SESSION["v"], 16), base2dec($u, 16), $srp_n)), base2dec($_SESSION["b"], 16), $srp_n); // u = H(A, B)
$u = base2dec(clipperz_hash($A . base2dec($_SESSION["B"],16)), 16);
// S = (Av^u) ^ b
$S = bcpowmod( bcmul( $A, bcpowmod( base2dec($_SESSION["v"], 16), $u, $srp_n) ), $_SESSION["b"], $srp_n );
$K = clipperz_hash($S); $K = clipperz_hash($S);
$M1 = clipperz_hash($A.base2dec($_SESSION["B"],16).$K); $M1 = clipperz_hash("597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" . clipperz_hash($_SESSION['C']) . base2dec($_SESSION["s"],16) . base2dec($_SESSION['A'],16) . base2dec($_SESSION['B'],16) . base2dec($K,16));
//$result["B"] = $_SESSION["B"]; //$result["B"] = $_SESSION["B"];
//$result["u"] = $u; //$result["u"] = $u;
@ -311,6 +320,20 @@ error_log("credentialCheck");
//$result["M1"] = $M1; //$result["M1"] = $M1;
//$result["_M1"] = $parameters["parameters"]["M1"]; //$result["_M1"] = $parameters["parameters"]["M1"];
// error_log("credentialCheck calculated: ". $M1);
// error_log("credentialCheck S: ". $S);
// error_log("credentialCheck A: ". $A);
// error_log("credentialCheck B: ". $_SESSION["B"]);
// error_log("credentialCheck base2dec: ". base2dec($_SESSION["B"],16));
// error_log("credentialCheck K: ". base2dec($K,16));
// error_log("credentialCheck n: ". $srp_n);
// error_log("credentialCheck u: ". $u);
// error_log("credentialCheck v: ". base2dec($_SESSION['v'],16));
// error_log("credentialCheck expected: ". $parameters["parameters"]["M1"]);
//User -> Host: M = H(H(N) xor H(g), H(I), s, A, B, K)
if ($M1 == $parameters["parameters"]["M1"]) { if ($M1 == $parameters["parameters"]["M1"]) {
$_SESSION["K"] = $K; $_SESSION["K"] = $K;
$M2 = clipperz_hash($A.$M1.$K); $M2 = clipperz_hash($A.$M1.$K);
@ -386,7 +409,11 @@ error_log("message");
$recordStats["updateDate"] = $record->update_date; $recordStats["updateDate"] = $record->update_date;
$recordsStats[$record->reference] = $recordStats; $recordsStats[$record->reference] = $recordStats;
} }
$result["recordsStats"] = $recordsStats; if ( isset( $recordsStats ) ) {
$result["recordsStats"] = $recordsStats;
} else {
$result["recordsStats"] = NULL;
}
$result["statistics"] = $user->statistics; $result["statistics"] = $user->statistics;
$result["version"] = $user->version; $result["version"] = $user->version;
@ -520,7 +547,11 @@ error_log("message");
$user->Save(); $user->Save();
$recordToDeleteReferenceList = $parameters["parameters"]["records"]["deleted"]; if (isset( $parameters["parameters"]["records"]["deleted"] ) ) {
$recordToDeleteReferenceList = $parameters["parameters"]["records"]["deleted"];
} else {
$recordToDeleteReferenceList = NULL;
}
$recordList = array(); $recordList = array();
$c = count($recordToDeleteReferenceList); $c = count($recordToDeleteReferenceList);
for ($i=0; $i<$c; $i++) { for ($i=0; $i<$c; $i++) {

View File

@ -17,17 +17,10 @@
$databaseUser = $GLOBALS['configuration']['user']; $databaseUser = $GLOBALS['configuration']['user'];
$databasePassword = $GLOBALS['configuration']['pass']; $databasePassword = $GLOBALS['configuration']['pass'];
$databasePort = $GLOBALS['configuration']['port']; $databasePort = $GLOBALS['configuration']['port'];
$this->connection = mysql_connect ($serverName.":".$databasePort, $databaseUser, $databasePassword); $this->connection = mysqli_connect ($serverName, $databaseUser, $databasePassword , $databaseName, $databasePort);
if ($this->connection) if (!$this->connection)
{ {
if (!mysql_select_db ($databaseName)) throw new Exception('I cannot find the specified database "'.$databaseName.'". Please edit configuration.php.');
{
throw new Exception('I cannot find the specified database "'.$databaseName.'". Please edit configuration.php.');
}
}
else
{
throw new Exception('I cannot connect to the database. Please edit configuration.php with your database configuration.');
} }
} }
@ -43,19 +36,19 @@
public static function Reader($query, $connection) public static function Reader($query, $connection)
{ {
$cursor = mysql_query($query, $connection); $cursor = mysqli_query($connection, $query);
return $cursor; return $cursor;
} }
public static function Read($cursor) public static function Read($cursor)
{ {
return mysql_fetch_assoc($cursor); return mysqli_fetch_assoc($cursor);
} }
public static function NonQuery($query, $connection) public static function NonQuery($query, $connection)
{ {
mysql_query($query, $connection); mysqli_query($connection, $query);
$result = mysql_affected_rows($connection); $result = mysqli_affected_rows($connection);
if ($result == -1) if ($result == -1)
{ {
return false; return false;
@ -66,14 +59,14 @@
public static function Query($query, $connection) public static function Query($query, $connection)
{ {
$result = mysql_query($query, $connection); $result = mysqli_query($connection, $query);
return mysql_num_rows($result); return mysqli_num_rows($result);
} }
public static function InsertOrUpdate($query, $connection) public static function InsertOrUpdate($query, $connection)
{ {
$result = mysql_query($query, $connection); $result = mysqli_query($connection, $query);
return intval(mysql_insert_id($connection)); return intval(mysqli_insert_id($connection));
} }
} }
?> ?>

View File

@ -92,10 +92,10 @@ class POG_Base
return $objectList; return $objectList;
} }
private function CreateObjects($mysql_result, $objectClass, $lazyLoad = true) private function CreateObjects($mysqli_result, $objectClass, $lazyLoad = true)
{ {
$objectList = array(); $objectList = array();
while ($row = mysql_fetch_assoc($mysql_result)) while ($row = mysqli_fetch_assoc($mysqli_result))
{ {
$pog_object = new $objectClass(); $pog_object = new $objectClass();
$this->PopulateObjectAttributes($row, $pog_object); $this->PopulateObjectAttributes($row, $pog_object);

View File

@ -164,24 +164,26 @@ if(count($_POST) > 0 && $_SESSION['diagnosticsSuccessful']==false)
if ($errors == 0) if ($errors == 0)
{ {
AddTrace('File Structure....OK!'); AddTrace('File Structure....OK!');
if (!mysql_connect ($GLOBALS['configuration']['host'].":".$GLOBALS['configuration']['port'], $GLOBALS['configuration']['user'], $GLOBALS['configuration']['pass'])) #if (!mysql_connect ($GLOBALS['configuration']['host'].":".$GLOBALS['configuration']['port'], $GLOBALS['configuration']['user'], $GLOBALS['configuration']['pass']))
if (!mysqli_connect ($GLOBALS['configuration']['host'], $GLOBALS['configuration']['user'], $GLOBALS['configuration']['pass'],$GLOBALS['configuration']['db'], $GLOBALS['configuration']['port']))
{ {
$errors++; $errors++;
AddError('Cannot connect to the specified database server. Edit configuration.php'); AddError('Cannot connect to the specified database server. Edit configuration.php');
AddError('Cannot find the specified database "'.$GLOBALS['configuration']['db'].'". Edit configuration.php');
} }
if (isset($GLOBALS['configuration']['db_encoding']) && $GLOBALS['configuration']['db_encoding'] == 1 && !Base64::IsBase64FunctionInstalled()) if (isset($GLOBALS['configuration']['db_encoding']) && $GLOBALS['configuration']['db_encoding'] == 1 && !Base64::IsBase64FunctionInstalled())
{ {
$errors++; $errors++;
AddError('$configuration[db_encoding] needs to be set to 0 until you install the base64 plugin. Set db_encoding to 0 by editing configuration.php, run setup again and go to the "Manage Plugins" tab. Install the base64 plugin. Then you can set db_encoding = 1'); AddError('$configuration[db_encoding] needs to be set to 0 until you install the base64 plugin. Set db_encoding to 0 by editing configuration.php, run setup again and go to the "Manage Plugins" tab. Install the base64 plugin. Then you can set db_encoding = 1');
} }
if ($errors == 0) # if ($errors == 0)
{ # {
if (!@mysql_select_db ($GLOBALS['configuration']['db'])) # if (!@mysql_select_db ($GLOBALS['configuration']['db']))
{ # {
$errors++; # $errors++;
AddError('Cannot find the specified database "'.$GLOBALS['configuration']['db'].'". Edit configuration.php'); # AddError('Cannot find the specified database "'.$GLOBALS['configuration']['db'].'". Edit configuration.php');
} # }
} # }
} }
/** /**

View File

@ -276,10 +276,10 @@
{ {
$link = ''; $link = '';
$content = file_get_contents($objectFilePath); $content = file_get_contents($objectFilePath);
$contentParts = split("<b>",$content); $contentParts = explode("<b>",$content);
if (isset($contentParts[1])) if (isset($contentParts[1]))
{ {
$contentParts2 = split("</b>",$contentParts[1]); $contentParts2 = explode("</b>",$contentParts[1]);
} }
if (isset($contentParts2[0])) if (isset($contentParts2[0]))
{ {
@ -287,8 +287,8 @@
} }
if (isset($className)) if (isset($className))
{ {
$linkParts1 = split("\*\/", $contentParts[1]); $linkParts1 = explode("\*\/", $contentParts[1]);
$linkParts2 = split("\@link", $linkParts1[0]); $linkParts2 = explode("\@link", $linkParts1[0]);
if (isset($linkParts2[1])) if (isset($linkParts2[1]))
{ {
$link = $linkParts2[1]; $link = $linkParts2[1];
@ -313,10 +313,10 @@
function GetObjectName($objectFilePath) function GetObjectName($objectFilePath)
{ {
$content = file_get_contents($objectFilePath); $content = file_get_contents($objectFilePath);
$contentParts = split("<b>",$content); $contentParts = explode("<b>",$content);
if (isset($contentParts[1])) if (isset($contentParts[1]))
{ {
$contentParts2 = split("</b>",$contentParts[1]); $contentParts2 = explode("</b>",$contentParts[1]);
} }
if (isset($contentParts2[0])) if (isset($contentParts2[0]))
{ {
@ -593,10 +593,10 @@
//extract sql //extract sql
$content = file_get_contents($objectFilePath); $content = file_get_contents($objectFilePath);
$contentParts = split("<b>",$content); $contentParts = explode("<b>",$content);
if (isset($contentParts[1])) if (isset($contentParts[1]))
{ {
$contentParts2 = split("</b>",$contentParts[1]); $contentParts2 = explode("</b>",$contentParts[1]);
} }
if (isset($contentParts2[0])) if (isset($contentParts2[0]))
{ {
@ -604,8 +604,8 @@
} }
if (isset($className)) if (isset($className))
{ {
$sqlParts = split(";",$contentParts[0]); $sqlParts = explode(";",$contentParts[0]);
$sqlPart = split("CREATE",$sqlParts[0]); $sqlPart = explode("CREATE",$sqlParts[0]);
$sql = "CREATE ".$sqlPart[1].";"; $sql = "CREATE ".$sqlPart[1].";";
//execute sql //execute sql

View File

@ -13,7 +13,7 @@
<script> <script>
Clipperz_IEisBroken = false; Clipperz_IEisBroken = false;
Clipperz_normalizedNewLine = '\n'; Clipperz_normalizedNewLine = '\n';
Clipperz_dumpUrl = "@dump.path@/beta"; Clipperz_dumpUrl = "@dump.path@beta";
</script> </script>
<!--[if IE]><script> <!--[if IE]><script>

View File

@ -67,9 +67,14 @@ MochiKit.Base.update(Clipperz.Crypto.SRP, {
}, },
'k': function() { 'k': function() {
//k = H(N, g)
if (Clipperz.Crypto.SRP._k == null) { if (Clipperz.Crypto.SRP._k == null) {
// Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt(this.stringHash(this.n().asString() + this.g().asString()), 16); // Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt(this.stringHash(this.n().asString() + this.g().asString()), 16);
Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e", 16); // This is a fixed hash derived from a hash of N and G
// Following hash for just AES256
// Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e", 16);
// Following hash for dual AES256
Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("23059873679103356965010473015094804246238452944122574891019568752064785140295", 10);
} }
return Clipperz.Crypto.SRP._k; return Clipperz.Crypto.SRP._k;
@ -138,8 +143,10 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'a': function () { 'a': function () {
if (this._a == null) { if (this._a == null) {
this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16); // this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16);
// this._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); // Due to the problem with BigInt not handling signed numbers, this must be even.
// Possible generate any number, then bitwise shift right then left.
this._a = new Clipperz.Crypto.BigInt("33361134861037855263467252772741875431812790785257651194773534061185325245730", 10);
} }
return this._a; return this._a;
@ -191,7 +198,8 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'x': function () { 'x': function () {
if (this._x == null) { if (this._x == null) {
this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s().asString(16, 64) + this.P()), 16); // Private key x = H(s, p)
this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s() + this.P()), 16);
} }
return this._x; return this._x;
@ -210,6 +218,7 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
'S': function () { 'S': function () {
// S = (B - kg^x) ^ (a + ux)
if (this._S == null) { if (this._S == null) {
var bigint; var bigint;
var srp; var srp;
@ -217,19 +226,43 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
bigint = Clipperz.Crypto.BigInt; bigint = Clipperz.Crypto.BigInt;
srp = Clipperz.Crypto.SRP; srp = Clipperz.Crypto.SRP;
this._S = bigint.powerModule( // S can be negative. This breaks as the BigInt Library is unsigned
bigint.subtract( this._S = bigint.powerModule( bigint.subtract( bigint.multiply(Clipperz.Crypto.SRP.k(),bigint.powerModule(srp.g(), this.x(), srp.n())), this.B()), bigint.add(this.a(), bigint.multiply(this.u(), this.x())),srp.n() );
this.B(),
bigint.multiply(
Clipperz.Crypto.SRP.k(), // var tmp_B = new BigInteger(this.B());
bigint.powerModule(srp.g(), this.x(), srp.n()) // var tmp_k = new BigInteger(Clipperz.Crypto.SRP.k());
) // var tmp_g = new BigInteger(srp.g());
), // var tmp_x = new BigInteger(this.x());
bigint.add(this.a(), bigint.multiply(this.u(), this.x())), // var tmp_a = new BigInteger(this.a());
srp.n() // var tmp_n = new BigInteger(srp.n());
) // var tmp_u = new BigInteger(this.u());
//
// var tmp_S1 = new BigInteger(tmp_B.subtract(tmp_k.multiply(tmp_g.modPow(tmp_x,tmp_n))));
// var tmp_S2 = new BigInteger(tmp_a.add(tmp_u.multiply(tmp_x)));
// var tmp_S = new BigInteger(tmp_S1.modPow(tmp_S2,tmp_n));
// if (tmp_S.isNegative() == true ) {
// tmp_S = tmp_S.add(srp.n());
// }
//console.log("_B", tmp_B.toString());
//console.log("_k", tmp_k.toString());
//console.log("_g", tmp_g.toString());
//console.log("_x", tmp_x.toString());
//console.log("_a", tmp_a.toString());
//console.log("_n", tmp_n.toString());
//console.log("_u", tmp_u.toString());
//console.log("S1", tmp_S1.toString());
//console.log("S2", tmp_S2.toString());
//console.log("S-", tmp_S.toString());
} }
//this._S= Clipperz.Crypto.BigInt(tmp_S.toString(),10);
return this._S; return this._S;
}, },
@ -258,9 +291,25 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
this.s().asString() + this.s().asString() +
this.A().asString() + this.A().asString() +
this.B().asString() + this.B().asString() +
this.K() new Clipperz.Crypto.BigInt(this.K(),16).asString()
); );
//console.log("M1", this._M1); //console.log("M1", this._M1);
//console.log("g", this.g().asString());
//console.log("s", this.s().asString());
//console.log("a", this.a().asString());
//console.log("A", this.A().asString());
//console.log("B", this.B().asString());
//console.log("S", this.S().asString());
//console.log("k", Clipperz.Crypto.SRP.k().asString());
//console.log("K", this.K());
//console.log("x", this.x().asString());
//console.log("P", this.P());
//console.log("u", this.u());
//console.log("u", this.u().asString());
//console.log("Test", this.stringHash(this.A().asString));
//console.log("N", Clipperz.Crypto.SRP.n().asString());
//console.log("g", Clipperz.Crypto.SRP.g().asString());
//console.log("test", this.A().asString() + this.B().asString());
} }
return this._M1; return this._M1;
@ -283,15 +332,22 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
var result; var result;
var s, x, v; var s, x, v;
s = aSalt; //` s = aSalt;
s = new Clipperz.Crypto.BigInt(aSalt,16);
x = this.stringHash(s.asString() + this.P());
x = this.stringHash(s + this.P()); x = this.stringHash(s + this.P());
v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
result = {}; result = {};
result['C'] = this.C(); result['C'] = this.C();
result['s'] = s; result['s'] = s.asString(16);
result['v'] = v.asString(16); result['v'] = v.asString(16);
//console.log("ServerSide C", result['C']);
//console.log("ServerSide s", result['s']);
//console.log("ServerSide v", result['v']);
//console.log("ServerSide P", this.P());
//console.log("ServerSide x", ge.asString());
return result; return result;
}, },
@ -334,7 +390,9 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'stringHash': function(aValue) { 'stringHash': function(aValue) {
var result; var result;
result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); //result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2);
//result = Clipperz.Crypto.SHA.sha256( new Clipperz.ByteArray(aValue)).toHexString().substring(2);
result = Clipperz.Crypto.SHA.sha_d256( new Clipperz.ByteArray(aValue)).toHexString().substring(2);
return result; return result;
}, },

File diff suppressed because it is too large Load Diff

View File

@ -354,7 +354,8 @@ Clipperz.PM.Proxy.Offline.DataStore.prototype = MochiKit.Base.update(null, {
this.set_C(someParameters.parameters.C); this.set_C(someParameters.parameters.C);
this.set_b(new Clipperz.Crypto.BigInt(randomBytes, 16)); this.set_b(new Clipperz.Crypto.BigInt(randomBytes, 16));
v = new Clipperz.Crypto.BigInt(this.userData()['v'], 16); v = new Clipperz.Crypto.BigInt(this.userData()['v'], 16);
this.set_B((Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(this.b(), Clipperz.Crypto.SRP.n()))); //this.set_B((Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(this.b(), Clipperz.Crypto.SRP.n())));
this.set_B((Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(this.b(), Clipperz.Crypto.SRP.n())).module(Clipperz.Crypto.SRP.n()));
this.set_A(someParameters.parameters.A); this.set_A(someParameters.parameters.A);
@ -363,7 +364,7 @@ Clipperz.PM.Proxy.Offline.DataStore.prototype = MochiKit.Base.update(null, {
nextTollRequestType = 'CONNECT'; nextTollRequestType = 'CONNECT';
} else if (someParameters.message == "credentialCheck") { } else if (someParameters.message == "credentialCheck") {
var v, u, s, S, A, K, M1; var v, u, s, S, A, K, M1, KK;
var stringHash = function (aValue) { var stringHash = function (aValue) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2);
}; };
@ -373,9 +374,11 @@ Clipperz.PM.Proxy.Offline.DataStore.prototype = MochiKit.Base.update(null, {
A = new Clipperz.Crypto.BigInt(this.A(), 16); A = new Clipperz.Crypto.BigInt(this.A(), 16);
u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + this.B().asString(10))).toHexString(), 16); u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + this.B().asString(10))).toHexString(), 16);
s = new Clipperz.Crypto.BigInt(this.userData()['s'], 16); s = new Clipperz.Crypto.BigInt(this.userData()['s'], 16);
S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(this.b(), Clipperz.Crypto.SRP.n()); //S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(this.b(), Clipperz.Crypto.SRP.n());
S = v.powerModule(u, Clipperz.Crypto.SRP.n()).multiply(A).module(Clipperz.Crypto.SRP.n()).powerModule(this.b(), Clipperz.Crypto.SRP.n())
K = stringHash(S.asString(10)); K = stringHash(S.asString(10));
KK = new Clipperz.Crypto.BigInt(K,16);
M1 = stringHash( M1 = stringHash(
"597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" + "597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" +
@ -383,7 +386,7 @@ Clipperz.PM.Proxy.Offline.DataStore.prototype = MochiKit.Base.update(null, {
s.asString(10) + s.asString(10) +
A.asString(10) + A.asString(10) +
this.B().asString(10) + this.B().asString(10) +
K KK.asString(10)
); );
if (someParameters.parameters.M1 == M1) { if (someParameters.parameters.M1 == M1) {
var M2; var M2;

View File

@ -41,7 +41,7 @@
// Clipperz_IEisBroken = false; // Clipperz_IEisBroken = false;
// Clipperz_normalizedNewLine = '\n'; // Clipperz_normalizedNewLine = '\n';
MochiKit = {}; MochiKit.__export__ = false; MochiKit = {}; MochiKit.__export__ = false;
Clipperz_dumpUrl = "@dump.path@/delta"; Clipperz_dumpUrl = "@dump.path@delta";
Clipperz_version = "@application.version@"; Clipperz_version = "@application.version@";
Clipperz_PM_UI_availableStyles = ['extra-short', 'narrow', 'wide', 'extra-wide']; Clipperz_PM_UI_availableStyles = ['extra-short', 'narrow', 'wide', 'extra-wide'];
"use strict"; "use strict";

View File

@ -56,7 +56,7 @@ MochiKit.Base.update(Clipperz.Crypto.SRP, {
return Clipperz.Crypto.SRP._n; return Clipperz.Crypto.SRP._n;
}, },
//......................................................................... //-------------------------------------------------------------------------
'g': function() { 'g': function() {
if (Clipperz.Crypto.SRP._g == null) { if (Clipperz.Crypto.SRP._g == null) {
@ -66,12 +66,15 @@ MochiKit.Base.update(Clipperz.Crypto.SRP, {
return Clipperz.Crypto.SRP._g; return Clipperz.Crypto.SRP._g;
}, },
//.........................................................................
'k': function() { 'k': function() {
//k = H(N, g)
if (Clipperz.Crypto.SRP._k == null) { if (Clipperz.Crypto.SRP._k == null) {
// Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt(this.stringHash(this.n().asString() + this.g().asString()), 16); // Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt(this.stringHash(this.n().asString() + this.g().asString()), 16);
Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e", 16); // This is a fixed hash derived from a hash of N and G
// Following hash for just AES256
// Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e", 16);
// Following hash for dual AES256
Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("23059873679103356965010473015094804246238452944122574891019568752064785140295", 10);
} }
return Clipperz.Crypto.SRP._k; return Clipperz.Crypto.SRP._k;
@ -140,8 +143,10 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'a': function () { 'a': function () {
if (this._a == null) { if (this._a == null) {
this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16); // this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16);
// this._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); // Due to the problem with BigInt not handling signed numbers, this must be even.
// Possible generate any number, then bitwise shift right then left.
this._a = new Clipperz.Crypto.BigInt("33361134861037855263467252772741875431812790785257651194773534061185325245730", 10);
} }
return this._a; return this._a;
@ -193,7 +198,8 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'x': function () { 'x': function () {
if (this._x == null) { if (this._x == null) {
this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s().asString(16, 64) + this.P()), 16); // Private key x = H(s, p)
this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s() + this.P()), 16);
} }
return this._x; return this._x;
@ -212,6 +218,7 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
'S': function () { 'S': function () {
// S = (B - kg^x) ^ (a + ux)
if (this._S == null) { if (this._S == null) {
var bigint; var bigint;
var srp; var srp;
@ -219,19 +226,43 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
bigint = Clipperz.Crypto.BigInt; bigint = Clipperz.Crypto.BigInt;
srp = Clipperz.Crypto.SRP; srp = Clipperz.Crypto.SRP;
this._S = bigint.powerModule( // S can be negative. This breaks as the BigInt Library is unsigned
bigint.subtract( this._S = bigint.powerModule( bigint.subtract( bigint.multiply(Clipperz.Crypto.SRP.k(),bigint.powerModule(srp.g(), this.x(), srp.n())), this.B()), bigint.add(this.a(), bigint.multiply(this.u(), this.x())),srp.n() );
this.B(),
bigint.multiply(
Clipperz.Crypto.SRP.k(), // var tmp_B = new BigInteger(this.B());
bigint.powerModule(srp.g(), this.x(), srp.n()) // var tmp_k = new BigInteger(Clipperz.Crypto.SRP.k());
) // var tmp_g = new BigInteger(srp.g());
), // var tmp_x = new BigInteger(this.x());
bigint.add(this.a(), bigint.multiply(this.u(), this.x())), // var tmp_a = new BigInteger(this.a());
srp.n() // var tmp_n = new BigInteger(srp.n());
) // var tmp_u = new BigInteger(this.u());
//
// var tmp_S1 = new BigInteger(tmp_B.subtract(tmp_k.multiply(tmp_g.modPow(tmp_x,tmp_n))));
// var tmp_S2 = new BigInteger(tmp_a.add(tmp_u.multiply(tmp_x)));
// var tmp_S = new BigInteger(tmp_S1.modPow(tmp_S2,tmp_n));
// if (tmp_S.isNegative() == true ) {
// tmp_S = tmp_S.add(srp.n());
// }
//console.log("_B", tmp_B.toString());
//console.log("_k", tmp_k.toString());
//console.log("_g", tmp_g.toString());
//console.log("_x", tmp_x.toString());
//console.log("_a", tmp_a.toString());
//console.log("_n", tmp_n.toString());
//console.log("_u", tmp_u.toString());
//console.log("S1", tmp_S1.toString());
//console.log("S2", tmp_S2.toString());
//console.log("S-", tmp_S.toString());
} }
//this._S= Clipperz.Crypto.BigInt(tmp_S.toString(),10);
return this._S; return this._S;
}, },
@ -260,9 +291,25 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
this.s().asString() + this.s().asString() +
this.A().asString() + this.A().asString() +
this.B().asString() + this.B().asString() +
this.K() new Clipperz.Crypto.BigInt(this.K(),16).asString()
); );
//console.log("M1", this._M1); //console.log("M1", this._M1);
//console.log("g", this.g().asString());
//console.log("s", this.s().asString());
//console.log("a", this.a().asString());
//console.log("A", this.A().asString());
//console.log("B", this.B().asString());
//console.log("S", this.S().asString());
//console.log("k", Clipperz.Crypto.SRP.k().asString());
//console.log("K", this.K());
//console.log("x", this.x().asString());
//console.log("P", this.P());
//console.log("u", this.u());
//console.log("u", this.u().asString());
//console.log("Test", this.stringHash(this.A().asString));
//console.log("N", Clipperz.Crypto.SRP.n().asString());
//console.log("g", Clipperz.Crypto.SRP.g().asString());
//console.log("test", this.A().asString() + this.B().asString());
} }
return this._M1; return this._M1;
@ -285,15 +332,22 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
var result; var result;
var s, x, v; var s, x, v;
s = aSalt; //` s = aSalt;
s = new Clipperz.Crypto.BigInt(aSalt,16);
x = this.stringHash(s.asString() + this.P());
x = this.stringHash(s + this.P()); x = this.stringHash(s + this.P());
v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
result = {}; result = {};
result['C'] = this.C(); result['C'] = this.C();
result['s'] = s; result['s'] = s.asString(16);
result['v'] = v.asString(16); result['v'] = v.asString(16);
//console.log("ServerSide C", result['C']);
//console.log("ServerSide s", result['s']);
//console.log("ServerSide v", result['v']);
//console.log("ServerSide P", this.P());
//console.log("ServerSide x", ge.asString());
return result; return result;
}, },
@ -336,7 +390,9 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'stringHash': function(aValue) { 'stringHash': function(aValue) {
var result; var result;
result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); //result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2);
//result = Clipperz.Crypto.SHA.sha256( new Clipperz.ByteArray(aValue)).toHexString().substring(2);
result = Clipperz.Crypto.SHA.sha_d256( new Clipperz.ByteArray(aValue)).toHexString().substring(2);
return result; return result;
}, },

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,8 @@ Clipperz.PM.DataModel.Record = function(args) {
Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments); Clipperz.PM.DataModel.Record.superclass.constructor.apply(this, arguments);
this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter')); this._updateDate = (args.updateDate ? Clipperz.PM.Date.parse(args.updateDate) : Clipperz.Base.exception.raise('MandatoryParameter'));
this._accessDate = (args.accessDate ? Clipperz.PM.Date.parse(args.accessDate) : Clipperz.Base.exception.raise('MandatoryParameter')); // Disabled due to invalid data and the raised exception
// this._accessDate = (args.accessDate ? Clipperz.PM.Date.parse(args.accessDate) : Clipperz.Base.exception.raise('MandatoryParameter'));
this._retrieveIndexDataFunction = args.retrieveIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); this._retrieveIndexDataFunction = args.retrieveIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter');
this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter'); this._updateIndexDataFunction = args.updateIndexDataFunction || Clipperz.Base.exception.raise('MandatoryParameter');

View File

@ -434,7 +434,8 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
randomBytes = Clipperz.Crypto.Base.generateRandomSeed(); randomBytes = Clipperz.Crypto.Base.generateRandomSeed();
aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16); aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16);
v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16);
aConnection['B'] = (Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())); //aConnection['B'] = (Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()));
aConnection['B'] = ((Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())).module(Clipperz.Crypto.SRP.n()));
aConnection['A'] = someParameters.parameters.A; aConnection['A'] = someParameters.parameters.A;
@ -443,7 +444,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
nextTollRequestType = 'CONNECT'; nextTollRequestType = 'CONNECT';
} else if (someParameters.message == "credentialCheck") { } else if (someParameters.message == "credentialCheck") {
var v, u, s, S, A, K, M1; var v, u, s, S, A, K, M1, KK;
var stringHash = function (aValue) { var stringHash = function (aValue) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2);
}; };
@ -452,9 +453,11 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
A = new Clipperz.Crypto.BigInt(aConnection['A'], 16); A = new Clipperz.Crypto.BigInt(aConnection['A'], 16);
u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10))).toHexString(), 16); u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10))).toHexString(), 16);
s = new Clipperz.Crypto.BigInt(aConnection['userData']['s'], 16); s = new Clipperz.Crypto.BigInt(aConnection['userData']['s'], 16);
S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()); //S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n());
S = v.powerModule(u, Clipperz.Crypto.SRP.n()).multiply(A).module(Clipperz.Crypto.SRP.n()).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n());
K = stringHash(S.asString(10)); K = stringHash(S.asString(10));
KK = new Clipperz.Crypto.BigInt(K,16);
M1 = stringHash( M1 = stringHash(
"597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" + "597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" +
@ -462,7 +465,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
s.asString(10) + s.asString(10) +
A.asString(10) + A.asString(10) +
aConnection['B'].asString(10) + aConnection['B'].asString(10) +
K KK.asString(10)
); );
if (someParameters.parameters.M1 == M1) { if (someParameters.parameters.M1 == M1) {
var M2; var M2;

View File

@ -1268,9 +1268,32 @@ Clipperz.log("THE BROWSER IS OFFLINE");
]; ];
var attributes = this.user().accountInfo()._attributes; var attributes = this.user().accountInfo()._attributes;
MochiKit.Iter.forEach(usefulFields, function (aFieldName) { //
result[aFieldName] = attributes[aFieldName]; // Disable loading of the details of the account. Hard code similar to the python frontend
}) //
// MochiKit.Iter.forEach(usefulFields, function (aFieldName) {
// result[aFieldName] = attributes[aFieldName];
// })
result['currentSubscriptionType'] = 'EARLY_ADOPTER' ;
result['expirationDate'] = 'Mon, 01 January 4001 00:00:00 UTC' ;
result['referenceDate'] = 'Fri, 03 April 2015 08:17:46 UTC' ;
result['featureSet'] = 'FULL' ;
result['features'] = ['UPDATE_CREDENTIALS',
'EDIT_CARD',
'CARD_DETAILS',
'REGISTER_CARD',
'ADD_CARD',
'DELETE_CARD',
'OFFLINE_COPY',
'LIST_CARDS'];
result['isExpired'] = false ;
result['isExpiring'] = false ;
result['paymentVerificationPending'] = false ;
result['attachmentQuota'] = 100 ;
result['certificateQuota'] = 100 ;
}; };
return result; return result;

View File

@ -13,7 +13,7 @@
<script> <script>
Clipperz_IEisBroken = false; Clipperz_IEisBroken = false;
Clipperz_normalizedNewLine = '\n'; Clipperz_normalizedNewLine = '\n';
Clipperz_dumpUrl = "@dump.path@/gamma"; Clipperz_dumpUrl = "@dump.path@gamma";
Clipperz_version = "@application.version@"; Clipperz_version = "@application.version@";
"use strict"; "use strict";
</script> </script>

View File

@ -67,9 +67,14 @@ MochiKit.Base.update(Clipperz.Crypto.SRP, {
}, },
'k': function() { 'k': function() {
//k = H(N, g)
if (Clipperz.Crypto.SRP._k == null) { if (Clipperz.Crypto.SRP._k == null) {
// Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt(this.stringHash(this.n().asString() + this.g().asString()), 16); // Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt(this.stringHash(this.n().asString() + this.g().asString()), 16);
Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e", 16); // This is a fixed hash derived from a hash of N and G
// Following hash for just AES256
// Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("64398bff522814e306a97cb9bfc4364b7eed16a8c17c5208a40a2bad2933c8e", 16);
// Following hash for dual AES256
Clipperz.Crypto.SRP._k = new Clipperz.Crypto.BigInt("23059873679103356965010473015094804246238452944122574891019568752064785140295", 10);
} }
return Clipperz.Crypto.SRP._k; return Clipperz.Crypto.SRP._k;
@ -138,8 +143,10 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'a': function () { 'a': function () {
if (this._a == null) { if (this._a == null) {
this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16); // this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16);
// this._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); // Due to the problem with BigInt not handling signed numbers, this must be even.
// Possible generate any number, then bitwise shift right then left.
this._a = new Clipperz.Crypto.BigInt("33361134861037855263467252772741875431812790785257651194773534061185325245730", 10);
} }
return this._a; return this._a;
@ -191,7 +198,8 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'x': function () { 'x': function () {
if (this._x == null) { if (this._x == null) {
this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s().asString(16, 64) + this.P()), 16); // Private key x = H(s, p)
this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s() + this.P()), 16);
} }
return this._x; return this._x;
@ -210,6 +218,7 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
'S': function () { 'S': function () {
// S = (B - kg^x) ^ (a + ux)
if (this._S == null) { if (this._S == null) {
var bigint; var bigint;
var srp; var srp;
@ -217,19 +226,43 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
bigint = Clipperz.Crypto.BigInt; bigint = Clipperz.Crypto.BigInt;
srp = Clipperz.Crypto.SRP; srp = Clipperz.Crypto.SRP;
this._S = bigint.powerModule( // S can be negative. This breaks as the BigInt Library is unsigned
bigint.subtract( this._S = bigint.powerModule( bigint.subtract( bigint.multiply(Clipperz.Crypto.SRP.k(),bigint.powerModule(srp.g(), this.x(), srp.n())), this.B()), bigint.add(this.a(), bigint.multiply(this.u(), this.x())),srp.n() );
this.B(),
bigint.multiply(
Clipperz.Crypto.SRP.k(), // var tmp_B = new BigInteger(this.B());
bigint.powerModule(srp.g(), this.x(), srp.n()) // var tmp_k = new BigInteger(Clipperz.Crypto.SRP.k());
) // var tmp_g = new BigInteger(srp.g());
), // var tmp_x = new BigInteger(this.x());
bigint.add(this.a(), bigint.multiply(this.u(), this.x())), // var tmp_a = new BigInteger(this.a());
srp.n() // var tmp_n = new BigInteger(srp.n());
) // var tmp_u = new BigInteger(this.u());
//
// var tmp_S1 = new BigInteger(tmp_B.subtract(tmp_k.multiply(tmp_g.modPow(tmp_x,tmp_n))));
// var tmp_S2 = new BigInteger(tmp_a.add(tmp_u.multiply(tmp_x)));
// var tmp_S = new BigInteger(tmp_S1.modPow(tmp_S2,tmp_n));
// if (tmp_S.isNegative() == true ) {
// tmp_S = tmp_S.add(srp.n());
// }
//console.log("_B", tmp_B.toString());
//console.log("_k", tmp_k.toString());
//console.log("_g", tmp_g.toString());
//console.log("_x", tmp_x.toString());
//console.log("_a", tmp_a.toString());
//console.log("_n", tmp_n.toString());
//console.log("_u", tmp_u.toString());
//console.log("S1", tmp_S1.toString());
//console.log("S2", tmp_S2.toString());
//console.log("S-", tmp_S.toString());
} }
//this._S= Clipperz.Crypto.BigInt(tmp_S.toString(),10);
return this._S; return this._S;
}, },
@ -258,9 +291,25 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
this.s().asString() + this.s().asString() +
this.A().asString() + this.A().asString() +
this.B().asString() + this.B().asString() +
this.K() new Clipperz.Crypto.BigInt(this.K(),16).asString()
); );
//console.log("M1", this._M1); //console.log("M1", this._M1);
//console.log("g", this.g().asString());
//console.log("s", this.s().asString());
//console.log("a", this.a().asString());
//console.log("A", this.A().asString());
//console.log("B", this.B().asString());
//console.log("S", this.S().asString());
//console.log("k", Clipperz.Crypto.SRP.k().asString());
//console.log("K", this.K());
//console.log("x", this.x().asString());
//console.log("P", this.P());
//console.log("u", this.u());
//console.log("u", this.u().asString());
//console.log("Test", this.stringHash(this.A().asString));
//console.log("N", Clipperz.Crypto.SRP.n().asString());
//console.log("g", Clipperz.Crypto.SRP.g().asString());
//console.log("test", this.A().asString() + this.B().asString());
} }
return this._M1; return this._M1;
@ -283,15 +332,22 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
var result; var result;
var s, x, v; var s, x, v;
s = aSalt; //` s = aSalt;
s = new Clipperz.Crypto.BigInt(aSalt,16);
x = this.stringHash(s.asString() + this.P());
x = this.stringHash(s + this.P()); x = this.stringHash(s + this.P());
v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
result = {}; result = {};
result['C'] = this.C(); result['C'] = this.C();
result['s'] = s; result['s'] = s.asString(16);
result['v'] = v.asString(16); result['v'] = v.asString(16);
//console.log("ServerSide C", result['C']);
//console.log("ServerSide s", result['s']);
//console.log("ServerSide v", result['v']);
//console.log("ServerSide P", this.P());
//console.log("ServerSide x", ge.asString());
return result; return result;
}, },
@ -334,7 +390,9 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, {
'stringHash': function(aValue) { 'stringHash': function(aValue) {
var result; var result;
result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); //result = this.hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2);
//result = Clipperz.Crypto.SHA.sha256( new Clipperz.ByteArray(aValue)).toHexString().substring(2);
result = Clipperz.Crypto.SHA.sha_d256( new Clipperz.ByteArray(aValue)).toHexString().substring(2);
return result; return result;
}, },

File diff suppressed because it is too large Load Diff

View File

@ -329,7 +329,8 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
randomBytes = Clipperz.Crypto.Base.generateRandomSeed(); randomBytes = Clipperz.Crypto.Base.generateRandomSeed();
aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16); aConnection['b'] = new Clipperz.Crypto.BigInt(randomBytes, 16);
v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16); v = new Clipperz.Crypto.BigInt(aConnection['userData']['v'], 16);
aConnection['B'] = (Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())); //aConnection['B'] = (Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()));
aConnection['B'] = ((Clipperz.Crypto.SRP.k().multiply(v)).add(Clipperz.Crypto.SRP.g().powerModule(aConnection['b'], Clipperz.Crypto.SRP.n())).module(Clipperz.Crypto.SRP.n()));
aConnection['A'] = someParameters.parameters.A; aConnection['A'] = someParameters.parameters.A;
@ -338,7 +339,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
nextTollRequestType = 'CONNECT'; nextTollRequestType = 'CONNECT';
} else if (someParameters.message == "credentialCheck") { } else if (someParameters.message == "credentialCheck") {
var v, u, s, S, A, K, M1; var v, u, s, S, A, K, M1, KK;
var stringHash = function (aValue) { var stringHash = function (aValue) {
return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2); return Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(aValue)).toHexString().substring(2);
}; };
@ -347,9 +348,11 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
A = new Clipperz.Crypto.BigInt(aConnection['A'], 16); A = new Clipperz.Crypto.BigInt(aConnection['A'], 16);
u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10))).toHexString(), 16); u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(A.asString(10) + aConnection['B'].asString(10))).toHexString(), 16);
s = new Clipperz.Crypto.BigInt(aConnection['userData']['s'], 16); s = new Clipperz.Crypto.BigInt(aConnection['userData']['s'], 16);
S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n()); //S = (A.multiply(v.powerModule(u, Clipperz.Crypto.SRP.n()))).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n());
S = v.powerModule(u, Clipperz.Crypto.SRP.n()).multiply(A).module(Clipperz.Crypto.SRP.n()).powerModule(aConnection['b'], Clipperz.Crypto.SRP.n());
K = stringHash(S.asString(10)); K = stringHash(S.asString(10));
KK = new Clipperz.Crypto.BigInt(K,16);
M1 = stringHash( M1 = stringHash(
"597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" + "597626870978286801440197562148588907434001483655788865609375806439877501869636875571920406529" +
@ -357,7 +360,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
s.asString(10) + s.asString(10) +
A.asString(10) + A.asString(10) +
aConnection['B'].asString(10) + aConnection['B'].asString(10) +
K KK.asString(10)
); );
if (someParameters.parameters.M1 == M1) { if (someParameters.parameters.M1 == M1) {
var M2; var M2;

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python2
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
import sys import sys