function __construct($I, $P, $mul) { parent::__construct($I, $P); $this->A = gmp_strval(gmp_mul($this->N, "{$mul}"), 16); }
parent::__construct($I, $P); $this->a = gmp_random(); $this->A = gmp_strval(gmp_powm($this->g, $this->a, $this->N), 16); } function setSalt($salt) { $this->salt = $salt; $this->x = gmp_init(hash('sha256', $salt . $this->P), 16); } function getA() { return $this->A; } function setB($B) { $this->B = gmp_init($B, 16); $this->u = gmp_init(hash('sha256', $this->A . $B), 16); $this->S = gmp_powm(gmp_sub($this->B, gmp_mul($this->k, gmp_powm($this->g, $this->x, $this->N))), gmp_add($this->a, gmp_mul($this->u, $this->x)), $this->N); } } // don't output if we're included into another script. if (!debug_backtrace()) { $I = 'email'; $P = 'password'; $S = new SRPServer($I, $P); $C = new SRPClient($I, $P); $C->setSalt($S->getSalt()); $S->setA($C->getA()); $C->setB($S->getB()); print $S->getProof() === $C->getProof() ? "OK\n\n" : "Not OK :(\n\n"; }