1 | <?php |
||
8 | final class Sha256Signer implements SignInterface |
||
9 | { |
||
10 | private const SIGN_ALGORITHM = OPENSSL_ALGO_SHA256; |
||
11 | |||
12 | private const HASH_ALGORITHM = 'sha256'; |
||
13 | |||
14 | /** |
||
15 | * @var resource |
||
16 | */ |
||
17 | private $privateKey; |
||
18 | |||
19 | /** |
||
20 | * @param resource $key |
||
21 | */ |
||
22 | 6 | public function __construct($key) |
|
30 | |||
31 | /** |
||
32 | * @param string $canonicalizedBody |
||
33 | * @return string |
||
34 | */ |
||
35 | 4 | public function hashBody(string $canonicalizedBody): string |
|
39 | |||
40 | /** |
||
41 | * @param string $canonicalizedHeaders |
||
42 | * @return string |
||
43 | * @throws \Exception |
||
44 | */ |
||
45 | 4 | public function signHeaders(string $canonicalizedHeaders): string |
|
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | 2 | public function name(): string |
|
65 | |||
66 | /** |
||
67 | * @param string $file |
||
68 | * @param string $passphrase |
||
69 | * @return Sha256Signer |
||
70 | * @throws \Exception |
||
71 | */ |
||
72 | 7 | public static function fromFile(string $file, string $passphrase = ''): self |
|
85 | |||
86 | /** |
||
87 | * @param string $privateKeyString |
||
88 | * @param string $passphrase |
||
89 | * @return Sha256Signer |
||
90 | * @throws \Exception |
||
91 | */ |
||
92 | 7 | public static function fromString(string $privateKeyString, string $passphrase = ''): self |
|
102 | } |
||
103 |