Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit a525296

Browse files
committed
Clean-up
1 parent 3d2ff68 commit a525296

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Developer/Encryption/FieldLevelEncryption.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,19 @@ private static function readAndDeleteJsonKey($object, $key) {
241241
}
242242

243243
private static function encryptBytes($key, $iv, $bytes) {
244-
return openssl_encrypt($bytes, self::SYMMETRIC_CYPHER, $key, OPENSSL_RAW_DATA, $iv);
244+
$encryptedBytes = openssl_encrypt($bytes, self::SYMMETRIC_CYPHER, $key, OPENSSL_RAW_DATA, $iv);
245+
if (false === $encryptedBytes) {
246+
throw new EncryptionException('Failed to encrypt bytes!');
247+
}
248+
return $encryptedBytes;
245249
}
246250

247-
private static function decryptBytes($key, $iv, $bytes) {
248-
return openssl_decrypt($bytes, self::SYMMETRIC_CYPHER, $key, OPENSSL_RAW_DATA, $iv);
251+
private static function decryptBytes($key, $iv, $encryptedBytes) {
252+
$bytes = openssl_decrypt($encryptedBytes, self::SYMMETRIC_CYPHER, $key, OPENSSL_RAW_DATA, $iv);
253+
if (false === $bytes) {
254+
throw new EncryptionException('Failed to decrypt bytes with the provided key and IV!');
255+
}
256+
return $bytes;
249257
}
250258

251259
private static function sanitizeJson($json) {

src/Developer/Encryption/FieldLevelEncryptionParams.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct($config, $ivValue, $encryptedKeyValue,
3636

3737
/**
3838
* Generate encryption parameters.
39-
* @param $config a FieldLevelEncryptionConfig instance
39+
* @param $config A FieldLevelEncryptionConfig instance
4040
* @return FieldLevelEncryptionParams
4141
* @throws EncryptionException
4242
*/

0 commit comments

Comments
 (0)