Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
30 | public function verify(string $signature): bool |
||
31 | { |
||
32 | OpenSslExceptionFactory::reset(); |
||
33 | |||
34 | ob_start(); |
||
35 | |||
36 | $result = openssl_verify( |
||
37 | $this->getBufferedData(), |
||
38 | @pack('H*', $signature), |
||
39 | $this->getKey() |
||
40 | ); |
||
41 | |||
42 | $error = trim(ob_get_clean()); |
||
43 | |||
44 | if (-1 === $result) { |
||
45 | throw OpenSslExceptionFactory::createForLastError(); |
||
46 | } |
||
47 | if (!empty($error)) { |
||
48 | throw new RuntimeException($error); |
||
49 | } |
||
50 | |||
51 | return 1 === $result; |
||
52 | } |
||
54 |