Skip to content

Commit 0f75469

Browse files
authored
Do not load KW algorithms if the dependency is not available (#520)
Do not load KW algorithms if the dependency is not available
1 parent cf7700f commit 0f75469

File tree

4 files changed

+74
-62
lines changed

4 files changed

+74
-62
lines changed

src/Bundle/Resources/config/Algorithms/encryption_aesgcmkw.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use AESKW\Wrapper;
56
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128GCMKW;
67
use Jose\Component\Encryption\Algorithm\KeyEncryption\A192GCMKW;
78
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256GCMKW;
@@ -14,18 +15,20 @@
1415
->autoconfigure()
1516
->autowire();
1617

17-
$container->set(A128GCMKW::class)
18-
->tag('jose.algorithm', [
19-
'alias' => 'A128GCMKW',
20-
]);
18+
if (interface_exists(Wrapper::class)) {
19+
$container->set(A128GCMKW::class)
20+
->tag('jose.algorithm', [
21+
'alias' => 'A128GCMKW',
22+
]);
2123

22-
$container->set(A192GCMKW::class)
23-
->tag('jose.algorithm', [
24-
'alias' => 'A192GCMKW',
25-
]);
24+
$container->set(A192GCMKW::class)
25+
->tag('jose.algorithm', [
26+
'alias' => 'A192GCMKW',
27+
]);
2628

27-
$container->set(A256GCMKW::class)
28-
->tag('jose.algorithm', [
29-
'alias' => 'A256GCMKW',
30-
]);
29+
$container->set(A256GCMKW::class)
30+
->tag('jose.algorithm', [
31+
'alias' => 'A256GCMKW',
32+
]);
33+
}
3134
};

src/Bundle/Resources/config/Algorithms/encryption_aeskw.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use AESKW\Wrapper;
56
use Jose\Component\Encryption\Algorithm\KeyEncryption\A128KW;
67
use Jose\Component\Encryption\Algorithm\KeyEncryption\A192KW;
78
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW;
@@ -14,18 +15,20 @@
1415
->autoconfigure()
1516
->autowire();
1617

17-
$container->set(A128KW::class)
18-
->tag('jose.algorithm', [
19-
'alias' => 'A128KW',
20-
]);
18+
if (interface_exists(Wrapper::class)) {
19+
$container->set(A128KW::class)
20+
->tag('jose.algorithm', [
21+
'alias' => 'A128KW',
22+
]);
2123

22-
$container->set(A192KW::class)
23-
->tag('jose.algorithm', [
24-
'alias' => 'A192KW',
25-
]);
24+
$container->set(A192KW::class)
25+
->tag('jose.algorithm', [
26+
'alias' => 'A192KW',
27+
]);
2628

27-
$container->set(A256KW::class)
28-
->tag('jose.algorithm', [
29-
'alias' => 'A256KW',
30-
]);
29+
$container->set(A256KW::class)
30+
->tag('jose.algorithm', [
31+
'alias' => 'A256KW',
32+
]);
33+
}
3134
};

src/Bundle/Resources/config/Algorithms/encryption_ecdhes.php

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use AESKW\Wrapper;
56
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHES;
67
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA128KW;
78
use Jose\Component\Encryption\Algorithm\KeyEncryption\ECDHESA192KW;
@@ -24,38 +25,40 @@
2425
'alias' => 'ECDH-ES',
2526
]);
2627

27-
$container->set(ECDHESA128KW::class)
28+
$container->set(ECDHSS::class)
2829
->tag('jose.algorithm', [
29-
'alias' => 'ECDH-ES+A128KW',
30+
'alias' => 'ECDH-SS',
3031
]);
3132

32-
$container->set(ECDHESA192KW::class)
33-
->tag('jose.algorithm', [
34-
'alias' => 'ECDH-ES+A192KW',
35-
]);
33+
if (interface_exists(Wrapper::class)) {
34+
$container->set(ECDHESA128KW::class)
35+
->tag('jose.algorithm', [
36+
'alias' => 'ECDH-ES+A128KW',
37+
]);
3638

37-
$container->set(ECDHESA256KW::class)
38-
->tag('jose.algorithm', [
39-
'alias' => 'ECDH-ES+A256KW',
40-
]);
39+
$container->set(ECDHESA192KW::class)
40+
->tag('jose.algorithm', [
41+
'alias' => 'ECDH-ES+A192KW',
42+
]);
4143

42-
$container->set(ECDHSS::class)
43-
->tag('jose.algorithm', [
44-
'alias' => 'ECDH-SS',
45-
]);
44+
$container->set(ECDHESA256KW::class)
45+
->tag('jose.algorithm', [
46+
'alias' => 'ECDH-ES+A256KW',
47+
]);
4648

47-
$container->set(ECDHSSA128KW::class)
48-
->tag('jose.algorithm', [
49-
'alias' => 'ECDH-SS+A128KW',
50-
]);
49+
$container->set(ECDHSSA128KW::class)
50+
->tag('jose.algorithm', [
51+
'alias' => 'ECDH-SS+A128KW',
52+
]);
5153

52-
$container->set(ECDHSSA192KW::class)
53-
->tag('jose.algorithm', [
54-
'alias' => 'ECDH-SS+A192KW',
55-
]);
54+
$container->set(ECDHSSA192KW::class)
55+
->tag('jose.algorithm', [
56+
'alias' => 'ECDH-SS+A192KW',
57+
]);
5658

57-
$container->set(ECDHSSA256KW::class)
58-
->tag('jose.algorithm', [
59-
'alias' => 'ECDH-SS+A256KW',
60-
]);
59+
$container->set(ECDHSSA256KW::class)
60+
->tag('jose.algorithm', [
61+
'alias' => 'ECDH-SS+A256KW',
62+
]);
63+
}
6164
};

src/Bundle/Resources/config/Algorithms/encryption_pbes2.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use AESKW\Wrapper;
56
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW;
67
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS384A192KW;
78
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS512A256KW;
@@ -14,18 +15,20 @@
1415
->autoconfigure()
1516
->autowire();
1617

17-
$container->set(PBES2HS256A128KW::class)
18-
->tag('jose.algorithm', [
19-
'alias' => 'PBES2-HS256+A128KW',
20-
]);
18+
if (interface_exists(Wrapper::class)) {
19+
$container->set(PBES2HS256A128KW::class)
20+
->tag('jose.algorithm', [
21+
'alias' => 'PBES2-HS256+A128KW',
22+
]);
2123

22-
$container->set(PBES2HS384A192KW::class)
23-
->tag('jose.algorithm', [
24-
'alias' => 'PBES2-HS384+A192KW',
25-
]);
24+
$container->set(PBES2HS384A192KW::class)
25+
->tag('jose.algorithm', [
26+
'alias' => 'PBES2-HS384+A192KW',
27+
]);
2628

27-
$container->set(PBES2HS512A256KW::class)
28-
->tag('jose.algorithm', [
29-
'alias' => 'PBES2-HS512+A256KW',
30-
]);
29+
$container->set(PBES2HS512A256KW::class)
30+
->tag('jose.algorithm', [
31+
'alias' => 'PBES2-HS512+A256KW',
32+
]);
33+
}
3134
};

0 commit comments

Comments
 (0)