Changeset 209900 in webkit


Ignore:
Timestamp:
Dec 15, 2016 7:01:14 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[WebIDL] Remove use of Dictionary from JSCryptoAlgorithmDictionary
https://bugs.webkit.org/show_bug.cgi?id=165919

Patch by Sam Weinig <sam@webkit.org> on 2016-12-15
Reviewed by Darin Adler.

  • bindings/js/JSCryptoAlgorithmDictionary.cpp:
  • bindings/js/JSCryptoAlgorithmDictionary.h:
  • bindings/js/JSCryptoOperationData.cpp:
  • bindings/js/JSCryptoOperationData.h:
  • bindings/js/JSWebKitSubtleCryptoCustom.cpp:

Replace simplistic use of Dictionary with simplistic use of direct JSObject
functions. Also, pass the ExecState by reference.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r209897 r209900  
     12016-12-15  Sam Weinig  <sam@webkit.org>
     2
     3        [WebIDL] Remove use of Dictionary from JSCryptoAlgorithmDictionary
     4        https://bugs.webkit.org/show_bug.cgi?id=165919
     5
     6        Reviewed by Darin Adler.
     7
     8        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
     9        * bindings/js/JSCryptoAlgorithmDictionary.h:
     10        * bindings/js/JSCryptoOperationData.cpp:
     11        * bindings/js/JSCryptoOperationData.h:
     12        * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
     13        Replace simplistic use of Dictionary with simplistic use of direct JSObject
     14        functions. Also, pass the ExecState by reference.
     15
    1162016-12-15  Filip Pizlo  <fpizlo@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

    r209801 r209900  
    3333#include "CryptoAlgorithmHmacKeyParamsDeprecated.h"
    3434#include "CryptoAlgorithmHmacParamsDeprecated.h"
     35#include "CryptoAlgorithmParameters.h"
    3536#include "CryptoAlgorithmRegistry.h"
    3637#include "CryptoAlgorithmRsaKeyGenParamsDeprecated.h"
     
    3839#include "CryptoAlgorithmRsaOaepParamsDeprecated.h"
    3940#include "CryptoAlgorithmRsaSsaParamsDeprecated.h"
    40 #include "Dictionary.h"
    4141#include "ExceptionCode.h"
    4242#include "JSCryptoOperationData.h"
     
    5353};
    5454
    55 bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier)
    56 {
    57     VM& vm = exec->vm();
    58     auto scope = DECLARE_THROW_SCOPE(vm);
     55static inline JSValue getProperty(ExecState& state, JSObject* object, const char* name)
     56{
     57    return object->get(&state, Identifier::fromString(&state, name));
     58}
     59
     60bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState& state, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier)
     61{
     62    auto scope = DECLARE_THROW_SCOPE(state.vm());
    5963
    6064    // typedef (Algorithm or DOMString) AlgorithmIdentifier;
     
    6266    String algorithmName;
    6367
    64     if (value.isString())
    65         algorithmName = value.toWTFString(exec);
    66     else if (value.isObject()) {
    67         if (value.getObject()->inherits(StringObject::info()))
    68             algorithmName = asString(asStringObject(value)->internalValue())->value(exec);
    69         else {
     68    if (value.isString()) {
     69        algorithmName = value.toWTFString(&state);
     70        RETURN_IF_EXCEPTION(scope, false);
     71    } else if (value.isObject()) {
     72        if (asObject(value)->inherits(StringObject::info())) {
     73            algorithmName = asString(asStringObject(value)->internalValue())->value(&state);
     74            RETURN_IF_EXCEPTION(scope, false);
     75        } else {
    7076            // FIXME: This doesn't perform some checks mandated by WebIDL for dictionaries:
    7177            // - null and undefined input should be treated as if all elements in the dictionary were undefined;
     
    7682            // WebCrypto doesn't yet clearly specify what to do with non-present values in most cases anyway.
    7783
    78             Dictionary dictionary(exec, value.getObject());
    79             dictionary.get("name", algorithmName);
     84            auto nameValue = getProperty(state, asObject(value), "name");
     85            RETURN_IF_EXCEPTION(scope, false);
     86
     87            algorithmName = convert<IDLDOMString>(state, nameValue);
     88            RETURN_IF_EXCEPTION(scope, false);
    8089        }
    8190    }
    8291
    83     RETURN_IF_EXCEPTION(scope, false);
    84 
    8592    if (!algorithmName.containsOnlyASCII()) {
    86         throwSyntaxError(exec, scope);
     93        throwSyntaxError(&state, scope);
    8794        return false;
    8895    }
     
    9097    auto identifier = CryptoAlgorithmRegistry::singleton().identifier(algorithmName);
    9198    if (!identifier) {
    92         setDOMException(exec, NOT_SUPPORTED_ERR);
     99        setDOMException(&state, NOT_SUPPORTED_ERR);
    93100        return false;
    94101    }
     
    98105}
    99106
    100 static JSValue getProperty(ExecState* exec, JSObject* object, const char* name)
    101 {
    102     return object->get(exec, Identifier::fromString(exec, name));
    103 }
    104 
    105 static bool getHashAlgorithm(Dictionary& dictionary, CryptoAlgorithmIdentifier& result, HashRequirement isRequired)
    106 {
    107     // FIXME: Teach Dictionary how to return JSValues, and use that to get hash element value.
    108 
    109     ExecState* exec = dictionary.execState();
    110     VM& vm = exec->vm();
    111     auto scope = DECLARE_THROW_SCOPE(vm);
    112     JSObject* object = dictionary.initializerObject();
    113 
    114     Identifier identifier = Identifier::fromString(exec, "hash");
    115 
    116     JSValue hash = getProperty(exec, object, "hash");
     107static bool getHashAlgorithm(ExecState& state, JSObject* object, CryptoAlgorithmIdentifier& result, HashRequirement isRequired)
     108{
     109    auto scope = DECLARE_THROW_SCOPE(state.vm());
     110
     111    auto hash = getProperty(state, object, "hash");
    117112    RETURN_IF_EXCEPTION(scope, false);
    118113
    119114    if (hash.isUndefinedOrNull()) {
    120115        if (isRequired == HashRequirement::Required)
    121             setDOMException(exec, NOT_SUPPORTED_ERR);
     116            setDOMException(&state, NOT_SUPPORTED_ERR);
    122117        return false;
    123118    }
    124119
    125     return JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(exec, hash, result);
    126 }
    127 
    128 static RefPtr<CryptoAlgorithmParametersDeprecated> createAesCbcParams(ExecState* exec, JSValue value)
    129 {
    130     VM& vm = exec->vm();
    131     auto scope = DECLARE_THROW_SCOPE(vm);
     120    return JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(state, hash, result);
     121}
     122
     123static RefPtr<CryptoAlgorithmParametersDeprecated> createAesCbcParams(ExecState& state, JSValue value)
     124{
     125    auto scope = DECLARE_THROW_SCOPE(state.vm());
    132126
    133127    if (!value.isObject()) {
    134         throwTypeError(exec, scope);
    135         return nullptr;
    136     }
    137 
    138     JSValue iv = getProperty(exec, value.getObject(), "iv");
     128        throwTypeError(&state, scope);
     129        return nullptr;
     130    }
     131
     132    auto iv = getProperty(state, asObject(value), "iv");
    139133    RETURN_IF_EXCEPTION(scope, nullptr);
    140134
     
    142136
    143137    CryptoOperationData ivData;
    144     auto success = cryptoOperationDataFromJSValue(exec, iv, ivData);
     138    auto success = cryptoOperationDataFromJSValue(state, iv, ivData);
    145139    ASSERT(scope.exception() || success);
    146140    if (!success)
     
    148142
    149143    if (ivData.second != 16) {
    150         throwException(exec, scope, createError(exec, "AES-CBC initialization data must be 16 bytes"));
     144        throwException(&state, scope, createError(&state, "AES-CBC initialization data must be 16 bytes"));
    151145        return nullptr;
    152146    }
     
    159153static RefPtr<CryptoAlgorithmParametersDeprecated> createAesKeyGenParams(ExecState& state, JSValue value)
    160154{
    161     VM& vm = state.vm();
    162     auto scope = DECLARE_THROW_SCOPE(vm);
     155    auto scope = DECLARE_THROW_SCOPE(state.vm());
    163156
    164157    if (!value.isObject()) {
     
    169162    auto result = adoptRef(*new CryptoAlgorithmAesKeyGenParamsDeprecated);
    170163
    171     JSValue lengthValue = getProperty(&state, value.getObject(), "length");
     164    auto lengthValue = getProperty(state, asObject(value), "length");
    172165    RETURN_IF_EXCEPTION(scope, nullptr);
    173166
     
    179172static RefPtr<CryptoAlgorithmParametersDeprecated> createHmacParams(ExecState& state, JSValue value)
    180173{
    181     VM& vm = state.vm();
    182     auto scope = DECLARE_THROW_SCOPE(vm);
     174    auto scope = DECLARE_THROW_SCOPE(state.vm());
    183175
    184176    if (!value.isObject()) {
     
    187179    }
    188180
    189     Dictionary dictionary(&state, value.getObject());
    190181    auto result = adoptRef(*new CryptoAlgorithmHmacParamsDeprecated);
    191182
    192     auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     183    auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required);
    193184    ASSERT_UNUSED(scope, scope.exception() || success);
    194185    if (!success)
     
    200191static RefPtr<CryptoAlgorithmParametersDeprecated> createHmacKeyParams(ExecState& state, JSValue value)
    201192{
    202     VM& vm = state.vm();
    203     auto scope = DECLARE_THROW_SCOPE(vm);
     193    auto scope = DECLARE_THROW_SCOPE(state.vm());
    204194
    205195    if (!value.isObject()) {
     
    208198    }
    209199
    210     Dictionary dictionary(&state, value.getObject());
    211200    auto result = adoptRef(*new CryptoAlgorithmHmacKeyParamsDeprecated);
    212201
    213     auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     202    auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required);
    214203    ASSERT(scope.exception() || success);
    215204    if (!success)
    216205        return nullptr;
    217206
    218     result->hasLength = dictionary.get("length", result->length);
    219     RETURN_IF_EXCEPTION(scope, nullptr);
     207    auto lengthValue = getProperty(state, asObject(value), "length");
     208    RETURN_IF_EXCEPTION(scope, nullptr);
     209
     210    result->length = convert<IDLUnsignedShort>(state, lengthValue, IntegerConversionConfiguration::Normal);
     211    RETURN_IF_EXCEPTION(scope, nullptr);
     212
     213    result->hasLength = true;
    220214
    221215    return WTFMove(result);
     
    224218static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaKeyGenParams(ExecState& state, JSValue value)
    225219{
    226     VM& vm = state.vm();
    227     auto scope = DECLARE_THROW_SCOPE(vm);
     220    auto scope = DECLARE_THROW_SCOPE(state.vm());
    228221
    229222    if (!value.isObject()) {
     
    232225    }
    233226
    234     Dictionary dictionary(&state, value.getObject());
    235227    auto result = adoptRef(*new CryptoAlgorithmRsaKeyGenParamsDeprecated);
    236228
    237     JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength");
     229    auto modulusLengthValue = getProperty(state, asObject(value), "modulusLength");
    238230    RETURN_IF_EXCEPTION(scope, nullptr);
    239231
     
    242234    RETURN_IF_EXCEPTION(scope, nullptr);
    243235
    244     JSValue publicExponentValue = getProperty(&state, value.getObject(), "publicExponent");
    245     RETURN_IF_EXCEPTION(scope, nullptr);
    246 
    247     RefPtr<Uint8Array> publicExponentArray = toUnsharedUint8Array(publicExponentValue);
     236    auto publicExponentValue = getProperty(state, asObject(value), "publicExponent");
     237    RETURN_IF_EXCEPTION(scope, nullptr);
     238
     239    auto publicExponentArray = toUnsharedUint8Array(publicExponentValue);
    248240    if (!publicExponentArray) {
    249241        throwTypeError(&state, scope, ASCIILiteral("Expected a Uint8Array in publicExponent"));
     
    252244    result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength());
    253245
    254     result->hasHash = getHashAlgorithm(dictionary, result->hash, HashRequirement::Optional);
     246    result->hasHash = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Optional);
    255247
    256248    return WTFMove(result);
     
    263255}
    264256
    265 static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaOaepParams(ExecState* exec, JSValue value)
    266 {
    267     VM& vm = exec->vm();
    268     auto scope = DECLARE_THROW_SCOPE(vm);
     257static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaOaepParams(ExecState& state, JSValue value)
     258{
     259    auto scope = DECLARE_THROW_SCOPE(state.vm());
    269260
    270261    if (!value.isObject()) {
    271         throwTypeError(exec, scope);
    272         return nullptr;
    273     }
    274 
    275     Dictionary dictionary(exec, value.getObject());
     262        throwTypeError(&state, scope);
     263        return nullptr;
     264    }
     265
    276266    auto result = adoptRef(*new CryptoAlgorithmRsaOaepParamsDeprecated);
    277267
    278     auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     268    auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required);
    279269    ASSERT(scope.exception() || success);
    280270    if (!success)
    281271        return nullptr;
    282272
    283     JSValue labelValue = getProperty(exec, value.getObject(), "label");
     273    auto labelValue = getProperty(state, asObject(value), "label");
    284274    RETURN_IF_EXCEPTION(scope, nullptr);
    285275
     
    289279
    290280    CryptoOperationData labelData;
    291     success = cryptoOperationDataFromJSValue(exec, labelValue, labelData);
     281    success = cryptoOperationDataFromJSValue(state, labelValue, labelData);
    292282    ASSERT(scope.exception() || success);
    293283    if (!success)
     
    301291static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaSsaParams(ExecState& state, JSValue value)
    302292{
    303     VM& vm = state.vm();
    304     auto scope = DECLARE_THROW_SCOPE(vm);
     293    auto scope = DECLARE_THROW_SCOPE(state.vm());
    305294
    306295    if (!value.isObject()) {
     
    309298    }
    310299
    311     Dictionary dictionary(&state, value.getObject());
    312300    auto result = adoptRef(*new CryptoAlgorithmRsaSsaParamsDeprecated);
    313301
    314     auto success = getHashAlgorithm(dictionary, result->hash, HashRequirement::Required);
     302    auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required);
    315303    ASSERT(scope.exception() || success);
    316304    if (!success)
     
    320308}
    321309
    322 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForEncrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
    323 {
    324     switch (algorithm) {
    325     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    326         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    327     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    328     case CryptoAlgorithmIdentifier::RSA_PSS:
    329         setDOMException(exec, NOT_SUPPORTED_ERR);
    330         return nullptr;
    331     case CryptoAlgorithmIdentifier::RSA_OAEP:
    332         return createRsaOaepParams(exec, value);
    333     case CryptoAlgorithmIdentifier::ECDSA:
    334     case CryptoAlgorithmIdentifier::ECDH:
    335     case CryptoAlgorithmIdentifier::AES_CTR:
    336         setDOMException(exec, NOT_SUPPORTED_ERR);
    337         return nullptr;
    338     case CryptoAlgorithmIdentifier::AES_CBC:
    339         return createAesCbcParams(exec, value);
    340     case CryptoAlgorithmIdentifier::AES_CMAC:
    341     case CryptoAlgorithmIdentifier::AES_GCM:
    342     case CryptoAlgorithmIdentifier::AES_CFB:
    343         setDOMException(exec, NOT_SUPPORTED_ERR);
    344         return nullptr;
    345     case CryptoAlgorithmIdentifier::AES_KW:
    346         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    347     case CryptoAlgorithmIdentifier::HMAC:
    348     case CryptoAlgorithmIdentifier::DH:
    349     case CryptoAlgorithmIdentifier::SHA_1:
    350     case CryptoAlgorithmIdentifier::SHA_224:
    351     case CryptoAlgorithmIdentifier::SHA_256:
    352     case CryptoAlgorithmIdentifier::SHA_384:
    353     case CryptoAlgorithmIdentifier::SHA_512:
    354     case CryptoAlgorithmIdentifier::CONCAT:
    355     case CryptoAlgorithmIdentifier::HKDF_CTR:
    356     case CryptoAlgorithmIdentifier::PBKDF2:
    357         setDOMException(exec, NOT_SUPPORTED_ERR);
    358         return nullptr;
    359     }
    360     RELEASE_ASSERT_NOT_REACHED();
    361     return nullptr;
    362 }
    363 
    364 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDecrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
    365 {
    366     switch (algorithm) {
    367     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    368         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    369     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    370     case CryptoAlgorithmIdentifier::RSA_PSS:
    371         setDOMException(exec, NOT_SUPPORTED_ERR);
    372         return nullptr;
    373     case CryptoAlgorithmIdentifier::RSA_OAEP:
    374         return createRsaOaepParams(exec, value);
    375     case CryptoAlgorithmIdentifier::ECDSA:
    376     case CryptoAlgorithmIdentifier::ECDH:
    377     case CryptoAlgorithmIdentifier::AES_CTR:
    378         setDOMException(exec, NOT_SUPPORTED_ERR);
    379         return nullptr;
    380     case CryptoAlgorithmIdentifier::AES_CBC:
    381         return createAesCbcParams(exec, value);
    382     case CryptoAlgorithmIdentifier::AES_CMAC:
    383     case CryptoAlgorithmIdentifier::AES_GCM:
    384     case CryptoAlgorithmIdentifier::AES_CFB:
    385         setDOMException(exec, NOT_SUPPORTED_ERR);
    386         return nullptr;
    387     case CryptoAlgorithmIdentifier::AES_KW:
    388         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    389     case CryptoAlgorithmIdentifier::HMAC:
    390     case CryptoAlgorithmIdentifier::DH:
    391     case CryptoAlgorithmIdentifier::SHA_1:
    392     case CryptoAlgorithmIdentifier::SHA_224:
    393     case CryptoAlgorithmIdentifier::SHA_256:
    394     case CryptoAlgorithmIdentifier::SHA_384:
    395     case CryptoAlgorithmIdentifier::SHA_512:
    396     case CryptoAlgorithmIdentifier::CONCAT:
    397     case CryptoAlgorithmIdentifier::HKDF_CTR:
    398     case CryptoAlgorithmIdentifier::PBKDF2:
    399         setDOMException(exec, NOT_SUPPORTED_ERR);
    400         return nullptr;
    401     }
    402     RELEASE_ASSERT_NOT_REACHED();
    403     return nullptr;
    404 }
    405 
    406 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForSign(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
    407 {
    408     switch (algorithm) {
    409     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    410         setDOMException(exec, NOT_SUPPORTED_ERR);
    411         return nullptr;
    412     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    413         return createRsaSsaParams(*exec, value);
    414     case CryptoAlgorithmIdentifier::RSA_PSS:
    415     case CryptoAlgorithmIdentifier::RSA_OAEP:
    416     case CryptoAlgorithmIdentifier::ECDSA:
    417     case CryptoAlgorithmIdentifier::ECDH:
    418     case CryptoAlgorithmIdentifier::AES_CTR:
    419     case CryptoAlgorithmIdentifier::AES_CBC:
    420     case CryptoAlgorithmIdentifier::AES_CMAC:
    421     case CryptoAlgorithmIdentifier::AES_GCM:
    422     case CryptoAlgorithmIdentifier::AES_CFB:
    423     case CryptoAlgorithmIdentifier::AES_KW:
    424         setDOMException(exec, NOT_SUPPORTED_ERR);
    425         return nullptr;
    426     case CryptoAlgorithmIdentifier::HMAC:
    427         return createHmacParams(*exec, value);
    428     case CryptoAlgorithmIdentifier::DH:
    429     case CryptoAlgorithmIdentifier::SHA_1:
    430     case CryptoAlgorithmIdentifier::SHA_224:
    431     case CryptoAlgorithmIdentifier::SHA_256:
    432     case CryptoAlgorithmIdentifier::SHA_384:
    433     case CryptoAlgorithmIdentifier::SHA_512:
    434     case CryptoAlgorithmIdentifier::CONCAT:
    435     case CryptoAlgorithmIdentifier::HKDF_CTR:
    436     case CryptoAlgorithmIdentifier::PBKDF2:
    437         setDOMException(exec, NOT_SUPPORTED_ERR);
    438         return nullptr;
    439     }
    440     RELEASE_ASSERT_NOT_REACHED();
    441     return nullptr;
    442 }
    443 
    444 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForVerify(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
    445 {
    446     switch (algorithm) {
    447     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    448         setDOMException(exec, NOT_SUPPORTED_ERR);
    449         return nullptr;
    450     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    451         return createRsaSsaParams(*exec, value);
    452     case CryptoAlgorithmIdentifier::RSA_PSS:
    453     case CryptoAlgorithmIdentifier::RSA_OAEP:
    454     case CryptoAlgorithmIdentifier::ECDSA:
    455     case CryptoAlgorithmIdentifier::ECDH:
    456     case CryptoAlgorithmIdentifier::AES_CTR:
    457     case CryptoAlgorithmIdentifier::AES_CBC:
    458     case CryptoAlgorithmIdentifier::AES_CMAC:
    459     case CryptoAlgorithmIdentifier::AES_GCM:
    460     case CryptoAlgorithmIdentifier::AES_CFB:
    461     case CryptoAlgorithmIdentifier::AES_KW:
    462         setDOMException(exec, NOT_SUPPORTED_ERR);
    463         return nullptr;
    464     case CryptoAlgorithmIdentifier::HMAC:
    465         return createHmacParams(*exec, value);
    466     case CryptoAlgorithmIdentifier::DH:
    467     case CryptoAlgorithmIdentifier::SHA_1:
    468     case CryptoAlgorithmIdentifier::SHA_224:
    469     case CryptoAlgorithmIdentifier::SHA_256:
    470     case CryptoAlgorithmIdentifier::SHA_384:
    471     case CryptoAlgorithmIdentifier::SHA_512:
    472     case CryptoAlgorithmIdentifier::CONCAT:
    473     case CryptoAlgorithmIdentifier::HKDF_CTR:
    474     case CryptoAlgorithmIdentifier::PBKDF2:
    475         setDOMException(exec, NOT_SUPPORTED_ERR);
    476         return nullptr;
    477     }
    478     RELEASE_ASSERT_NOT_REACHED();
    479     return nullptr;
    480 }
    481 
    482 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDigest(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
    483 {
    484     switch (algorithm) {
    485     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    486     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    487     case CryptoAlgorithmIdentifier::RSA_PSS:
    488     case CryptoAlgorithmIdentifier::RSA_OAEP:
    489     case CryptoAlgorithmIdentifier::ECDSA:
    490     case CryptoAlgorithmIdentifier::ECDH:
    491     case CryptoAlgorithmIdentifier::AES_CTR:
    492     case CryptoAlgorithmIdentifier::AES_CBC:
    493     case CryptoAlgorithmIdentifier::AES_CMAC:
    494     case CryptoAlgorithmIdentifier::AES_GCM:
    495     case CryptoAlgorithmIdentifier::AES_CFB:
    496     case CryptoAlgorithmIdentifier::AES_KW:
    497     case CryptoAlgorithmIdentifier::HMAC:
    498     case CryptoAlgorithmIdentifier::DH:
    499         setDOMException(exec, NOT_SUPPORTED_ERR);
    500         return nullptr;
    501     case CryptoAlgorithmIdentifier::SHA_1:
    502     case CryptoAlgorithmIdentifier::SHA_224:
    503     case CryptoAlgorithmIdentifier::SHA_256:
    504     case CryptoAlgorithmIdentifier::SHA_384:
    505     case CryptoAlgorithmIdentifier::SHA_512:
    506         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    507     case CryptoAlgorithmIdentifier::CONCAT:
    508     case CryptoAlgorithmIdentifier::HKDF_CTR:
    509     case CryptoAlgorithmIdentifier::PBKDF2:
    510         setDOMException(exec, NOT_SUPPORTED_ERR);
    511         return nullptr;
    512     }
    513     RELEASE_ASSERT_NOT_REACHED();
    514     return nullptr;
    515 }
    516 
    517 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
    518 {
    519     switch (algorithm) {
    520     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    521     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    522     case CryptoAlgorithmIdentifier::RSA_PSS:
    523     case CryptoAlgorithmIdentifier::RSA_OAEP:
    524         return createRsaKeyGenParams(*exec, value);
    525     case CryptoAlgorithmIdentifier::ECDSA:
    526     case CryptoAlgorithmIdentifier::ECDH:
    527         setDOMException(exec, NOT_SUPPORTED_ERR);
    528         return nullptr;
    529     case CryptoAlgorithmIdentifier::AES_CTR:
    530     case CryptoAlgorithmIdentifier::AES_CBC:
    531     case CryptoAlgorithmIdentifier::AES_CMAC:
    532     case CryptoAlgorithmIdentifier::AES_GCM:
    533     case CryptoAlgorithmIdentifier::AES_CFB:
    534     case CryptoAlgorithmIdentifier::AES_KW:
    535         return createAesKeyGenParams(*exec, value);
    536     case CryptoAlgorithmIdentifier::HMAC:
    537         return createHmacKeyParams(*exec, value);
    538     case CryptoAlgorithmIdentifier::DH:
    539     case CryptoAlgorithmIdentifier::SHA_1:
    540     case CryptoAlgorithmIdentifier::SHA_224:
    541     case CryptoAlgorithmIdentifier::SHA_256:
    542     case CryptoAlgorithmIdentifier::SHA_384:
    543     case CryptoAlgorithmIdentifier::SHA_512:
    544     case CryptoAlgorithmIdentifier::CONCAT:
    545     case CryptoAlgorithmIdentifier::HKDF_CTR:
    546     case CryptoAlgorithmIdentifier::PBKDF2:
    547         setDOMException(exec, NOT_SUPPORTED_ERR);
    548         return nullptr;
    549     }
    550     RELEASE_ASSERT_NOT_REACHED();
    551     return nullptr;
    552 }
    553 
    554 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
    555 {
    556     switch (algorithm) {
    557     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    558     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    559     case CryptoAlgorithmIdentifier::RSA_PSS:
    560     case CryptoAlgorithmIdentifier::RSA_OAEP:
    561     case CryptoAlgorithmIdentifier::ECDSA:
    562     case CryptoAlgorithmIdentifier::ECDH:
    563     case CryptoAlgorithmIdentifier::AES_CTR:
    564     case CryptoAlgorithmIdentifier::AES_CBC:
    565     case CryptoAlgorithmIdentifier::AES_CMAC:
    566     case CryptoAlgorithmIdentifier::AES_GCM:
    567     case CryptoAlgorithmIdentifier::AES_CFB:
    568     case CryptoAlgorithmIdentifier::AES_KW:
    569     case CryptoAlgorithmIdentifier::HMAC:
    570     case CryptoAlgorithmIdentifier::DH:
    571     case CryptoAlgorithmIdentifier::SHA_1:
    572     case CryptoAlgorithmIdentifier::SHA_224:
    573     case CryptoAlgorithmIdentifier::SHA_256:
    574     case CryptoAlgorithmIdentifier::SHA_384:
    575     case CryptoAlgorithmIdentifier::SHA_512:
    576     case CryptoAlgorithmIdentifier::CONCAT:
    577     case CryptoAlgorithmIdentifier::HKDF_CTR:
    578     case CryptoAlgorithmIdentifier::PBKDF2:
    579         setDOMException(exec, NOT_SUPPORTED_ERR);
    580         return nullptr;
    581     }
    582     RELEASE_ASSERT_NOT_REACHED();
    583     return nullptr;
    584 }
    585 
    586 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
    587 {
    588     switch (algorithm) {
    589     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    590     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    591     case CryptoAlgorithmIdentifier::RSA_PSS:
    592     case CryptoAlgorithmIdentifier::RSA_OAEP:
    593     case CryptoAlgorithmIdentifier::ECDSA:
    594     case CryptoAlgorithmIdentifier::ECDH:
    595     case CryptoAlgorithmIdentifier::AES_CTR:
    596     case CryptoAlgorithmIdentifier::AES_CBC:
    597     case CryptoAlgorithmIdentifier::AES_CMAC:
    598     case CryptoAlgorithmIdentifier::AES_GCM:
    599     case CryptoAlgorithmIdentifier::AES_CFB:
    600     case CryptoAlgorithmIdentifier::AES_KW:
    601     case CryptoAlgorithmIdentifier::HMAC:
    602     case CryptoAlgorithmIdentifier::DH:
    603     case CryptoAlgorithmIdentifier::SHA_1:
    604     case CryptoAlgorithmIdentifier::SHA_224:
    605     case CryptoAlgorithmIdentifier::SHA_256:
    606     case CryptoAlgorithmIdentifier::SHA_384:
    607     case CryptoAlgorithmIdentifier::SHA_512:
    608     case CryptoAlgorithmIdentifier::CONCAT:
    609     case CryptoAlgorithmIdentifier::HKDF_CTR:
    610     case CryptoAlgorithmIdentifier::PBKDF2:
    611         setDOMException(exec, NOT_SUPPORTED_ERR);
    612         return nullptr;
    613     }
    614     RELEASE_ASSERT_NOT_REACHED();
    615     return nullptr;
    616 }
    617 
    618 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForImportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
    619 {
    620     switch (algorithm) {
    621     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    622     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    623     case CryptoAlgorithmIdentifier::RSA_PSS:
    624     case CryptoAlgorithmIdentifier::RSA_OAEP:
    625         return createRsaKeyParamsWithHash(*exec, value);
    626     case CryptoAlgorithmIdentifier::ECDSA:
    627     case CryptoAlgorithmIdentifier::ECDH:
    628     case CryptoAlgorithmIdentifier::AES_CTR:
    629     case CryptoAlgorithmIdentifier::AES_CBC:
    630     case CryptoAlgorithmIdentifier::AES_CMAC:
    631     case CryptoAlgorithmIdentifier::AES_GCM:
    632     case CryptoAlgorithmIdentifier::AES_CFB:
    633     case CryptoAlgorithmIdentifier::AES_KW:
    634         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    635     case CryptoAlgorithmIdentifier::HMAC:
    636         return createHmacParams(*exec, value);
    637     case CryptoAlgorithmIdentifier::DH:
    638         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    639     case CryptoAlgorithmIdentifier::SHA_1:
    640     case CryptoAlgorithmIdentifier::SHA_224:
    641     case CryptoAlgorithmIdentifier::SHA_256:
    642     case CryptoAlgorithmIdentifier::SHA_384:
    643     case CryptoAlgorithmIdentifier::SHA_512:
    644     case CryptoAlgorithmIdentifier::CONCAT:
    645     case CryptoAlgorithmIdentifier::HKDF_CTR:
    646     case CryptoAlgorithmIdentifier::PBKDF2:
    647         setDOMException(exec, NOT_SUPPORTED_ERR);
    648         return nullptr;
    649     }
    650     RELEASE_ASSERT_NOT_REACHED();
    651     return nullptr;
    652 }
    653 
    654 RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForExportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
    655 {
    656     switch (algorithm) {
    657     case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
    658     case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
    659     case CryptoAlgorithmIdentifier::RSA_PSS:
    660     case CryptoAlgorithmIdentifier::RSA_OAEP:
    661     case CryptoAlgorithmIdentifier::ECDSA:
    662     case CryptoAlgorithmIdentifier::ECDH:
    663     case CryptoAlgorithmIdentifier::AES_CTR:
    664     case CryptoAlgorithmIdentifier::AES_CBC:
    665     case CryptoAlgorithmIdentifier::AES_CMAC:
    666     case CryptoAlgorithmIdentifier::AES_GCM:
    667     case CryptoAlgorithmIdentifier::AES_CFB:
    668     case CryptoAlgorithmIdentifier::AES_KW:
    669     case CryptoAlgorithmIdentifier::HMAC:
    670     case CryptoAlgorithmIdentifier::DH:
    671         return adoptRef(*new CryptoAlgorithmParametersDeprecated);
    672     case CryptoAlgorithmIdentifier::SHA_1:
    673     case CryptoAlgorithmIdentifier::SHA_224:
    674     case CryptoAlgorithmIdentifier::SHA_256:
    675     case CryptoAlgorithmIdentifier::SHA_384:
    676     case CryptoAlgorithmIdentifier::SHA_512:
    677     case CryptoAlgorithmIdentifier::CONCAT:
    678     case CryptoAlgorithmIdentifier::HKDF_CTR:
    679     case CryptoAlgorithmIdentifier::PBKDF2:
    680         setDOMException(exec, NOT_SUPPORTED_ERR);
     310RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForEncrypt(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue value)
     311{
     312    switch (algorithm) {
     313    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     314        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     315    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     316    case CryptoAlgorithmIdentifier::RSA_PSS:
     317        setDOMException(&state, NOT_SUPPORTED_ERR);
     318        return nullptr;
     319    case CryptoAlgorithmIdentifier::RSA_OAEP:
     320        return createRsaOaepParams(state, value);
     321    case CryptoAlgorithmIdentifier::ECDSA:
     322    case CryptoAlgorithmIdentifier::ECDH:
     323    case CryptoAlgorithmIdentifier::AES_CTR:
     324        setDOMException(&state, NOT_SUPPORTED_ERR);
     325        return nullptr;
     326    case CryptoAlgorithmIdentifier::AES_CBC:
     327        return createAesCbcParams(state, value);
     328    case CryptoAlgorithmIdentifier::AES_CMAC:
     329    case CryptoAlgorithmIdentifier::AES_GCM:
     330    case CryptoAlgorithmIdentifier::AES_CFB:
     331        setDOMException(&state, NOT_SUPPORTED_ERR);
     332        return nullptr;
     333    case CryptoAlgorithmIdentifier::AES_KW:
     334        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     335    case CryptoAlgorithmIdentifier::HMAC:
     336    case CryptoAlgorithmIdentifier::DH:
     337    case CryptoAlgorithmIdentifier::SHA_1:
     338    case CryptoAlgorithmIdentifier::SHA_224:
     339    case CryptoAlgorithmIdentifier::SHA_256:
     340    case CryptoAlgorithmIdentifier::SHA_384:
     341    case CryptoAlgorithmIdentifier::SHA_512:
     342    case CryptoAlgorithmIdentifier::CONCAT:
     343    case CryptoAlgorithmIdentifier::HKDF_CTR:
     344    case CryptoAlgorithmIdentifier::PBKDF2:
     345        setDOMException(&state, NOT_SUPPORTED_ERR);
     346        return nullptr;
     347    }
     348    RELEASE_ASSERT_NOT_REACHED();
     349    return nullptr;
     350}
     351
     352RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDecrypt(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue value)
     353{
     354    switch (algorithm) {
     355    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     356        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     357    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     358    case CryptoAlgorithmIdentifier::RSA_PSS:
     359        setDOMException(&state, NOT_SUPPORTED_ERR);
     360        return nullptr;
     361    case CryptoAlgorithmIdentifier::RSA_OAEP:
     362        return createRsaOaepParams(state, value);
     363    case CryptoAlgorithmIdentifier::ECDSA:
     364    case CryptoAlgorithmIdentifier::ECDH:
     365    case CryptoAlgorithmIdentifier::AES_CTR:
     366        setDOMException(&state, NOT_SUPPORTED_ERR);
     367        return nullptr;
     368    case CryptoAlgorithmIdentifier::AES_CBC:
     369        return createAesCbcParams(state, value);
     370    case CryptoAlgorithmIdentifier::AES_CMAC:
     371    case CryptoAlgorithmIdentifier::AES_GCM:
     372    case CryptoAlgorithmIdentifier::AES_CFB:
     373        setDOMException(&state, NOT_SUPPORTED_ERR);
     374        return nullptr;
     375    case CryptoAlgorithmIdentifier::AES_KW:
     376        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     377    case CryptoAlgorithmIdentifier::HMAC:
     378    case CryptoAlgorithmIdentifier::DH:
     379    case CryptoAlgorithmIdentifier::SHA_1:
     380    case CryptoAlgorithmIdentifier::SHA_224:
     381    case CryptoAlgorithmIdentifier::SHA_256:
     382    case CryptoAlgorithmIdentifier::SHA_384:
     383    case CryptoAlgorithmIdentifier::SHA_512:
     384    case CryptoAlgorithmIdentifier::CONCAT:
     385    case CryptoAlgorithmIdentifier::HKDF_CTR:
     386    case CryptoAlgorithmIdentifier::PBKDF2:
     387        setDOMException(&state, NOT_SUPPORTED_ERR);
     388        return nullptr;
     389    }
     390    RELEASE_ASSERT_NOT_REACHED();
     391    return nullptr;
     392}
     393
     394RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForSign(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue value)
     395{
     396    switch (algorithm) {
     397    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     398        setDOMException(&state, NOT_SUPPORTED_ERR);
     399        return nullptr;
     400    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     401        return createRsaSsaParams(state, value);
     402    case CryptoAlgorithmIdentifier::RSA_PSS:
     403    case CryptoAlgorithmIdentifier::RSA_OAEP:
     404    case CryptoAlgorithmIdentifier::ECDSA:
     405    case CryptoAlgorithmIdentifier::ECDH:
     406    case CryptoAlgorithmIdentifier::AES_CTR:
     407    case CryptoAlgorithmIdentifier::AES_CBC:
     408    case CryptoAlgorithmIdentifier::AES_CMAC:
     409    case CryptoAlgorithmIdentifier::AES_GCM:
     410    case CryptoAlgorithmIdentifier::AES_CFB:
     411    case CryptoAlgorithmIdentifier::AES_KW:
     412        setDOMException(&state, NOT_SUPPORTED_ERR);
     413        return nullptr;
     414    case CryptoAlgorithmIdentifier::HMAC:
     415        return createHmacParams(state, value);
     416    case CryptoAlgorithmIdentifier::DH:
     417    case CryptoAlgorithmIdentifier::SHA_1:
     418    case CryptoAlgorithmIdentifier::SHA_224:
     419    case CryptoAlgorithmIdentifier::SHA_256:
     420    case CryptoAlgorithmIdentifier::SHA_384:
     421    case CryptoAlgorithmIdentifier::SHA_512:
     422    case CryptoAlgorithmIdentifier::CONCAT:
     423    case CryptoAlgorithmIdentifier::HKDF_CTR:
     424    case CryptoAlgorithmIdentifier::PBKDF2:
     425        setDOMException(&state, NOT_SUPPORTED_ERR);
     426        return nullptr;
     427    }
     428    RELEASE_ASSERT_NOT_REACHED();
     429    return nullptr;
     430}
     431
     432RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForVerify(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue value)
     433{
     434    switch (algorithm) {
     435    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     436        setDOMException(&state, NOT_SUPPORTED_ERR);
     437        return nullptr;
     438    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     439        return createRsaSsaParams(state, value);
     440    case CryptoAlgorithmIdentifier::RSA_PSS:
     441    case CryptoAlgorithmIdentifier::RSA_OAEP:
     442    case CryptoAlgorithmIdentifier::ECDSA:
     443    case CryptoAlgorithmIdentifier::ECDH:
     444    case CryptoAlgorithmIdentifier::AES_CTR:
     445    case CryptoAlgorithmIdentifier::AES_CBC:
     446    case CryptoAlgorithmIdentifier::AES_CMAC:
     447    case CryptoAlgorithmIdentifier::AES_GCM:
     448    case CryptoAlgorithmIdentifier::AES_CFB:
     449    case CryptoAlgorithmIdentifier::AES_KW:
     450        setDOMException(&state, NOT_SUPPORTED_ERR);
     451        return nullptr;
     452    case CryptoAlgorithmIdentifier::HMAC:
     453        return createHmacParams(state, value);
     454    case CryptoAlgorithmIdentifier::DH:
     455    case CryptoAlgorithmIdentifier::SHA_1:
     456    case CryptoAlgorithmIdentifier::SHA_224:
     457    case CryptoAlgorithmIdentifier::SHA_256:
     458    case CryptoAlgorithmIdentifier::SHA_384:
     459    case CryptoAlgorithmIdentifier::SHA_512:
     460    case CryptoAlgorithmIdentifier::CONCAT:
     461    case CryptoAlgorithmIdentifier::HKDF_CTR:
     462    case CryptoAlgorithmIdentifier::PBKDF2:
     463        setDOMException(&state, NOT_SUPPORTED_ERR);
     464        return nullptr;
     465    }
     466    RELEASE_ASSERT_NOT_REACHED();
     467    return nullptr;
     468}
     469
     470RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDigest(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue)
     471{
     472    switch (algorithm) {
     473    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     474    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     475    case CryptoAlgorithmIdentifier::RSA_PSS:
     476    case CryptoAlgorithmIdentifier::RSA_OAEP:
     477    case CryptoAlgorithmIdentifier::ECDSA:
     478    case CryptoAlgorithmIdentifier::ECDH:
     479    case CryptoAlgorithmIdentifier::AES_CTR:
     480    case CryptoAlgorithmIdentifier::AES_CBC:
     481    case CryptoAlgorithmIdentifier::AES_CMAC:
     482    case CryptoAlgorithmIdentifier::AES_GCM:
     483    case CryptoAlgorithmIdentifier::AES_CFB:
     484    case CryptoAlgorithmIdentifier::AES_KW:
     485    case CryptoAlgorithmIdentifier::HMAC:
     486    case CryptoAlgorithmIdentifier::DH:
     487        setDOMException(&state, NOT_SUPPORTED_ERR);
     488        return nullptr;
     489    case CryptoAlgorithmIdentifier::SHA_1:
     490    case CryptoAlgorithmIdentifier::SHA_224:
     491    case CryptoAlgorithmIdentifier::SHA_256:
     492    case CryptoAlgorithmIdentifier::SHA_384:
     493    case CryptoAlgorithmIdentifier::SHA_512:
     494        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     495    case CryptoAlgorithmIdentifier::CONCAT:
     496    case CryptoAlgorithmIdentifier::HKDF_CTR:
     497    case CryptoAlgorithmIdentifier::PBKDF2:
     498        setDOMException(&state, NOT_SUPPORTED_ERR);
     499        return nullptr;
     500    }
     501    RELEASE_ASSERT_NOT_REACHED();
     502    return nullptr;
     503}
     504
     505RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue value)
     506{
     507    switch (algorithm) {
     508    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     509    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     510    case CryptoAlgorithmIdentifier::RSA_PSS:
     511    case CryptoAlgorithmIdentifier::RSA_OAEP:
     512        return createRsaKeyGenParams(state, value);
     513    case CryptoAlgorithmIdentifier::ECDSA:
     514    case CryptoAlgorithmIdentifier::ECDH:
     515        setDOMException(&state, NOT_SUPPORTED_ERR);
     516        return nullptr;
     517    case CryptoAlgorithmIdentifier::AES_CTR:
     518    case CryptoAlgorithmIdentifier::AES_CBC:
     519    case CryptoAlgorithmIdentifier::AES_CMAC:
     520    case CryptoAlgorithmIdentifier::AES_GCM:
     521    case CryptoAlgorithmIdentifier::AES_CFB:
     522    case CryptoAlgorithmIdentifier::AES_KW:
     523        return createAesKeyGenParams(state, value);
     524    case CryptoAlgorithmIdentifier::HMAC:
     525        return createHmacKeyParams(state, value);
     526    case CryptoAlgorithmIdentifier::DH:
     527    case CryptoAlgorithmIdentifier::SHA_1:
     528    case CryptoAlgorithmIdentifier::SHA_224:
     529    case CryptoAlgorithmIdentifier::SHA_256:
     530    case CryptoAlgorithmIdentifier::SHA_384:
     531    case CryptoAlgorithmIdentifier::SHA_512:
     532    case CryptoAlgorithmIdentifier::CONCAT:
     533    case CryptoAlgorithmIdentifier::HKDF_CTR:
     534    case CryptoAlgorithmIdentifier::PBKDF2:
     535        setDOMException(&state, NOT_SUPPORTED_ERR);
     536        return nullptr;
     537    }
     538    RELEASE_ASSERT_NOT_REACHED();
     539    return nullptr;
     540}
     541
     542RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue)
     543{
     544    switch (algorithm) {
     545    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     546    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     547    case CryptoAlgorithmIdentifier::RSA_PSS:
     548    case CryptoAlgorithmIdentifier::RSA_OAEP:
     549    case CryptoAlgorithmIdentifier::ECDSA:
     550    case CryptoAlgorithmIdentifier::ECDH:
     551    case CryptoAlgorithmIdentifier::AES_CTR:
     552    case CryptoAlgorithmIdentifier::AES_CBC:
     553    case CryptoAlgorithmIdentifier::AES_CMAC:
     554    case CryptoAlgorithmIdentifier::AES_GCM:
     555    case CryptoAlgorithmIdentifier::AES_CFB:
     556    case CryptoAlgorithmIdentifier::AES_KW:
     557    case CryptoAlgorithmIdentifier::HMAC:
     558    case CryptoAlgorithmIdentifier::DH:
     559    case CryptoAlgorithmIdentifier::SHA_1:
     560    case CryptoAlgorithmIdentifier::SHA_224:
     561    case CryptoAlgorithmIdentifier::SHA_256:
     562    case CryptoAlgorithmIdentifier::SHA_384:
     563    case CryptoAlgorithmIdentifier::SHA_512:
     564    case CryptoAlgorithmIdentifier::CONCAT:
     565    case CryptoAlgorithmIdentifier::HKDF_CTR:
     566    case CryptoAlgorithmIdentifier::PBKDF2:
     567        setDOMException(&state, NOT_SUPPORTED_ERR);
     568        return nullptr;
     569    }
     570    RELEASE_ASSERT_NOT_REACHED();
     571    return nullptr;
     572}
     573
     574RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue)
     575{
     576    switch (algorithm) {
     577    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     578    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     579    case CryptoAlgorithmIdentifier::RSA_PSS:
     580    case CryptoAlgorithmIdentifier::RSA_OAEP:
     581    case CryptoAlgorithmIdentifier::ECDSA:
     582    case CryptoAlgorithmIdentifier::ECDH:
     583    case CryptoAlgorithmIdentifier::AES_CTR:
     584    case CryptoAlgorithmIdentifier::AES_CBC:
     585    case CryptoAlgorithmIdentifier::AES_CMAC:
     586    case CryptoAlgorithmIdentifier::AES_GCM:
     587    case CryptoAlgorithmIdentifier::AES_CFB:
     588    case CryptoAlgorithmIdentifier::AES_KW:
     589    case CryptoAlgorithmIdentifier::HMAC:
     590    case CryptoAlgorithmIdentifier::DH:
     591    case CryptoAlgorithmIdentifier::SHA_1:
     592    case CryptoAlgorithmIdentifier::SHA_224:
     593    case CryptoAlgorithmIdentifier::SHA_256:
     594    case CryptoAlgorithmIdentifier::SHA_384:
     595    case CryptoAlgorithmIdentifier::SHA_512:
     596    case CryptoAlgorithmIdentifier::CONCAT:
     597    case CryptoAlgorithmIdentifier::HKDF_CTR:
     598    case CryptoAlgorithmIdentifier::PBKDF2:
     599        setDOMException(&state, NOT_SUPPORTED_ERR);
     600        return nullptr;
     601    }
     602    RELEASE_ASSERT_NOT_REACHED();
     603    return nullptr;
     604}
     605
     606RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForImportKey(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue value)
     607{
     608    switch (algorithm) {
     609    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     610    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     611    case CryptoAlgorithmIdentifier::RSA_PSS:
     612    case CryptoAlgorithmIdentifier::RSA_OAEP:
     613        return createRsaKeyParamsWithHash(state, value);
     614    case CryptoAlgorithmIdentifier::ECDSA:
     615    case CryptoAlgorithmIdentifier::ECDH:
     616    case CryptoAlgorithmIdentifier::AES_CTR:
     617    case CryptoAlgorithmIdentifier::AES_CBC:
     618    case CryptoAlgorithmIdentifier::AES_CMAC:
     619    case CryptoAlgorithmIdentifier::AES_GCM:
     620    case CryptoAlgorithmIdentifier::AES_CFB:
     621    case CryptoAlgorithmIdentifier::AES_KW:
     622        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     623    case CryptoAlgorithmIdentifier::HMAC:
     624        return createHmacParams(state, value);
     625    case CryptoAlgorithmIdentifier::DH:
     626        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     627    case CryptoAlgorithmIdentifier::SHA_1:
     628    case CryptoAlgorithmIdentifier::SHA_224:
     629    case CryptoAlgorithmIdentifier::SHA_256:
     630    case CryptoAlgorithmIdentifier::SHA_384:
     631    case CryptoAlgorithmIdentifier::SHA_512:
     632    case CryptoAlgorithmIdentifier::CONCAT:
     633    case CryptoAlgorithmIdentifier::HKDF_CTR:
     634    case CryptoAlgorithmIdentifier::PBKDF2:
     635        setDOMException(&state, NOT_SUPPORTED_ERR);
     636        return nullptr;
     637    }
     638    RELEASE_ASSERT_NOT_REACHED();
     639    return nullptr;
     640}
     641
     642RefPtr<CryptoAlgorithmParametersDeprecated> JSCryptoAlgorithmDictionary::createParametersForExportKey(ExecState& state, CryptoAlgorithmIdentifier algorithm, JSValue)
     643{
     644    switch (algorithm) {
     645    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
     646    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
     647    case CryptoAlgorithmIdentifier::RSA_PSS:
     648    case CryptoAlgorithmIdentifier::RSA_OAEP:
     649    case CryptoAlgorithmIdentifier::ECDSA:
     650    case CryptoAlgorithmIdentifier::ECDH:
     651    case CryptoAlgorithmIdentifier::AES_CTR:
     652    case CryptoAlgorithmIdentifier::AES_CBC:
     653    case CryptoAlgorithmIdentifier::AES_CMAC:
     654    case CryptoAlgorithmIdentifier::AES_GCM:
     655    case CryptoAlgorithmIdentifier::AES_CFB:
     656    case CryptoAlgorithmIdentifier::AES_KW:
     657    case CryptoAlgorithmIdentifier::HMAC:
     658    case CryptoAlgorithmIdentifier::DH:
     659        return adoptRef(*new CryptoAlgorithmParametersDeprecated);
     660    case CryptoAlgorithmIdentifier::SHA_1:
     661    case CryptoAlgorithmIdentifier::SHA_224:
     662    case CryptoAlgorithmIdentifier::SHA_256:
     663    case CryptoAlgorithmIdentifier::SHA_384:
     664    case CryptoAlgorithmIdentifier::SHA_512:
     665    case CryptoAlgorithmIdentifier::CONCAT:
     666    case CryptoAlgorithmIdentifier::HKDF_CTR:
     667    case CryptoAlgorithmIdentifier::PBKDF2:
     668        setDOMException(&state, NOT_SUPPORTED_ERR);
    681669        return nullptr;
    682670    }
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.h

    r208179 r209900  
    4242class JSCryptoAlgorithmDictionary {
    4343public:
    44     static bool getAlgorithmIdentifier(JSC::ExecState*, JSC::JSValue, CryptoAlgorithmIdentifier&);
     44    static bool getAlgorithmIdentifier(JSC::ExecState&, JSC::JSValue, CryptoAlgorithmIdentifier&);
    4545
    46     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForEncrypt(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    47     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDecrypt(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    48     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForSign(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    49     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForVerify(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    50     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDigest(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    51     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForGenerateKey(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    52     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDeriveKey(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    53     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDeriveBits(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    54     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForImportKey(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
    55     static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForExportKey(JSC::ExecState*, CryptoAlgorithmIdentifier, JSC::JSValue);
     46    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForEncrypt(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     47    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDecrypt(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     48    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForSign(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     49    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForVerify(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     50    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDigest(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     51    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForGenerateKey(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     52    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDeriveKey(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     53    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForDeriveBits(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     54    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForImportKey(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
     55    static RefPtr<CryptoAlgorithmParametersDeprecated> createParametersForExportKey(JSC::ExecState&, CryptoAlgorithmIdentifier, JSC::JSValue);
    5656};
    5757
  • trunk/Source/WebCore/bindings/js/JSCryptoOperationData.cpp

    r208209 r209900  
    3535namespace WebCore {
    3636
    37 bool cryptoOperationDataFromJSValue(ExecState* exec, JSValue value, CryptoOperationData& result)
     37bool cryptoOperationDataFromJSValue(ExecState& state, JSValue value, CryptoOperationData& result)
    3838{
    39     VM& vm = exec->vm();
    40     auto scope = DECLARE_THROW_SCOPE(vm);
     39    auto scope = DECLARE_THROW_SCOPE(state.vm());
    4140
    4241    if (ArrayBuffer* buffer = toUnsharedArrayBuffer(value))
     
    4544        result = std::make_pair(static_cast<uint8_t*>(bufferView->baseAddress()), bufferView->byteLength());
    4645    else {
    47         throwTypeError(exec, scope, ASCIILiteral("Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData"));
     46        throwTypeError(&state, scope, ASCIILiteral("Only ArrayBuffer and ArrayBufferView objects can be passed as CryptoOperationData"));
    4847        return false;
    4948    }
  • trunk/Source/WebCore/bindings/js/JSCryptoOperationData.h

    r208179 r209900  
    3737typedef std::pair<const uint8_t*, size_t> CryptoOperationData;
    3838
    39 bool cryptoOperationDataFromJSValue(JSC::ExecState*, JSC::JSValue, CryptoOperationData&);
     39bool cryptoOperationDataFromJSValue(JSC::ExecState&, JSC::JSValue, CryptoOperationData&);
    4040
    4141} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp

    r209801 r209900  
    6969
    7070    CryptoAlgorithmIdentifier algorithmIdentifier;
    71     auto success = JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(&state, value, algorithmIdentifier);
     71    auto success = JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(state, value, algorithmIdentifier);
    7272    ASSERT_UNUSED(scope, scope.exception() || success);
    7373    if (!success)
     
    152152        return jsUndefined();
    153153
    154     auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
     154    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(state, algorithm->identifier(), state.uncheckedArgument(0));
    155155    ASSERT(scope.exception() || parameters);
    156156    if (!parameters)
     
    168168
    169169    CryptoOperationData data;
    170     auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
     170    auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), data);
    171171    ASSERT(scope.exception() || success);
    172172    if (!success)
     
    204204        return jsUndefined();
    205205
    206     auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
     206    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(state, algorithm->identifier(), state.uncheckedArgument(0));
    207207    ASSERT(scope.exception() || parameters);
    208208    if (!parameters)
     
    220220
    221221    CryptoOperationData data;
    222     auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
     222    auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), data);
    223223    ASSERT(scope.exception() || success);
    224224    if (!success)
     
    256256        return jsUndefined();
    257257
    258     auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(&state, algorithm->identifier(), state.uncheckedArgument(0));
     258    auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(state, algorithm->identifier(), state.uncheckedArgument(0));
    259259    ASSERT(scope.exception() || parameters);
    260260    if (!parameters)
     
    272272
    273273    CryptoOperationData data;
    274     auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
     274    auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), data);
    275275    ASSERT(scope.exception() || success);
    276276    if (!success)
     
    308308        return jsUndefined();
    309309
    310     auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(&state, algorithm->identifier(), state.uncheckedArgument(0));
     310    auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(state, algorithm->identifier(), state.uncheckedArgument(0));
    311311    ASSERT(scope.exception() || parameters);
    312312    if (!parameters)
     
    324324
    325325    CryptoOperationData signature;
    326     auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), signature);
     326    auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), signature);
    327327    ASSERT(scope.exception() || success);
    328328    if (!success)
     
    330330
    331331    CryptoOperationData data;
    332     success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(3), data);
     332    success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(3), data);
    333333    ASSERT(scope.exception() || success);
    334334    if (!success)
     
    366366        return jsUndefined();
    367367
    368     auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(&state, algorithm->identifier(), state.uncheckedArgument(0));
     368    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(state, algorithm->identifier(), state.uncheckedArgument(0));
    369369    ASSERT(scope.exception() || parameters);
    370370    if (!parameters)
     
    372372
    373373    CryptoOperationData data;
    374     auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data);
     374    auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(1), data);
    375375    ASSERT(scope.exception() || success);
    376376    if (!success)
     
    408408        return jsUndefined();
    409409
    410     auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(&state, algorithm->identifier(), state.uncheckedArgument(0));
     410    auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(state, algorithm->identifier(), state.uncheckedArgument(0));
    411411    ASSERT(scope.exception() || parameters);
    412412    if (!parameters)
     
    522522
    523523    CryptoOperationData data;
    524     success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data);
     524    success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(1), data);
    525525    ASSERT(scope.exception() || success);
    526526    if (!success)
     
    535535            return jsUndefined();
    536536
    537         parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, algorithm->identifier(), state.uncheckedArgument(2));
     537        parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(state, algorithm->identifier(), state.uncheckedArgument(2));
    538538        ASSERT(scope.exception() || parameters);
    539539        if (!parameters)
     
    670670        return jsUndefined();
    671671
    672     auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(3));
     672    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(state, algorithm->identifier(), state.uncheckedArgument(3));
    673673    ASSERT(scope.exception() || parameters);
    674674    if (!parameters)
     
    716716
    717717    CryptoOperationData wrappedKeyData;
    718     success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), wrappedKeyData);
     718    success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(1), wrappedKeyData);
    719719    ASSERT(scope.exception() || success);
    720720    if (!success)
     
    735735    if (!unwrapAlgorithm)
    736736        return jsUndefined();
    737     auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3));
     737    auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3));
    738738    ASSERT(scope.exception() || unwrapAlgorithmParameters);
    739739    if (!unwrapAlgorithmParameters)
     
    748748            return jsUndefined();
    749749
    750         unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4));
     750        unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4));
    751751        ASSERT(scope.exception() || unwrappedKeyAlgorithmParameters);
    752752        if (!unwrappedKeyAlgorithmParameters)
Note: See TracChangeset for help on using the changeset viewer.