File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed
src/Library/Encryption/Algorithm/KeyEncryption Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 44
55namespace Jose \Component \Encryption \Algorithm \KeyEncryption ;
66
7+ use AESKW \Wrapper as WrapperInterface ;
78use InvalidArgumentException ;
89use Jose \Component \Core \JWK ;
910use ParagonIE \ConstantTime \Base64UrlSafe ;
@@ -20,6 +21,9 @@ public function __construct()
2021 if (! extension_loaded ('openssl ' )) {
2122 throw new RuntimeException ('Please install the OpenSSL extension ' );
2223 }
24+ if (! interface_exists (WrapperInterface::class)) {
25+ throw new RuntimeException ('Please install "spomky-labs/aes-key-wrap" to use AES-KW algorithms ' );
26+ }
2327 }
2428
2529 public function allowedKeyTypes (): array
Original file line number Diff line number Diff line change 88use InvalidArgumentException ;
99use Jose \Component \Core \JWK ;
1010use ParagonIE \ConstantTime \Base64UrlSafe ;
11+ use RuntimeException ;
1112use function in_array ;
1213use function is_string ;
1314
1415abstract class AESKW implements KeyWrapping
1516{
17+ public function __construct ()
18+ {
19+ if (! interface_exists (WrapperInterface::class)) {
20+ throw new RuntimeException ('Please install "spomky-labs/aes-key-wrap" to use AES-KW algorithms ' );
21+ }
22+ }
23+
1624 public function allowedKeyTypes (): array
1725 {
1826 return ['oct ' ];
Original file line number Diff line number Diff line change 44
55namespace Jose \Component \Encryption \Algorithm \KeyEncryption ;
66
7- use AESKW \A128KW ;
8- use AESKW \A192KW ;
9- use AESKW \A256KW ;
7+ use AESKW \Wrapper as WrapperInterface ;
8+ use RuntimeException ;
109
1110abstract class AbstractECDHAESKW implements KeyAgreementWithKeyWrapping
1211{
12+ public function __construct ()
13+ {
14+ if (! interface_exists (WrapperInterface::class)) {
15+ throw new RuntimeException ('Please install "spomky-labs/aes-key-wrap" to use AES-KW algorithms ' );
16+ }
17+ }
18+
1319 public function allowedKeyTypes (): array
1420 {
1521 return ['EC ' , 'OKP ' ];
@@ -20,7 +26,7 @@ public function getKeyManagementMode(): string
2026 return self ::MODE_WRAP ;
2127 }
2228
23- abstract protected function getWrapper (): A128KW | A192KW | A256KW ;
29+ abstract protected function getWrapper (): WrapperInterface ;
2430
2531 abstract protected function getKeyLength (): int ;
2632}
Original file line number Diff line number Diff line change 77use AESKW \A128KW ;
88use AESKW \A192KW ;
99use AESKW \A256KW ;
10+ use AESKW \Wrapper as WrapperInterface ;
1011use InvalidArgumentException ;
1112use Jose \Component \Core \JWK ;
1213use ParagonIE \ConstantTime \Base64UrlSafe ;
14+ use RuntimeException ;
1315use function in_array ;
1416use function is_int ;
1517use function is_string ;
@@ -20,6 +22,9 @@ public function __construct(
2022 private readonly int $ salt_size = 64 ,
2123 private readonly int $ nb_count = 4096
2224 ) {
25+ if (! interface_exists (WrapperInterface::class)) {
26+ throw new RuntimeException ('Please install "spomky-labs/aes-key-wrap" to use AES-KW algorithms ' );
27+ }
2328 }
2429
2530 public function allowedKeyTypes (): array
You can’t perform that action at this time.
0 commit comments