Skip to content

Commit f3dd1ef

Browse files
committed
Introduce NONCE_SALT and NONCE_KEY
git-svn-id: https://develop.svn.wordpress.org/trunk@10120 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f5b4d2b commit f3dd1ef

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

wp-config-sample.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
define('AUTH_KEY', 'put your unique phrase here');
4545
define('SECURE_AUTH_KEY', 'put your unique phrase here');
4646
define('LOGGED_IN_KEY', 'put your unique phrase here');
47+
define('NONCE_KEY', 'put your unique phrase here');
4748
/**#@-*/
4849

4950
/**

wp-includes/pluggable.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,10 +1159,10 @@ function wp_verify_nonce($nonce, $action = -1) {
11591159
$i = wp_nonce_tick();
11601160

11611161
// Nonce generated 0-12 hours ago
1162-
if ( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce )
1162+
if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
11631163
return 1;
11641164
// Nonce generated 12-24 hours ago
1165-
if ( substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce )
1165+
if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )
11661166
return 2;
11671167
// Invalid nonce
11681168
return false;
@@ -1184,7 +1184,7 @@ function wp_create_nonce($action = -1) {
11841184

11851185
$i = wp_nonce_tick();
11861186

1187-
return substr(wp_hash($i . $action . $uid), -12, 10);
1187+
return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
11881188
}
11891189
endif;
11901190

@@ -1272,6 +1272,19 @@ function wp_salt($scheme = 'auth') {
12721272
update_option('logged_in_salt', $salt);
12731273
}
12741274
}
1275+
} elseif ( 'nonce' == $scheme ) {
1276+
if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) )
1277+
$secret_key = NONCE_KEY;
1278+
1279+
if ( defined('NONCE_SALT') ) {
1280+
$salt = NONCE_SALT;
1281+
} else {
1282+
$salt = get_option('nonce_salt');
1283+
if ( empty($salt) ) {
1284+
$salt = wp_generate_password();
1285+
update_option('nonce_salt', $salt);
1286+
}
1287+
}
12751288
} else {
12761289
// ensure each auth scheme has its own unique salt
12771290
$salt = hash_hmac('md5', $scheme, $secret_key);

0 commit comments

Comments
 (0)