@@ -967,7 +967,8 @@ protected function encryptAndSign(Key $userKey, array $device, int $id, INotific
967967 $ this ->printInfo ('Device public key size: ' . strlen ($ device ['devicepublickey ' ]));
968968 $ this ->printInfo ('Data to encrypt is: ' . json_encode ($ data ));
969969
970- if (!openssl_public_encrypt (json_encode ($ data ), $ encryptedSubject , $ device ['devicepublickey ' ], OPENSSL_PKCS1_PADDING )) {
970+ $ padding = $ this ->appConfig ->getAppValueString ('push_encryption_padding ' , 'PKCS1 ' ) === 'OAEP ' ? OPENSSL_PKCS1_OAEP_PADDING : OPENSSL_PKCS1_PADDING ;
971+ if (!openssl_public_encrypt (json_encode ($ data ), $ encryptedSubject , $ device ['devicepublickey ' ], $ padding )) {
971972 $ error = openssl_error_string ();
972973 $ this ->log ->error ($ error , ['app ' => 'notifications ' ]);
973974 $ this ->printInfo ('<error>Error while encrypting data: " ' . $ error . '"</error> ' );
@@ -1006,7 +1007,8 @@ protected function encryptAndSignDelete(Key $userKey, array $device, ?array $ids
10061007 $ remainingIds = $ ret ['remaining ' ];
10071008 $ data = $ ret ['data ' ];
10081009
1009- if (!openssl_public_encrypt (json_encode ($ data ), $ encryptedSubject , $ device ['devicepublickey ' ], OPENSSL_PKCS1_PADDING )) {
1010+ $ padding = $ this ->appConfig ->getAppValueString ('push_encryption_padding ' , 'PKCS1 ' ) === 'OAEP ' ? OPENSSL_PKCS1_OAEP_PADDING : OPENSSL_PKCS1_PADDING ;
1011+ if (!openssl_public_encrypt (json_encode ($ data ), $ encryptedSubject , $ device ['devicepublickey ' ], $ padding )) {
10101012 $ this ->log ->error (openssl_error_string (), ['app ' => 'notifications ' ]);
10111013 throw new \InvalidArgumentException ('Failed to encrypt message for device ' );
10121014 }
0 commit comments