updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -7,7 +7,7 @@
namespace Lcobucci\JWT\Signer;
use InvalidArgumentException;
use const OPENSSL_KEYTYPE_RSA;
/**
* Base class for RSASSA-PKCS1 signers
@@ -15,66 +15,10 @@ use InvalidArgumentException;
* @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>
* @since 2.1.0
*/
abstract class Rsa extends BaseSigner
abstract class Rsa extends OpenSSL
{
/**
* {@inheritdoc}
*/
public function createHash($payload, Key $key)
final public function getKeyType()
{
$key = openssl_get_privatekey($key->getContent(), $key->getPassphrase());
$this->validateKey($key);
$signature = '';
if (!openssl_sign($payload, $signature, $key, $this->getAlgorithm())) {
throw new InvalidArgumentException(
'There was an error while creating the signature: ' . openssl_error_string()
);
}
return $signature;
return OPENSSL_KEYTYPE_RSA;
}
/**
* {@inheritdoc}
*/
public function doVerify($expected, $payload, Key $key)
{
$key = openssl_get_publickey($key->getContent());
$this->validateKey($key);
return openssl_verify($payload, $expected, $key, $this->getAlgorithm()) === 1;
}
/**
* Validates if the given key is a valid RSA public/private key
*
* @param resource $key
*
* @throws InvalidArgumentException
*/
private function validateKey($key)
{
if ($key === false) {
throw new InvalidArgumentException(
'It was not possible to parse your key, reason: ' . openssl_error_string()
);
}
$details = openssl_pkey_get_details($key);
if (!isset($details['key']) || $details['type'] !== OPENSSL_KEYTYPE_RSA) {
throw new InvalidArgumentException('This key is not compatible with RSA signatures');
}
}
/**
* Returns the algorithm name
*
* @internal
*
* @return string
*/
abstract public function getAlgorithm();
}