diff -r e88534039a8d -r 2b6cdff92b09 install/includes/stages/login.php --- a/install/includes/stages/login.php Tue Apr 06 10:46:25 2010 -0400 +++ b/install/includes/stages/login.php Tue Apr 06 15:54:45 2010 -0400 @@ -20,39 +20,24 @@ require_once( ENANO_ROOT . '/includes/rijndael.php' ); require_once( ENANO_ROOT . '/includes/constants.php' ); require_once( ENANO_ROOT . '/includes/dbal.php' ); - -// Write our temporary password key to the database -require( ENANO_ROOT . '/config.new.php' ); -if ( !defined('ENANO_INSTALL_HAVE_CONFIG') ) -{ - die('Config file is corrupt'); -} -$db = new $dbdriver(); -$result = $db->connect(); -if ( !$result ) - die('DB privileges were revoked'); - -// Is the key in the database? -$q = $db->sql_query('SELECT config_value FROM ' . table_prefix . 'config WHERE config_name = \'install_aes_key\';'); -if ( !$q ) - $db->_die(); -if ( $db->numrows() > 0 ) -{ - list($install_aes_key) = $db->fetchrow_num(); -} -else -{ - $aes = AESCrypt::singleton(AES_BITS, AES_BLOCKSIZE); - $install_aes_key = $aes->gen_readymade_key(); - - if ( ! $db->sql_query('INSERT INTO ' . table_prefix . 'config ( config_name, config_value ) VALUES ( \'install_aes_key\', \'' . $install_aes_key .'\' ); ') ) - $db->_die(); -} -$db->free_result($q); +require_once( ENANO_ROOT . '/includes/sessions.php' ); $ui->add_header(''); $ui->show_header(); +// generate the HTML for the form, and store the public and private key in the temporary config +$aes_form = sessionManager::generate_aes_form($dh_keys); +$fp = @fopen(ENANO_ROOT . '/config.new.php', 'a+'); +if ( !$fp ) + die('Couldn\'t open the config for writing'); +fwrite($fp, " +// DiffieHellman parameters +\$dh_public = '{$dh_keys['public']}'; +\$dh_private = '{$dh_keys['private']}'; +\$aes_fallback = '{$dh_keys['aes']}'; +"); +fclose($fp); + // FIXME: l10n ?>