|
@@ 348-356 (lines=9) @@
|
| 345 |
|
* @throws \RuntimeException If encrypt fails |
| 346 |
|
* @return string |
| 347 |
|
*/ |
| 348 |
|
protected function _encrypt($kek, $block) { |
| 349 |
|
$str = openssl_encrypt($block, $this->_cipherMethod(), $kek, |
| 350 |
|
OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); |
| 351 |
|
if (false === $str) { |
| 352 |
|
throw new \RuntimeException( |
| 353 |
|
"openssl_encrypt() failed: " . $this->_getLastOpenSSLError()); |
| 354 |
|
} |
| 355 |
|
return $str; |
| 356 |
|
} |
| 357 |
|
|
| 358 |
|
/** |
| 359 |
|
* Apply AES-1(K, W) operation (decrypt) to 64 bit block. |
|
@@ 366-374 (lines=9) @@
|
| 363 |
|
* @throws \RuntimeException If decrypt fails |
| 364 |
|
* @return string |
| 365 |
|
*/ |
| 366 |
|
protected function _decrypt($kek, $block) { |
| 367 |
|
$str = openssl_decrypt($block, $this->_cipherMethod(), $kek, |
| 368 |
|
OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING); |
| 369 |
|
if (false === $str) { |
| 370 |
|
throw new \RuntimeException( |
| 371 |
|
"openssl_decrypt() failed: " . $this->_getLastOpenSSLError()); |
| 372 |
|
} |
| 373 |
|
return $str; |
| 374 |
|
} |
| 375 |
|
|
| 376 |
|
/** |
| 377 |
|
* Get latest OpenSSL error message. |