public static function LockrAes128CtrSha256KeyWrapper::decrypt in Lockr 7.3
Same name and namespace in other branches
- 7.2 vendor/lockr/lockr-client/src/KeyWrapper/LockrAes128CtrSha256KeyWrapper.php \Lockr\KeyWrapper\LockrAes128CtrSha256KeyWrapper::decrypt()
Decrypt the given ciphertext.
Parameters
string $ciphertext:
string $wrapping_key:
Return value
string|bool
Overrides KeyWrapperInterface::decrypt
2 calls to LockrAes128CtrSha256KeyWrapper::decrypt()
- LockrAes128CtrSha256KeyWrapperTest::testEncryptsData in vendor/
lockr/ lockr/ tests/ KeyWrapper/ LockrAes128CtrSha256KeyWrapperTest.php - LockrAes128CtrSha256KeyWrapperTest::testReencryptsData in vendor/
lockr/ lockr/ tests/ KeyWrapper/ LockrAes128CtrSha256KeyWrapperTest.php
File
- vendor/
lockr/ lockr/ src/ KeyWrapper/ LockrAes128CtrSha256KeyWrapper.php, line 50
Class
Namespace
Lockr\KeyWrapperCode
public static function decrypt($ciphertext, $wrapping_key) {
$parts = self::decode($wrapping_key);
if (!$parts) {
return false;
}
list($key, $iv, $hmac_key) = $parts;
$hmac = base64_decode(substr($ciphertext, 0, self::HASH_BYTES));
$ciphertext = base64_decode(substr($ciphertext, self::HASH_BYTES));
if (!hash_equals($hmac, self::hmac($ciphertext, $hmac_key))) {
return false;
}
$plaintext = openssl_decrypt($ciphertext, self::METHOD, $key, OPENSSL_RAW_DATA, $iv);
if ($plaintext === false) {
return false;
}
return $plaintext;
}