Conditions | 4 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
25 | public function verify(string $plain, string $signature): void |
||
26 | { |
||
27 | if (function_exists('sodium_crypto_sign_verify_detached')) { |
||
28 | try { |
||
29 | if (!sodium_crypto_sign_verify_detached($signature, $plain, $this->publicKey->getContent())) { |
||
30 | throw new InvalidSignatureException('Signature is to verified'); |
||
31 | } |
||
32 | } catch (SodiumException $e) { |
||
33 | throw new InvalidSignatureException('Sodium cannot verify the signature', 0, $e); |
||
34 | } |
||
35 | } else { |
||
36 | throw new RuntimeException('sodium_crypto_sign_verify_detached function is not available'); |
||
37 | } |
||
58 |