Security: Reduce the length of the hash returned by wp_fast_hash() so it can be used in the user_activation_key field when a legacy database schema is still in use.

This reduces the hash length from 32 bytes to 30 so the overall length of an activation key after encoding, prefixing, and prepending a timestamp fits into 60 bytes.

A key is also introduced for domain separation. This doesn't affect the output length.

Props dd32, paragoninitiativeenterprises, peterwilsoncc, johnbillion

Fixes #21022
Built from https://develop.svn.wordpress.org/trunk@59904


git-svn-id: http://core.svn.wordpress.org/trunk@59246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn
2025-03-03 09:51:22 +00:00
parent 582128f4f2
commit f2de6c15ca
2 changed files with 3 additions and 2 deletions

View File

@@ -9142,7 +9142,8 @@ function wp_fast_hash(
#[\SensitiveParameter]
string $message
): string {
return '$generic$' . sodium_bin2hex( sodium_crypto_generichash( $message ) );
$hashed = sodium_crypto_generichash( $message, 'wp_fast_hash_6.8+', 30 );
return '$generic$' . sodium_bin2base64( $hashed, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING );
}
/**

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59903';
$wp_version = '6.8-alpha-59904';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.