You are here

private static function LockrAes128CtrSha256KeyWrapper::doEncrypt in Lockr 7.3

2 calls to LockrAes128CtrSha256KeyWrapper::doEncrypt()
LockrAes128CtrSha256KeyWrapper::encrypt in vendor/lockr/lockr/src/KeyWrapper/LockrAes128CtrSha256KeyWrapper.php
Encrypt the given plaintext.
LockrAes128CtrSha256KeyWrapper::reencrypt in vendor/lockr/lockr/src/KeyWrapper/LockrAes128CtrSha256KeyWrapper.php
Encrypt the given plaintext reusing state.

File

vendor/lockr/lockr/src/KeyWrapper/LockrAes128CtrSha256KeyWrapper.php, line 80

Class

LockrAes128CtrSha256KeyWrapper

Namespace

Lockr\KeyWrapper

Code

private static function doEncrypt($plaintext, $key, $iv, $hmac_key) {
  $ciphertext = openssl_encrypt($plaintext, self::METHOD, $key, OPENSSL_RAW_DATA, $iv);
  $hmac = self::hmac($ciphertext, $hmac_key);
  return [
    'ciphertext' => base64_encode($hmac) . base64_encode($ciphertext),
    'encoded' => self::encode($key, $iv, $hmac_key),
  ];
}