1 | <?php |
||
12 | final class Sha256Signer implements SignInterface |
||
13 | { |
||
14 | /** |
||
15 | * |
||
16 | */ |
||
17 | private CONST SIGN_ALGORITHM = OPENSSL_ALGO_SHA256; |
||
18 | |||
19 | /** |
||
20 | * |
||
21 | */ |
||
22 | private CONST HASH_ALGORITHM = 'sha256'; |
||
23 | |||
24 | /** |
||
25 | * @var resource |
||
26 | */ |
||
27 | private $privateKey; |
||
28 | |||
29 | /** |
||
30 | * Sha256Signer constructor. |
||
31 | * @param $key |
||
32 | */ |
||
33 | 6 | public function __construct($key) |
|
41 | |||
42 | /** |
||
43 | * @param string $canonicalizedBody |
||
44 | * @return string |
||
45 | */ |
||
46 | 4 | public function hashBody(string $canonicalizedBody): string |
|
50 | |||
51 | /** |
||
52 | * @param string $canonicalizedHeaders |
||
53 | * @return string |
||
54 | * @throws \Exception |
||
55 | */ |
||
56 | 4 | public function signHeaders(string $canonicalizedHeaders): string |
|
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | 2 | public function name(): string |
|
76 | |||
77 | /** |
||
78 | * @param string $file |
||
79 | * @param string|null $passphrase |
||
80 | * @return Sha256Signer |
||
81 | * @throws \Exception |
||
82 | */ |
||
83 | 7 | public static function fromFile(string $file, string $passphrase = ''): self |
|
91 | |||
92 | /** |
||
93 | * @param string $privateKeyString |
||
94 | * @param string $passphrase |
||
95 | * @return Sha256Signer |
||
96 | * @throws \Exception |
||
97 | */ |
||
98 | 7 | public static function fromString(string $privateKeyString, string $passphrase = ''): self |
|
108 | } |