You are here

function aes_make_iv in AES encryption 6

Same name and namespace in other branches
  1. 5 aes.module \aes_make_iv()
  2. 7 aes.module \aes_make_iv()
3 calls to aes_make_iv()
aes_config_submit in ./aes.module
aes_enable in ./aes.module
aes_encrypt in ./aes.module
aes_encrypt

File

./aes.module, line 545

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;
  }
  else {
    $randgen = MCRYPT_DEV_URANDOM;
  }
  $td = mcrypt_module_open(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));
}