private function getOpenSslAlgorithm(string $algorithm) : int
    {
        switch ($algorithm) {
            case Algorithms::RSA_SHA256:
                return OPENSSL_ALGO_SHA256;
            case Algorithms::RSA_SHA384:
                return OPENSSL_ALGO_SHA384;
            case Algorithms::RSA_SHA512:
                return OPENSSL_ALGO_SHA512;
            default:
                throw new InvalidArgumentException("Algorithm \"$algorithm\" is not an OpenSSL algorithm");
        }
    }