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] => acbf03ccd80ddd965c8a3fca0cd7bdb3b80b13d4fed2ccc4aaeb4b454022336bb3fd1c0f783266b1e824e305d604635089508dfefea1054797f0d06cf5fc84e2 [s] => 616135ab757dc08d607159a57fae4e1b10b6c0d877a6a17e7d8f3c87593935e41d059d606ae8847e2c37b8377105f608566c5e333c41599a4e2428174f3d173f )

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] => 5055afdade4d008dc8dcdebc668d4cb977c3453e8a6414f2c6b2e8b5962deb381f131e2f76fdb48a36ae29aa556b4666f277c7b5ff2541c51aee0c954d8851e )

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] => a322606d4d430c8e2be2905f968a410d9e7c721aa80e83cba8e2db43d2798fac )

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