Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion system/libraries/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,10 @@ public function hkdf($key, $digest = 'sha512', $salt = NULL, $length = NULL, $in
return FALSE;
}

self::strlen($salt) OR $salt = str_repeat("\0", $this->_digests[$digest]);
// PHP 8.1+ deprecates passing NULL to strlen() - $salt defaults to NULL (see docblock: "Optional
// salt"), and both encrypt() and decrypt() call hkdf() with an explicit NULL salt for their HMAC key
// derivation, so this is hit on every encrypt/decrypt call, not just an edge case.
self::strlen($salt ?? '') OR $salt = str_repeat("\0", $this->_digests[$digest]);

$prk = hash_hmac($digest, $key, $salt, TRUE);
$key = '';
Expand Down