Make WordPress Core

Ticket #29518: 29518.2.diff

File 29518.2.diff, 1.6 KB (added by voldemortensen, 9 years ago)
  • src/wp-includes/pluggable.php

     
    669669        $pass_frag = substr($user->user_pass, 8, 4);
    670670
    671671        $key = wp_hash( $username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme );
     672        // Fall back to sha1 if ext/hash is unavailable.
     673        $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    672674        $hash = hash_hmac( 'sha256', $username . '|' . $expiration . '|' . $token, $key );
    673675
    674676        if ( ! hash_equals( $hash, $hmac ) ) {
     
    734736        $pass_frag = substr($user->user_pass, 8, 4);
    735737
    736738        $key = wp_hash( $user->user_login . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme );
     739        // Fall back to sha1 if ext/hash is unavailable.
     740        $algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
    737741        $hash = hash_hmac( 'sha256', $user->user_login . '|' . $expiration . '|' . $token, $key );
    738742
    739743        $cookie = $user->user_login . '|' . $expiration . '|' . $token . '|' . $hash;
  • src/wp-includes/session.php

     
    6161         * @return string A hash of the session token (a verifier).
    6262         */
    6363        final private function hash_token( $token ) {
    64                 return hash( 'sha256', $token );
     64                // Fall back to sha1 if ext/hash is unavailable.
     65                if ( function_exists( 'hash' ) ) {
     66                        return hash( 'sha256', $token );
     67                } else {
     68                        return sha1( $token );
     69                }
    6570        }
    6671
    6772        /**