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] => 9a9dfd6de9122b2d54525922eeb34fa667b424770171f333b46dc5d000a58f909a9e7e5838e375c3d36f2b4de681ba79452a34c7739a5cc3d5c5203edfd58b97 [s] => 603fb7ed1869bed81eb8d1e202a51755508c7884e8ca19d2a199f60387e659d47775572ce5a35a13ea7d9025c07eef9c5cba33eaac2c0217e0daf2253833d719 )

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] => 2ab022a8c92e00dab4bab8d923660ef595e2147c237ccb87df8575b990513803a4cada8319801ddd7b685d8ed921969eb6ededb6f3acfd77de7b9ba2945b4ad7 )

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] => 96cb6ba2c8a1420b9dc81d7907640daff191c1cc5c7f634aa765b50ef3d38a48 )

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