| @@ 47-56 (lines=10) @@ | ||
| 44 | * @param string|resource $privateKey |
|
| 45 | * @return string |
|
| 46 | */ |
|
| 47 | public function sign($value, $privateKey) |
|
| 48 | { |
|
| 49 | $result = openssl_sign($value, $signature, $privateKey, $this->getAlgorithm()); |
|
| 50 | ||
| 51 | if (false === $result) { |
|
| 52 | throw new \RuntimeException('Failed to encrypt value. ' . implode("\n", $this->getSslErrors())); |
|
| 53 | } |
|
| 54 | ||
| 55 | return $signature; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @param string $value |
|
| @@ 64-73 (lines=10) @@ | ||
| 61 | * @param string|resource $publicKey |
|
| 62 | * @return boolean |
|
| 63 | */ |
|
| 64 | public function verify($value, $signature, $publicKey) |
|
| 65 | { |
|
| 66 | $result = openssl_verify($value, $signature, $publicKey, $this->getAlgorithm()); |
|
| 67 | ||
| 68 | if ($result === -1) { |
|
| 69 | throw new \RuntimeException('Failed to verify signature. ' . implode("\n", $this->getSslErrors())); |
|
| 70 | } |
|
| 71 | ||
| 72 | return (boolean)$result; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @return integer |
|