JSCryptoAlgorithmDictionary.cpp [plain text]
#include "config.h"
#include "JSCryptoAlgorithmDictionary.h"
#if ENABLE(SUBTLE_CRYPTO)
#include "CryptoAlgorithmAesCbcParams.h"
#include "CryptoAlgorithmAesKeyGenParams.h"
#include "CryptoAlgorithmHmacKeyParams.h"
#include "CryptoAlgorithmHmacParams.h"
#include "CryptoAlgorithmRegistry.h"
#include "CryptoAlgorithmRsaKeyGenParams.h"
#include "CryptoAlgorithmRsaKeyParamsWithHash.h"
#include "CryptoAlgorithmRsaOaepParams.h"
#include "CryptoAlgorithmRsaSsaParams.h"
#include "ExceptionCode.h"
#include "JSCryptoOperationData.h"
#include "JSDOMBinding.h"
#include "JSDOMConvert.h"
#include "JSDictionary.h"
using namespace JSC;
namespace WebCore {
enum class HashRequirement {
Optional,
Required,
};
bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier)
{
String algorithmName;
if (value.isString())
algorithmName = value.toString(exec)->value(exec);
else if (value.isObject()) {
if (value.getObject()->inherits(StringObject::info()))
algorithmName = asString(asStringObject(value)->internalValue())->value(exec);
else {
JSDictionary dictionary(exec, value.getObject());
dictionary.get("name", algorithmName);
}
}
if (exec->hadException())
return false;
if (!algorithmName.containsOnlyASCII()) {
throwSyntaxError(exec);
return false;
}
if (!CryptoAlgorithmRegistry::singleton().getIdentifierForName(algorithmName, algorithmIdentifier)) {
setDOMException(exec, NOT_SUPPORTED_ERR);
return false;
}
return true;
}
static JSValue getProperty(ExecState* exec, JSObject* object, const char* name)
{
return object->get(exec, Identifier::fromString(exec, name));
}
static bool getHashAlgorithm(JSDictionary& dictionary, CryptoAlgorithmIdentifier& result, HashRequirement isRequired)
{
ExecState* exec = dictionary.execState();
JSObject* object = dictionary.initializerObject();
Identifier identifier = Identifier::fromString(exec, "hash");
JSValue hash = getProperty(exec, object, "hash");
if (exec->hadException())
return false;
if (hash.isUndefinedOrNull()) {
if (isRequired == HashRequirement::Required)
setDOMException(exec, NOT_SUPPORTED_ERR);
return false;
}
return JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(exec, hash, result);
}
static RefPtr<CryptoAlgorithmParameters> createAesCbcParams(ExecState* exec, JSValue value)
{
if (!value.isObject()) {
throwTypeError(exec);
return nullptr;
}
JSValue iv = getProperty(exec, value.getObject(), "iv");
if (exec->hadException())
return nullptr;
auto result = adoptRef(*new CryptoAlgorithmAesCbcParams);
CryptoOperationData ivData;
if (!cryptoOperationDataFromJSValue(exec, iv, ivData)) {
ASSERT(exec->hadException());
return nullptr;
}
if (ivData.second != 16) {
exec->vm().throwException(exec, createError(exec, "AES-CBC initialization data must be 16 bytes"));
return nullptr;
}
memcpy(result->iv.data(), ivData.first, ivData.second);
return WTFMove(result);
}
static RefPtr<CryptoAlgorithmParameters> createAesKeyGenParams(ExecState& state, JSValue value)
{
if (!value.isObject()) {
throwTypeError(&state);
return nullptr;
}
auto result = adoptRef(*new CryptoAlgorithmAesKeyGenParams);
JSValue lengthValue = getProperty(&state, value.getObject(), "length");
if (state.hadException())
return nullptr;
result->length = convert<uint16_t>(state, lengthValue, EnforceRange);
return WTFMove(result);
}
static RefPtr<CryptoAlgorithmParameters> createHmacParams(ExecState& state, JSValue value)
{
if (!value.isObject()) {
throwTypeError(&state);
return nullptr;
}
JSDictionary jsDictionary(&state, value.getObject());
auto result = adoptRef(*new CryptoAlgorithmHmacParams);
if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
ASSERT(state.hadException());
return nullptr;
}
return WTFMove(result);
}
static RefPtr<CryptoAlgorithmParameters> createHmacKeyParams(ExecState& state, JSValue value)
{
if (!value.isObject()) {
throwTypeError(&state);
return nullptr;
}
JSDictionary jsDictionary(&state, value.getObject());
auto result = adoptRef(*new CryptoAlgorithmHmacKeyParams);
if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
ASSERT(state.hadException());
return nullptr;
}
result->hasLength = jsDictionary.get("length", result->length);
if (state.hadException())
return nullptr;
return WTFMove(result);
}
static RefPtr<CryptoAlgorithmParameters> createRsaKeyGenParams(ExecState& state, JSValue value)
{
if (!value.isObject()) {
throwTypeError(&state);
return nullptr;
}
JSDictionary jsDictionary(&state, value.getObject());
auto result = adoptRef(*new CryptoAlgorithmRsaKeyGenParams);
JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength");
if (state.hadException())
return nullptr;
result->modulusLength = convert<uint32_t>(state, modulusLengthValue, NormalConversion);
if (state.hadException())
return nullptr;
JSValue publicExponentValue = getProperty(&state, value.getObject(), "publicExponent");
if (state.hadException())
return nullptr;
RefPtr<Uint8Array> publicExponentArray = toUint8Array(publicExponentValue);
if (!publicExponentArray) {
throwTypeError(&state, "Expected a Uint8Array in publicExponent");
return nullptr;
}
result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength());
result->hasHash = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Optional);
return WTFMove(result);
}
static RefPtr<CryptoAlgorithmParameters> createRsaKeyParamsWithHash(ExecState&, JSValue)
{
return adoptRef(*new CryptoAlgorithmRsaKeyParamsWithHash);
}
static RefPtr<CryptoAlgorithmParameters> createRsaOaepParams(ExecState* exec, JSValue value)
{
if (!value.isObject()) {
throwTypeError(exec);
return nullptr;
}
JSDictionary jsDictionary(exec, value.getObject());
auto result = adoptRef(*new CryptoAlgorithmRsaOaepParams);
if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
ASSERT(exec->hadException());
return nullptr;
}
JSValue labelValue = getProperty(exec, value.getObject(), "label");
if (exec->hadException())
return nullptr;
result->hasLabel = !labelValue.isUndefinedOrNull();
if (!result->hasLabel)
return WTFMove(result);
CryptoOperationData labelData;
if (!cryptoOperationDataFromJSValue(exec, labelValue, labelData)) {
ASSERT(exec->hadException());
return nullptr;
}
result->label.append(labelData.first, labelData.second);
return WTFMove(result);
}
static RefPtr<CryptoAlgorithmParameters> createRsaSsaParams(ExecState& state, JSValue value)
{
if (!value.isObject()) {
throwTypeError(&state);
return nullptr;
}
JSDictionary jsDictionary(&state, value.getObject());
auto result = adoptRef(*new CryptoAlgorithmRsaSsaParams);
if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
ASSERT(state.hadException());
return nullptr;
}
return WTFMove(result);
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForEncrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::RSA_OAEP:
return createRsaOaepParams(exec, value);
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::AES_CBC:
return createAesCbcParams(exec, value);
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::AES_KW:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::HMAC:
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDecrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::RSA_OAEP:
return createRsaOaepParams(exec, value);
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::AES_CBC:
return createAesCbcParams(exec, value);
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::AES_KW:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::HMAC:
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForSign(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
return createRsaSsaParams(*exec, value);
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::HMAC:
return createHmacParams(*exec, value);
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForVerify(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
return createRsaSsaParams(*exec, value);
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::HMAC:
return createHmacParams(*exec, value);
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDigest(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
case CryptoAlgorithmIdentifier::HMAC:
case CryptoAlgorithmIdentifier::DH:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
return createRsaKeyGenParams(*exec, value);
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
return createAesKeyGenParams(*exec, value);
case CryptoAlgorithmIdentifier::HMAC:
return createHmacKeyParams(*exec, value);
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
case CryptoAlgorithmIdentifier::HMAC:
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
case CryptoAlgorithmIdentifier::HMAC:
case CryptoAlgorithmIdentifier::DH:
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
return createRsaKeyParamsWithHash(*exec, value);
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::HMAC:
return createHmacParams(*exec, value);
case CryptoAlgorithmIdentifier::DH:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
{
switch (algorithm) {
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
case CryptoAlgorithmIdentifier::RSA_PSS:
case CryptoAlgorithmIdentifier::RSA_OAEP:
case CryptoAlgorithmIdentifier::ECDSA:
case CryptoAlgorithmIdentifier::ECDH:
case CryptoAlgorithmIdentifier::AES_CTR:
case CryptoAlgorithmIdentifier::AES_CBC:
case CryptoAlgorithmIdentifier::AES_CMAC:
case CryptoAlgorithmIdentifier::AES_GCM:
case CryptoAlgorithmIdentifier::AES_CFB:
case CryptoAlgorithmIdentifier::AES_KW:
case CryptoAlgorithmIdentifier::HMAC:
case CryptoAlgorithmIdentifier::DH:
return adoptRef(*new CryptoAlgorithmParameters);
case CryptoAlgorithmIdentifier::SHA_1:
case CryptoAlgorithmIdentifier::SHA_224:
case CryptoAlgorithmIdentifier::SHA_256:
case CryptoAlgorithmIdentifier::SHA_384:
case CryptoAlgorithmIdentifier::SHA_512:
case CryptoAlgorithmIdentifier::CONCAT:
case CryptoAlgorithmIdentifier::HKDF_CTR:
case CryptoAlgorithmIdentifier::PBKDF2:
setDOMException(exec, NOT_SUPPORTED_ERR);
return nullptr;
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
}
#endif // ENABLE(SUBTLE_CRYPTO)