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] => 79604e49e70afa4c4c80a302d60d486c7794370924b8515883134d5f0af08cc5bfbdb83c79d64edd1177b60062f1e8f87ba1c8e0d8719a1ad945d38d1c209fae [s] => 4a64feb499f0afc15078c2819eb26ad6ac38795c04e83c2f6dcaf7ae0f75a78a4d46105d3af61a7a0628a870c8131d400545ca5e35517e2f3a6553c38121df7b )

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] => 44bf6f9273a78ba05cec9654177d8b08ef9c6c750a97723e7f37546d3322c66e9659ebec835e0215c379412aa6afe004a793b90457472429f9e33c5acf521995 )

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

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