diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-09-20 15:07:40 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-09-20 15:07:40 +0200 |
| commit | 2a619ceba75a4c16b25de12d59a87eac795a4468 (patch) | |
| tree | 1d63a35217011fa761b703633b3f91fd839ec71e /wrappers/php/src/Discovery.php | |
| parent | 7e309b67de74fe5bd5a1c70c1880c2a381c4f78b (diff) | |
Remove: unused wrappers
Diffstat (limited to 'wrappers/php/src/Discovery.php')
| -rw-r--r-- | wrappers/php/src/Discovery.php | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/wrappers/php/src/Discovery.php b/wrappers/php/src/Discovery.php deleted file mode 100644 index 39aa53d..0000000 --- a/wrappers/php/src/Discovery.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php declare(strict_types=1); - -namespace EduVpn\Common; - -use EduVpn\Common\Impl\GoSlice; -use Error; -use FFI; -use InvalidArgumentException; - -final class Discovery -{ - public function __construct() { } - - const LIB_NAME = 'eduvpn_common'; - - private static ?FFI $ffi = null; - - private static function ffi(): FFI - { - if (!self::$ffi) { - if (!(self::$ffi = FFI::load(__DIR__ . '/headers/' . self::LIB_NAME . '_php.h'))) - throw new Error('failed to load ' . self::LIB_NAME); - } - return self::$ffi; - } - - /** - * Verifies the signature on the JSON server_list.json/organization_list.json file. - * If the function returns, the signature is valid for the given file type. - * - * @param string $signature .minisig signature file contents. - * @param string $signedJson Signed .json file contents. - * @param string $expectedFileName The file type to be verified, one of "server_list.json" or - * "organization_list.json". - * @param int $minSignTime Minimum time for signature (UNIX timestamp, seconds). Should be set to at least - * the time of the previous signature. - * @return void - * @throws InvalidArgumentException If expectedFileName is not one of the allowed values. - * @throws VerifyException If signature verification fails. - */ - public static function verify(string $signature, string $signedJson, string $expectedFileName, - int $minSignTime): void - { - $ffi = self::ffi(); - $signatureData = new GoSlice($ffi, $signature); - $jsonData = new GoSlice($ffi, $signedJson); - $expectedNameData = new GoSlice($ffi, $expectedFileName); - - $result = $ffi->Verify($signatureData->slice(), $jsonData->slice(), $expectedNameData->slice(), $minSignTime); - - switch ($result) { - case 0: - return; - case 1: - throw new InvalidArgumentException('unknown expected file name', $result); - case 2: - throw new InvalidSignatureException(); - case 3: - throw new InvalidSignatureUnknownKeyException(); - case 4: - throw new SignatureTooOldException(); - default: - throw new UnknownVerifyException($result); - } - } - - /** @internal Use for testing only, see Go documentation. */ - public static function insecureTestingSetExtraKey(string $keyString): void - { - $ffi = self::ffi(); - $keyData = new GoSlice($ffi, $keyString); - $ffi->InsecureTestingSetExtraKey($keyData->slice()); - } -} |
