Skip to content

Commit 415ccee

Browse files
author
Ian Barber
committed
Use SHA256 constant when available
Should help with HHVM, re googleapis#153
1 parent 170a793 commit 415ccee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Google/Signer/P12.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public function sign($data)
8282
"PHP 5.3.0 or higher is required to use service accounts."
8383
);
8484
}
85-
if (!openssl_sign($data, $signature, $this->privateKey, "sha256")) {
85+
$hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
86+
if (!openssl_sign($data, $signature, $this->privateKey, $hash)) {
8687
throw new Google_Auth_Exception("Unable to sign data");
8788
}
8889
return $signature;

src/Google/Verifier/Pem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function __destruct()
6464
*/
6565
public function verify($data, $signature)
6666
{
67-
$status = openssl_verify($data, $signature, $this->publicKey, "sha256");
67+
$hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
68+
$status = openssl_verify($data, $signature, $this->publicKey, $hash);
6869
if ($status === -1) {
6970
throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string());
7071
}

0 commit comments

Comments
 (0)