public static function sign(RSAKey $key, $message, $hash)
{
Assertion::string($message);
Assertion::string($hash);
Assertion::inArray($hash, ['sha256', 'sha384', 'sha512']);
$em = self::encodeEMSAPSS($message, 8 * $key->getModulusLength() - 1, Hash::$hash());
Assertion::string($em);
$message = self::convertOctetStringToInteger($em);
$signature = self::getRSASP1($key, $message);
Assertion::isInstanceOf($signature, BigInteger::class);
return self::convertIntegerToOctetString($signature, $key->getModulusLength());
}