Back to Aes class

Method getExpandedKey

public string
getExpandedKey
(mixed $blockSize, mixed $iv)
Get the expanded key
Parameters
  • int $blockSize Blocksize to process
  • string $iv IV
Returns
  • string
Class: Aes
Project: Joomla

Method getExpandedKey - Source code

/**
 * Get the expanded key
 *
 * @param   integer  $blockSize  Blocksize to process
 * @param   string   $iv         IV
 *
 * @return   string
 */
public function getExpandedKey($blockSize, $iv)
{
    $key = $this->key;
    $passLength = \strlen($key);
    if (\function_exists('mb_strlen')) {
        $passLength = mb_strlen($key, 'ASCII');
    }
    if ($passLength != $blockSize) {
        $iterations = 1000;
        $salt = $this->adapter->resizeKey($iv, 16);
        $key = hash_pbkdf2('sha256', $this->key, $salt, $iterations, $blockSize, true);
    }
    return $key;
}