You are here

function aes_make_iv in AES encryption 7

Same name and namespace in other branches
  1. 5 aes.module \aes_make_iv()
  2. 6 aes.module \aes_make_iv()

Define or set aes_encryption_iv variable.

Parameters

bool $ignore_implementation: Set FALSE to protect calling function if using phpseclib, TRUE otherwise.

3 calls to aes_make_iv()
aes_config_submit in ./aes.admin.inc
Submits aes_config form.
aes_enable in ./aes.install
Implements hook_enable().
aes_encrypt in ./aes.module
Encrypts a string.

File

./aes.module, line 444
Main file of the AES encryption module.

Code

function aes_make_iv($ignore_implementation = FALSE) {

  // Bail out if using phpseclib
  if (variable_get("aes_implementation", "mcrypt") == "phpseclib" && $ignore_implementation == FALSE) {
    watchdog("aes", "Called aes_make_iv when using phpseclib. This is harmless, but shouldn't happen.", array(), WATCHDOG_WARNING);
    return;
  }
  if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
    $randgen = MCRYPT_RAND;
    srand();
  }
  else {
    $randgen = MCRYPT_DEV_URANDOM;
  }
  $td = mcrypt_module_open_safe(variable_get("aes_cipher", "rijndael-128"), "", MCRYPT_MODE_CBC, "");
  $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), $randgen);
  mcrypt_module_close($td);
  variable_set("aes_encryption_iv", base64_encode($iv));
}