You are here

function _oauth_common_verify_body_hash in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 oauth_common.inc \_oauth_common_verify_body_hash()
  2. 7.3 oauth_common.inc \_oauth_common_verify_body_hash()
1 call to _oauth_common_verify_body_hash()
oauth_common_verify_request in ./oauth_common.inc
Verifies the request

File

./oauth_common.inc, line 111

Code

function _oauth_common_verify_body_hash($req) {
  $body_hash = $req
    ->get_parameter('oauth_body_hash');
  if ($body_hash && module_exists('inputstream')) {
    $hres = hash_init('sha1');
    $stream = fopen('drupal://input', 'r');
    hash_update_stream($hres, $stream);
    fclose($stream);
    $sha1 = hash_final($hres, TRUE);
    if ($sha1 !== base64_decode($body_hash)) {
      throw new OAuthException("Invalid body hash");
    }
  }
}