function _acquia_agent_hmac in Acquia Connector 6.2
Same name and namespace in other branches
- 6 acquia_agent/acquia_agent_streams.inc \_acquia_agent_hmac()
- 7.3 acquia_agent/acquia_agent.module \_acquia_agent_hmac()
- 7 acquia_agent/acquia_agent.module \_acquia_agent_hmac()
- 7.2 acquia_agent/acquia_agent.module \_acquia_agent_hmac()
Calculates a HMAC-SHA1 according to RFC2104 (http://www.ietf.org/rfc/rfc2104.txt). With addition of xmlrpc params.
3 calls to _acquia_agent_hmac()
- acquia_agent_valid_response in acquia_agent/
acquia_agent_streams.inc - Determine if a response from Acquia is valid.
- _acquia_agent_authenticator in acquia_agent/
acquia_agent_streams.inc - Creates an authenticator based on xmlrpc params and a HMAC-SHA1.
- _acquia_agent_create_authenticator in acquia_agent/
acquia_agent.pages.inc - Helper function. Creates an authenticator for xmlrpc calls
File
- acquia_agent/
acquia_agent_streams.inc, line 344 - XML-RPC communication functions for Acquia communication.
Code
function _acquia_agent_hmac($key, $time, $nonce, $params) {
if (empty($params['rpc_version']) || $params['rpc_version'] < 2) {
$encoded_params = serialize($params);
$string = $time . ':' . $nonce . ':' . $key . ':' . $encoded_params;
return base64_encode(pack("H*", 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)))));
}
elseif ($params['rpc_version'] == 2) {
$encoded_params = json_encode($params);
$string = $time . ':' . $nonce . ':' . $encoded_params;
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)));
}
else {
$string = $time . ':' . $nonce;
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)));
}
}