WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createRsaHashed(WebCryptoAlgorithmId id, unsigned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExponentSize, WebCryptoAlgorithmId hash) { // FIXME: Verify that id is an RSA algorithm which expects a hash if (!WebCryptoAlgorithm::isHash(hash)) return WebCryptoKeyAlgorithm(); return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoRsaHashedKeyAlgorithmParams(modulusLengthBits, publicExponent, publicExponentSize, createHash(hash)))); }
WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createAes(WebCryptoAlgorithmId id, unsigned short keyLengthBits) { // FIXME: Verify that id is an AES algorithm. // FIXME: Move this somewhere more general. if (keyLengthBits != 128 && keyLengthBits != 192 && keyLengthBits != 256) return WebCryptoKeyAlgorithm(); return WebCryptoKeyAlgorithm(id, adoptPtr(new WebCryptoAesKeyAlgorithmParams(keyLengthBits))); }
WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createHmac( WebCryptoAlgorithmId hash, unsigned keyLengthBits) { if (!WebCryptoAlgorithm::isHash(hash)) return WebCryptoKeyAlgorithm(); return WebCryptoKeyAlgorithm(WebCryptoAlgorithmIdHmac, wrapUnique(new WebCryptoHmacKeyAlgorithmParams( createHash(hash), keyLengthBits))); }
WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId id, WebCryptoKeyAlgorithmParams* params) { return WebCryptoKeyAlgorithm(id, adoptPtr(params)); }
WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createWithoutParams( WebCryptoAlgorithmId id) { if (!WebCryptoAlgorithm::isKdf(id)) return WebCryptoKeyAlgorithm(); return WebCryptoKeyAlgorithm(id, nullptr); }
WebCryptoKeyAlgorithm WebCryptoKeyAlgorithm::createEc( WebCryptoAlgorithmId id, WebCryptoNamedCurve namedCurve) { return WebCryptoKeyAlgorithm( id, wrapUnique(new WebCryptoEcKeyAlgorithmParams(namedCurve))); }