4646 */
4747abstract class EncryptionBench
4848{
49- private AlgorithmManager $ contentEncryptionAlgorithmsManager ;
50-
51- private AlgorithmManager $ keyEncryptionAlgorithmsManager ;
49+ private AlgorithmManager $ algorithmsManager ;
5250
5351 private CompressionMethodManager $ compressionMethodsManager ;
5452
5553 private JWESerializerManager $ serializerManager ;
5654
5755 public function init (): void
5856 {
59- $ this ->keyEncryptionAlgorithmsManager = new AlgorithmManager ([
57+ $ this ->algorithmsManager = new AlgorithmManager ([
58+ // Key Encryption
6059 new A128KW (),
6160 new A192KW (),
6261 new A256KW (),
@@ -74,8 +73,8 @@ public function init(): void
7473 new RSA15 (),
7574 new RSAOAEP (),
7675 new RSAOAEP256 (),
77- ]);
78- $ this -> contentEncryptionAlgorithmsManager = new AlgorithmManager ([
76+
77+ // Content Encryption
7978 new A128CBCHS256 (),
8079 new A192CBCHS384 (),
8180 new A256CBCHS512 (),
@@ -97,11 +96,7 @@ public function init(): void
9796 */
9897 public function encryption (array $ params ): void
9998 {
100- $ jweBuilder = new JWEBuilder (
101- $ this ->getKeyEncryptionAlgorithmsManager (),
102- $ this ->getContentEncryptionAlgorithmsManager (),
103- $ this ->getCompressionMethodsManager ()
104- );
99+ $ jweBuilder = new JWEBuilder ($ this ->getAlgorithmsManager (), $ this ->getCompressionMethodsManager ());
105100 $ jweBuilder
106101 ->withPayload ($ params ['payload ' ])
107102 ->withAAD ($ this ->getAAD ())
@@ -118,11 +113,7 @@ public function encryption(array $params): void
118113 */
119114 public function decryption (array $ params ): void
120115 {
121- $ jweLoader = new JWEDecrypter (
122- $ this ->getKeyEncryptionAlgorithmsManager (),
123- $ this ->getContentEncryptionAlgorithmsManager (),
124- $ this ->getCompressionMethodsManager ()
125- );
116+ $ jweLoader = new JWEDecrypter ($ this ->getAlgorithmsManager (), $ this ->getCompressionMethodsManager ());
126117 $ jwe = $ this ->serializerManager ->unserialize ($ params ['input ' ]);
127118 $ keyset = JWKSet::createFromKeyData ($ params ['recipient_keys ' ]);
128119 $ jweLoader ->decryptUsingKeySet ($ jwe , $ keyset , 0 );
@@ -143,14 +134,9 @@ abstract public function dataRecipientPublicKeys(): array;
143134
144135 abstract protected function getAAD (): ?string ;
145136
146- private function getKeyEncryptionAlgorithmsManager (): AlgorithmManager
147- {
148- return $ this ->keyEncryptionAlgorithmsManager ;
149- }
150-
151- private function getContentEncryptionAlgorithmsManager (): AlgorithmManager
137+ private function getAlgorithmsManager (): AlgorithmManager
152138 {
153- return $ this ->contentEncryptionAlgorithmsManager ;
139+ return $ this ->algorithmsManager ;
154140 }
155141
156142 private function getCompressionMethodsManager (): CompressionMethodManager
0 commit comments