SRP PHP Client

PHP Client for Login over Secure Remote Password Protocol

1. registrate

generate s (salt) and v (verifier). generated by client, stored by server

$username = "falk";
$password = "test123";
$s = $srp->getRandomSeed();
$x = $srp->generateX($s, $username, $password);
$v = $srp->generateV($x);
$send = array("phase" => 0, "I" => $username, "v" => $v, "s" => $s);

Send

Array ( [phase] => 0 [I] => falk [v] => 3c61ef039150243c21dd5a28fe7658fc447a7c5747a45e3ee1a2e45b7137aa970f0a748af9f28e99bea4ea105ba039820a0f9949b09e213626850de3140d5092 [s] => e07a4c58c59e211565b1fb625f1bb292ed608696136bd4049a2325087b4c617c7e1ee29e13b6e6de98b4459e5d7d515c506046bb762d936212da11c9affd6615 )

Recive

Array ( [success] => 1 )

2. Login - Phase 1

client generate a (private random key), A (public generated key) and send A, I (username) to server.

$a = $srp->getRandomSeed();
$A = $srp->generateA($a);
$send = array("phase" => 1, "I" => $username, "A" => $A);

Send

Array ( [phase] => 1 [I] => falk [A] => 318ee300dce35e818c1635a3d04bdbc49dff4a32f2217ff240a326dfd34ccc00f60495455fc07a59ee177bf452ef286cfc3df1f1f19f6138078c0c40572d3ad2 )

Recive

Array ( [success] => )

3. Login - Phase 2

Client receive s (salt) und B (public key of Server) in Phase 1. Client build M1 and send it sto Server.


Notice: Undefined index: B in /html/code.falk-m.de/srp/client.php on line 128

Notice: Undefined index: s in /html/code.falk-m.de/srp/client.php on line 129
$B = $res1["B"];
$s = $res1["s"];
$x = $srp->generateX($s, $username, $password);
$S = $srp->generateS_Client($A, $B, $a, $x);
$M1 = $srp->generateM1($A, $B, $S);
$send = array("phase" => 2, "M1" => $M1);

Send

Array ( [phase] => 2 [M1] => 0704eb353d08bc1e1a60fef0b98e96bdf66b2f9ef2d193fa6cab8f8df51a8954 )

Recive

4. Server verification

Client receive M2 from Server, rebiuld and compare them and build session key

$res2 = json_decode($res["body"], true);
$M2 = $res2["M2"];
$M2_check = $srp->generateM2($A, $M1, $S);

if($M2 == $M2_check){
echo "SUCCESS;";
$K = $srp->generateK($S);
echo "SESSION KEY: ".$K;
}

Output


Notice: Trying to access array offset on value of type null in /html/code.falk-m.de/srp/client.php on line 180