fallback sha256 openssl_verify code for php releases prior to 5.3
This commit is contained in:
parent
112fc59e31
commit
5a5a7bfc4c
1 changed files with 6 additions and 3 deletions
|
@ -202,14 +202,17 @@ function receive_post(&$a) {
|
|||
receive_return(400);
|
||||
}
|
||||
|
||||
$verify = false;
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
$verify = openssl_verify($signed_data,$signature,$key,'sha256');
|
||||
}
|
||||
else {
|
||||
// FIXME
|
||||
// fallback sha256 verify for PHP < 5.3
|
||||
|
||||
$rawsig = '';
|
||||
$hash = hash('sha256',$signed_data,true);
|
||||
openssl_public_decrypt($signature,$rawsig,$key);
|
||||
$verify = (($rawsig && substr($rawsig,-32) === $hash) ? true : false);
|
||||
}
|
||||
|
||||
if(! $verify) {
|
||||
|
|
Loading…
Reference in a new issue