enabling sha512

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/251/head
Maxence Lange 2018-12-20 15:51:09 -01:00
rodzic df4fbf9589
commit b5b5690ab8
1 zmienionych plików z 17 dodań i 6 usunięć

Wyświetl plik

@ -269,13 +269,8 @@ class SignatureService {
$signed = base64_decode($sign['signature']);
$estimated = $this->generateEstimatedSignature($headers, $request);
$algorithm = 'sha256';
if ($this->get('algorithm', $sign, '') === 'rsa-sha256') {
$algorithm = 'sha256';
}
$publicKey = $this->retrieveKey($keyId);
$algorithm = $this->getAlgorithmFromSignature($sign);
if ($publicKey === ''
|| openssl_verify($estimated, $signed, $publicKey, $algorithm) !== 1) {
throw new SignatureException('signature cannot be checked');
@ -371,4 +366,20 @@ class SignatureService {
}
/**
* @param array $sign
*
* @return string
*/
private function getAlgorithmFromSignature(array $sign): string {
switch ($this->get('algorithm', $sign, '')) {
case 'rsa-sha512':
return 'sha512';
default:
return 'sha256';
}
}
}