drupal_valid_test_ua($user_agent)Validate the HMAC and timestamp of a user agent header from simpletest.
includes/bootstrap.inc, line 1987
<?php
function drupal_valid_test_ua($user_agent) {
global $databases;
list($prefix, $time, $salt, $hmac) = explode(';', $user_agent);
$check_string = $prefix . ';' . $time . ';' . $salt;
// We use the database credentials from settings.php to make the HMAC key, since
// the database is not yet initialized and we can't access any Drupal variables.
// The file properties add more entropy not easily accessible to others.
$filepath = DRUPAL_ROOT . '/includes/bootstrap.inc';
$key = sha1(serialize($databases) . filectime($filepath) . fileinode($filepath), TRUE);
// The HMAC must match.
return $hmac == base64_encode(hash_hmac('sha1', $check_string, $key, TRUE));
}
?>