$t('AES encryption implementation'), 'value' => $value, 'severity' => $requirement_severity, ); return $requirements; } function aes_get_available_aes_implementations() { if (module_exists('libraries') && libraries_get_path('phpseclib')) { $phpsec_include_path = libraries_get_path('phpseclib'); } else { $phpsec_include_path = dirname(__FILE__) . '/phpseclib'; } set_include_path(get_include_path() . PATH_SEPARATOR . $phpsec_include_path); $phpsec_available = TRUE; if (file_exists($phpsec_include_path . '/Crypt/AES.php') === FALSE) { $phpsec_available = FALSE; } else { if (is_readable($phpsec_include_path . '/Crypt/AES.php') === FALSE) { $phpsec_available = FALSE; } } if (extension_loaded("mcrypt")) { $mcrypt_available = TRUE; } else { $mcrypt_available = FALSE; } return array('mcrypt' => $mcrypt_available, 'phpseclib' => $phpsec_available); } function aes_install() { $t = get_t(); variable_set("aes_key_storage_method", "Database"); variable_set("aes_cipher", "rijndael-128"); variable_set("aes_convert", FALSE); variable_set("aes_viewing_method", "collapsible"); $aes_implementations = aes_get_available_aes_implementations(); if ($aes_implementations['mcrypt']) { variable_set("aes_implementation", "mcrypt"); $install_msg = $t("AES installed using the Mcrypt implementation."); } else { if ($aes_implementations['phpseclib']) { variable_set("aes_implementation", "phpseclib"); $install_msg = $t("AES installed using the phpseclib implementation."); } else { // This case shouldn't actually be possible since hook_requirements should stop the installation if there's no implementation. variable_set("aes_implementation", "missing"); $install_msg = $t("AES installed without any implementation!"); } } drupal_set_message($install_msg); } /** * Implements hook_schema(). */ function aes_schema() { $schema['aes_passwords'] = array( 'fields' => array( 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'pass' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), ), 'primary key' => array('uid'), ); return $schema; } /** * Implements hook_uninstall(). */ function aes_uninstall() { // Delete keyfile. if (variable_get("aes_key_storage_method", "") == "File") { unlink(variable_get("aes_key_path", "")); } //delete variables variable_del("aes_key"); variable_del("aes_convert"); variable_del("aes_key_storage_method"); variable_del("aes_key_path"); variable_del("aes_key"); variable_del("aes_encryption_iv"); variable_del("aes_cipher"); variable_del("aes_viewing_method"); variable_del("aes_implementation"); drupal_set_message(t("AES uninstalled.")); } /** * Convert old setting for aes_convert from string to boolean. */ function aes_update_7100(&$sandbox) { $old_value = variable_get("aes_convert", FALSE); if (is_string($old_value)) { $old_value = strtolower($old_value); $new_value = ($old_value === 'true'); } else { $new_value = (bool) $old_value; } variable_set("aes_convert", $new_value); }