46
46
*/
47
47
abstract class EncryptionBench
48
48
{
49
- private AlgorithmManager $ contentEncryptionAlgorithmsManager ;
50
-
51
- private AlgorithmManager $ keyEncryptionAlgorithmsManager ;
49
+ private AlgorithmManager $ algorithmsManager ;
52
50
53
51
private CompressionMethodManager $ compressionMethodsManager ;
54
52
55
53
private JWESerializerManager $ serializerManager ;
56
54
57
55
public function init (): void
58
56
{
59
- $ this ->keyEncryptionAlgorithmsManager = new AlgorithmManager ([
57
+ $ this ->algorithmsManager = new AlgorithmManager ([
58
+ // Key Encryption
60
59
new A128KW (),
61
60
new A192KW (),
62
61
new A256KW (),
@@ -74,8 +73,8 @@ public function init(): void
74
73
new RSA15 (),
75
74
new RSAOAEP (),
76
75
new RSAOAEP256 (),
77
- ]);
78
- $ this -> contentEncryptionAlgorithmsManager = new AlgorithmManager ([
76
+
77
+ // Content Encryption
79
78
new A128CBCHS256 (),
80
79
new A192CBCHS384 (),
81
80
new A256CBCHS512 (),
@@ -97,11 +96,7 @@ public function init(): void
97
96
*/
98
97
public function encryption (array $ params ): void
99
98
{
100
- $ jweBuilder = new JWEBuilder (
101
- $ this ->getKeyEncryptionAlgorithmsManager (),
102
- $ this ->getContentEncryptionAlgorithmsManager (),
103
- $ this ->getCompressionMethodsManager ()
104
- );
99
+ $ jweBuilder = new JWEBuilder ($ this ->getAlgorithmsManager (), $ this ->getCompressionMethodsManager ());
105
100
$ jweBuilder
106
101
->withPayload ($ params ['payload ' ])
107
102
->withAAD ($ this ->getAAD ())
@@ -118,11 +113,7 @@ public function encryption(array $params): void
118
113
*/
119
114
public function decryption (array $ params ): void
120
115
{
121
- $ jweLoader = new JWEDecrypter (
122
- $ this ->getKeyEncryptionAlgorithmsManager (),
123
- $ this ->getContentEncryptionAlgorithmsManager (),
124
- $ this ->getCompressionMethodsManager ()
125
- );
116
+ $ jweLoader = new JWEDecrypter ($ this ->getAlgorithmsManager (), $ this ->getCompressionMethodsManager ());
126
117
$ jwe = $ this ->serializerManager ->unserialize ($ params ['input ' ]);
127
118
$ keyset = JWKSet::createFromKeyData ($ params ['recipient_keys ' ]);
128
119
$ jweLoader ->decryptUsingKeySet ($ jwe , $ keyset , 0 );
@@ -143,14 +134,9 @@ abstract public function dataRecipientPublicKeys(): array;
143
134
144
135
abstract protected function getAAD (): ?string ;
145
136
146
- private function getKeyEncryptionAlgorithmsManager (): AlgorithmManager
147
- {
148
- return $ this ->keyEncryptionAlgorithmsManager ;
149
- }
150
-
151
- private function getContentEncryptionAlgorithmsManager (): AlgorithmManager
137
+ private function getAlgorithmsManager (): AlgorithmManager
152
138
{
153
- return $ this ->contentEncryptionAlgorithmsManager ;
139
+ return $ this ->algorithmsManager ;
154
140
}
155
141
156
142
private function getCompressionMethodsManager (): CompressionMethodManager
0 commit comments