Skip to content

Commit 314ba0c

Browse files
committed
use new version openssl_encrypt (>=PHP7.1)
1 parent d2dbba0 commit 314ba0c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Encryption.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,16 @@ public static function encrypt($payload, $userPublicKey, $userAuthToken, $native
8282
// encrypt
8383
// "The additional data passed to each invocation of AEAD_AES_128_GCM is a zero-length octet sequence."
8484
if (!$nativeEncryption) {
85-
list($encryptedText, $tag) = \Jose\Util\GCM::encrypt($contentEncryptionKey, $nonce, $plaintext, null);
86-
$cipherText = $encryptedText.$tag;
85+
list($encryptedText, $tag) = \Jose\Util\GCM::encrypt($contentEncryptionKey, $nonce, $plaintext, "");
8786
} else {
88-
$cipherText = openssl_encrypt($plaintext, 'aes-128-gcm', $contentEncryptionKey, false, $nonce); // base 64 encoded
87+
$encryptedText = openssl_encrypt($plaintext, 'aes-128-gcm', $contentEncryptionKey, OPENSSL_RAW_DATA, $nonce, $tag); // base 64 encoded
8988
}
9089

9190
// return values in url safe base64
9291
return array(
9392
'localPublicKey' => Base64Url::encode($localPublicKey),
9493
'salt' => Base64Url::encode($salt),
95-
'cipherText' => $cipherText,
94+
'cipherText' => $encryptedText.$tag,
9695
);
9796
}
9897

0 commit comments

Comments
 (0)