You are here

function _acquia_search_hmac in Acquia Search 6

Calculates a HMAC-SHA1 of a data string.

See RFC2104 (http://www.ietf.org/rfc/rfc2104.txt). Note, the result of this must be identical to using hash_hmac('sha1', $string, $key); We don't use that function since PHP can be missing it if it was compiled with the --disable-hash switch. However, the hash extension is enabled by default as of PHP 5.1.2, so we should consider requiring it and using the built-in function since it is a little faster (~1.5x).

4 calls to _acquia_search_hmac()
AcquiaSearchTest::testHMAC in tests/acquia_search.test
acquia_search_authenticator in ./acquia_search.module
Creates an authenticator based on a data string and HMAC-SHA1.
acquia_search_valid_response in ./acquia_search.module
Validate the authenticity of returned data using a nonce and HMAC-SHA1.
_acquia_search_derived_key in ./acquia_search.module
Derive a key for the solr hmac using the information shared with acquia.com.

File

./acquia_search.module, line 385
Integration between Acquia Drupal and Acquia's hosted solr search service.

Code

function _acquia_search_hmac($key, $string) {
  return sha1((str_pad($key, 64, chr(0x0)) ^ str_repeat(chr(0x5c), 64)) . pack("H*", sha1((str_pad($key, 64, chr(0x0)) ^ str_repeat(chr(0x36), 64)) . $string)));
}