forked from La_Bureautique/zeg1jeux
C'est le maître des clefs
This commit is contained in:
parent
3d5f09c060
commit
57f635e02f
|
@ -15,12 +15,14 @@ class Jaklis {
|
||||||
|
|
||||||
private $msgLimit = 15;
|
private $msgLimit = 15;
|
||||||
|
|
||||||
|
private $pubsecDir = __DIR__ .'/../cache/pubsec/';
|
||||||
|
|
||||||
private $userPubsecPath;
|
private $userPubsecPath;
|
||||||
|
|
||||||
|
|
||||||
public function __construct ($userPubkey, $mode = 'local') {
|
public function __construct ($userPubkey, $mode = 'local') {
|
||||||
|
|
||||||
$this->userPubsecPath = __DIR__ .'/../cache/pubsec/'. $userPubkey .'.dunikey';
|
$this->userPubsecPath = $this->pubsecDir . $userPubkey .'.dunikey';
|
||||||
|
|
||||||
if ($this->mode != 'local') {
|
if ($this->mode != 'local') {
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,65 @@
|
||||||
|
|
||||||
class Keygen {
|
class Keygen {
|
||||||
|
|
||||||
|
private $keygenPath = __DIR__ . '/../vendors/keygen/keygen';
|
||||||
|
|
||||||
|
private $pubsecDir = __DIR__ .'/../cache/pubsec/';
|
||||||
|
|
||||||
|
private $userPubsecPath;
|
||||||
|
|
||||||
public function __construct () {
|
public function __construct () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getG1Pub ($salt, $pepper) {
|
||||||
|
|
||||||
|
$salt = str_replace('"', '\"', $salt);
|
||||||
|
$pepper = str_replace('"', '\"', $pepper);
|
||||||
|
|
||||||
|
$cmd = $this->keygenPath;
|
||||||
|
$cmd .= ' -f pubsec';
|
||||||
|
$cmd .= ' -t duniter';
|
||||||
|
$cmd .= ' "'. $salt .'"';
|
||||||
|
$cmd .= ' "'. $pepper .'"';
|
||||||
|
|
||||||
|
$output=null;
|
||||||
|
$result_code=null;
|
||||||
|
exec($cmd, $output, $result_code);
|
||||||
|
|
||||||
|
// die($cmd . '<br />'. print_r($output, true) . '<br />'. print_r($result_code, true));
|
||||||
|
|
||||||
|
if (empty($output) or empty($output[0])) {
|
||||||
|
|
||||||
|
throw new Exception('Keygen me calcule pas (la G1 pub)');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generatePubsec ($salt, $pepper) {
|
||||||
|
|
||||||
|
$salt = str_replace('"', '\"', $salt);
|
||||||
|
$pepper = str_replace('"', '\"', $pepper);
|
||||||
|
|
||||||
|
$userPubkey = $this->getG1Pub($salt, $pepper);
|
||||||
|
|
||||||
|
$cmd = $this->keygenPath;
|
||||||
|
$cmd .= ' -f pubsec';
|
||||||
|
$cmd .= ' -t duniter';
|
||||||
|
$cmd .= ' "'. $salt .'"';
|
||||||
|
$cmd .= ' "'. $pepper .'"';
|
||||||
|
$cmd .= ' -o '. $this->pubsecDir . $userPubkey . '.dunikey';
|
||||||
|
|
||||||
|
$output=null;
|
||||||
|
$result_code=null;
|
||||||
|
exec($cmd, $output, $result_code);
|
||||||
|
|
||||||
|
// die($cmd . '<br />'. print_r($result_code, true));
|
||||||
|
|
||||||
|
if ($result_code != 0) {
|
||||||
|
|
||||||
|
throw new Exception('Keygen me calcule pas (la dunikey)');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,10 @@ if (isset($_POST['salt'], $_POST['pepper'])) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$playerG1Id = $fred->donneMoiSaPutaindeG1Pub($_POST['salt'], $_POST['pepper']);
|
$playerG1Id = $fred->donneMoiSaPutaindeG1Pub($_POST['salt'], $_POST['pepper']);
|
||||||
|
$keygen->generatePubsec($_POST['salt'], $_POST['pepper']);
|
||||||
|
|
||||||
} catch (Exception $errMsg) {
|
} catch (Exception $errMsg) {
|
||||||
|
|
||||||
ErrorsHandler::kaput($errMsg);
|
ErrorsHandler::kaput($errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue