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