/** * Get signature algorithm identifier of given asymmetric cryptographic type * utilizing given hash algorithm. * * @param AlgorithmIdentifier $crypto_algo Cryptographic algorithm * identifier, eg. RSA or EC * @param HashAlgorithmIdentifier $hash_algo Hash algorithm identifier * @throws \UnexpectedValueException * @return SignatureAlgorithmIdentifier */ public static function algoForAsymmetricCrypto(AlgorithmIdentifier $crypto_algo, HashAlgorithmIdentifier $hash_algo) { switch ($crypto_algo->oid()) { case AlgorithmIdentifier::OID_RSA_ENCRYPTION: $oid = self::_oidForRSA($hash_algo); break; case AlgorithmIdentifier::OID_EC_PUBLIC_KEY: $oid = self::_oidForEC($hash_algo); break; default: throw new \UnexpectedValueException("Crypto algorithm " . $crypto_algo->name() . " not supported."); } $cls = AlgorithmIdentifier::MAP_OID_TO_CLASS[$oid]; return new $cls(); }