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] => 50a9ac25c013a9a14657fea4142bdf2500d86554743603530b8348e82a1781fc74b9e276ffcbaac6a4aed40701f07fb43347e53a67100417ebc4800fbb961c45 [s] => 4d46f8bb6b53942f1729acba5477301c689b989520fa3be344cd6f9b2d13f9a548f665ca32449a4d1e1fa4a168c2805387c325c10df3ebf2ba934412975c43f4 )

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] => 1886085692deab26cd8f351f3ddfcc8926f5a9095408431adcbdbea5d9f26c3c9042fc54ea3b404bfcfbea66fd3b83520900b92618ecebc8541efa13983e08bd )

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.


Warning: Undefined array key "B" in /html/code.falk-m.de/srp/client.php on line 128

Warning: Undefined array key "s" in /html/code.falk-m.de/srp/client.php on line 129

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /html/code.falk-m.de/srp/php/lib/srp.php on line 222

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /html/code.falk-m.de/srp/php/lib/srp.php on line 222
$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] => d5cfc2320d28f2dbe06809d93b328a461a136acd4ef94e3ba6c88f157a925566 )

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


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