2 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "JSCryptoAlgorithmDictionary.h"
29 #if ENABLE(SUBTLE_CRYPTO)
31 #include "CryptoAlgorithmAesCbcParams.h"
32 #include "CryptoAlgorithmAesKeyGenParams.h"
33 #include "CryptoAlgorithmHmacKeyParams.h"
34 #include "CryptoAlgorithmHmacParams.h"
35 #include "CryptoAlgorithmRegistry.h"
36 #include "CryptoAlgorithmRsaKeyGenParams.h"
37 #include "CryptoAlgorithmRsaKeyParamsWithHash.h"
38 #include "CryptoAlgorithmRsaOaepParams.h"
39 #include "CryptoAlgorithmRsaSsaParams.h"
40 #include "ExceptionCode.h"
41 #include "JSCryptoOperationData.h"
42 #include "JSDOMBinding.h"
43 #include "JSDOMConvert.h"
44 #include "JSDictionary.h"
50 enum class HashRequirement {
55 bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier)
58 auto scope = DECLARE_THROW_SCOPE(vm);
60 // typedef (Algorithm or DOMString) AlgorithmIdentifier;
65 algorithmName = value.toString(exec)->value(exec);
66 else if (value.isObject()) {
67 if (value.getObject()->inherits(StringObject::info()))
68 algorithmName = asString(asStringObject(value)->internalValue())->value(exec);
70 // FIXME: This doesn't perform some checks mandated by WebIDL for dictionaries:
71 // - null and undefined input should be treated as if all elements in the dictionary were undefined;
72 // - undefined elements should be treated as having a default value, or as not present if there isn't such;
73 // - RegExp and Date objects cannot be converted to dictionaries.
75 // This is partially because we don't implement it elsewhere in WebCore yet, and partially because
76 // WebCrypto doesn't yet clearly specify what to do with non-present values in most cases anyway.
78 JSDictionary dictionary(exec, value.getObject());
79 dictionary.get("name", algorithmName);
83 RETURN_IF_EXCEPTION(scope, false);
85 if (!algorithmName.containsOnlyASCII()) {
86 throwSyntaxError(exec, scope);
90 if (!CryptoAlgorithmRegistry::singleton().getIdentifierForName(algorithmName, algorithmIdentifier)) {
91 setDOMException(exec, NOT_SUPPORTED_ERR);
98 static JSValue getProperty(ExecState* exec, JSObject* object, const char* name)
100 return object->get(exec, Identifier::fromString(exec, name));
103 static bool getHashAlgorithm(JSDictionary& dictionary, CryptoAlgorithmIdentifier& result, HashRequirement isRequired)
105 // FXIME: Teach JSDictionary how to return JSValues, and use that to get hash element value.
107 ExecState* exec = dictionary.execState();
109 auto scope = DECLARE_THROW_SCOPE(vm);
110 JSObject* object = dictionary.initializerObject();
112 Identifier identifier = Identifier::fromString(exec, "hash");
114 JSValue hash = getProperty(exec, object, "hash");
115 RETURN_IF_EXCEPTION(scope, false);
117 if (hash.isUndefinedOrNull()) {
118 if (isRequired == HashRequirement::Required)
119 setDOMException(exec, NOT_SUPPORTED_ERR);
123 return JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(exec, hash, result);
126 static RefPtr<CryptoAlgorithmParameters> createAesCbcParams(ExecState* exec, JSValue value)
129 auto scope = DECLARE_THROW_SCOPE(vm);
131 if (!value.isObject()) {
132 throwTypeError(exec, scope);
136 JSValue iv = getProperty(exec, value.getObject(), "iv");
137 RETURN_IF_EXCEPTION(scope, nullptr);
139 auto result = adoptRef(*new CryptoAlgorithmAesCbcParams);
141 CryptoOperationData ivData;
142 auto success = cryptoOperationDataFromJSValue(exec, iv, ivData);
143 ASSERT(scope.exception() || success);
147 if (ivData.second != 16) {
148 throwException(exec, scope, createError(exec, "AES-CBC initialization data must be 16 bytes"));
152 memcpy(result->iv.data(), ivData.first, ivData.second);
154 return WTFMove(result);
157 static RefPtr<CryptoAlgorithmParameters> createAesKeyGenParams(ExecState& state, JSValue value)
160 auto scope = DECLARE_THROW_SCOPE(vm);
162 if (!value.isObject()) {
163 throwTypeError(&state, scope);
167 auto result = adoptRef(*new CryptoAlgorithmAesKeyGenParams);
169 JSValue lengthValue = getProperty(&state, value.getObject(), "length");
170 RETURN_IF_EXCEPTION(scope, nullptr);
172 result->length = convert<uint16_t>(state, lengthValue, EnforceRange);
174 return WTFMove(result);
177 static RefPtr<CryptoAlgorithmParameters> createHmacParams(ExecState& state, JSValue value)
180 auto scope = DECLARE_THROW_SCOPE(vm);
182 if (!value.isObject()) {
183 throwTypeError(&state, scope);
187 JSDictionary jsDictionary(&state, value.getObject());
188 auto result = adoptRef(*new CryptoAlgorithmHmacParams);
190 auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
191 ASSERT_UNUSED(scope, scope.exception() || success);
195 return WTFMove(result);
198 static RefPtr<CryptoAlgorithmParameters> createHmacKeyParams(ExecState& state, JSValue value)
201 auto scope = DECLARE_THROW_SCOPE(vm);
203 if (!value.isObject()) {
204 throwTypeError(&state, scope);
208 JSDictionary jsDictionary(&state, value.getObject());
209 auto result = adoptRef(*new CryptoAlgorithmHmacKeyParams);
211 auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
212 ASSERT(scope.exception() || success);
216 result->hasLength = jsDictionary.get("length", result->length);
217 RETURN_IF_EXCEPTION(scope, nullptr);
219 return WTFMove(result);
222 static RefPtr<CryptoAlgorithmParameters> createRsaKeyGenParams(ExecState& state, JSValue value)
225 auto scope = DECLARE_THROW_SCOPE(vm);
227 if (!value.isObject()) {
228 throwTypeError(&state, scope);
232 JSDictionary jsDictionary(&state, value.getObject());
233 auto result = adoptRef(*new CryptoAlgorithmRsaKeyGenParams);
235 JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength");
236 RETURN_IF_EXCEPTION(scope, nullptr);
238 // FIXME: Why no EnforceRange? Filed as <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23779>.
239 result->modulusLength = convert<uint32_t>(state, modulusLengthValue, NormalConversion);
240 RETURN_IF_EXCEPTION(scope, nullptr);
242 JSValue publicExponentValue = getProperty(&state, value.getObject(), "publicExponent");
243 RETURN_IF_EXCEPTION(scope, nullptr);
245 RefPtr<Uint8Array> publicExponentArray = toUint8Array(publicExponentValue);
246 if (!publicExponentArray) {
247 throwTypeError(&state, scope, "Expected a Uint8Array in publicExponent");
250 result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength());
252 result->hasHash = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Optional);
254 return WTFMove(result);
257 static RefPtr<CryptoAlgorithmParameters> createRsaKeyParamsWithHash(ExecState&, JSValue)
259 // WebCrypto RSA algorithms currently do not take any parameters to importKey.
260 return adoptRef(*new CryptoAlgorithmRsaKeyParamsWithHash);
263 static RefPtr<CryptoAlgorithmParameters> createRsaOaepParams(ExecState* exec, JSValue value)
266 auto scope = DECLARE_THROW_SCOPE(vm);
268 if (!value.isObject()) {
269 throwTypeError(exec, scope);
273 JSDictionary jsDictionary(exec, value.getObject());
274 auto result = adoptRef(*new CryptoAlgorithmRsaOaepParams);
276 auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
277 ASSERT(scope.exception() || success);
281 JSValue labelValue = getProperty(exec, value.getObject(), "label");
282 RETURN_IF_EXCEPTION(scope, nullptr);
284 result->hasLabel = !labelValue.isUndefinedOrNull();
285 if (!result->hasLabel)
286 return WTFMove(result);
288 CryptoOperationData labelData;
289 success = cryptoOperationDataFromJSValue(exec, labelValue, labelData);
290 ASSERT(scope.exception() || success);
294 result->label.append(labelData.first, labelData.second);
296 return WTFMove(result);
299 static RefPtr<CryptoAlgorithmParameters> createRsaSsaParams(ExecState& state, JSValue value)
302 auto scope = DECLARE_THROW_SCOPE(vm);
304 if (!value.isObject()) {
305 throwTypeError(&state, scope);
309 JSDictionary jsDictionary(&state, value.getObject());
310 auto result = adoptRef(*new CryptoAlgorithmRsaSsaParams);
312 auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
313 ASSERT(scope.exception() || success);
317 return WTFMove(result);
320 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForEncrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
323 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
324 return adoptRef(*new CryptoAlgorithmParameters);
325 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
326 case CryptoAlgorithmIdentifier::RSA_PSS:
327 setDOMException(exec, NOT_SUPPORTED_ERR);
329 case CryptoAlgorithmIdentifier::RSA_OAEP:
330 return createRsaOaepParams(exec, value);
331 case CryptoAlgorithmIdentifier::ECDSA:
332 case CryptoAlgorithmIdentifier::ECDH:
333 case CryptoAlgorithmIdentifier::AES_CTR:
334 setDOMException(exec, NOT_SUPPORTED_ERR);
336 case CryptoAlgorithmIdentifier::AES_CBC:
337 return createAesCbcParams(exec, value);
338 case CryptoAlgorithmIdentifier::AES_CMAC:
339 case CryptoAlgorithmIdentifier::AES_GCM:
340 case CryptoAlgorithmIdentifier::AES_CFB:
341 setDOMException(exec, NOT_SUPPORTED_ERR);
343 case CryptoAlgorithmIdentifier::AES_KW:
344 return adoptRef(*new CryptoAlgorithmParameters);
345 case CryptoAlgorithmIdentifier::HMAC:
346 case CryptoAlgorithmIdentifier::DH:
347 case CryptoAlgorithmIdentifier::SHA_1:
348 case CryptoAlgorithmIdentifier::SHA_224:
349 case CryptoAlgorithmIdentifier::SHA_256:
350 case CryptoAlgorithmIdentifier::SHA_384:
351 case CryptoAlgorithmIdentifier::SHA_512:
352 case CryptoAlgorithmIdentifier::CONCAT:
353 case CryptoAlgorithmIdentifier::HKDF_CTR:
354 case CryptoAlgorithmIdentifier::PBKDF2:
355 setDOMException(exec, NOT_SUPPORTED_ERR);
358 RELEASE_ASSERT_NOT_REACHED();
362 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDecrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
365 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
366 return adoptRef(*new CryptoAlgorithmParameters);
367 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
368 case CryptoAlgorithmIdentifier::RSA_PSS:
369 setDOMException(exec, NOT_SUPPORTED_ERR);
371 case CryptoAlgorithmIdentifier::RSA_OAEP:
372 return createRsaOaepParams(exec, value);
373 case CryptoAlgorithmIdentifier::ECDSA:
374 case CryptoAlgorithmIdentifier::ECDH:
375 case CryptoAlgorithmIdentifier::AES_CTR:
376 setDOMException(exec, NOT_SUPPORTED_ERR);
378 case CryptoAlgorithmIdentifier::AES_CBC:
379 return createAesCbcParams(exec, value);
380 case CryptoAlgorithmIdentifier::AES_CMAC:
381 case CryptoAlgorithmIdentifier::AES_GCM:
382 case CryptoAlgorithmIdentifier::AES_CFB:
383 setDOMException(exec, NOT_SUPPORTED_ERR);
385 case CryptoAlgorithmIdentifier::AES_KW:
386 return adoptRef(*new CryptoAlgorithmParameters);
387 case CryptoAlgorithmIdentifier::HMAC:
388 case CryptoAlgorithmIdentifier::DH:
389 case CryptoAlgorithmIdentifier::SHA_1:
390 case CryptoAlgorithmIdentifier::SHA_224:
391 case CryptoAlgorithmIdentifier::SHA_256:
392 case CryptoAlgorithmIdentifier::SHA_384:
393 case CryptoAlgorithmIdentifier::SHA_512:
394 case CryptoAlgorithmIdentifier::CONCAT:
395 case CryptoAlgorithmIdentifier::HKDF_CTR:
396 case CryptoAlgorithmIdentifier::PBKDF2:
397 setDOMException(exec, NOT_SUPPORTED_ERR);
400 RELEASE_ASSERT_NOT_REACHED();
404 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForSign(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
407 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
408 setDOMException(exec, NOT_SUPPORTED_ERR);
410 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
411 return createRsaSsaParams(*exec, value);
412 case CryptoAlgorithmIdentifier::RSA_PSS:
413 case CryptoAlgorithmIdentifier::RSA_OAEP:
414 case CryptoAlgorithmIdentifier::ECDSA:
415 case CryptoAlgorithmIdentifier::ECDH:
416 case CryptoAlgorithmIdentifier::AES_CTR:
417 case CryptoAlgorithmIdentifier::AES_CBC:
418 case CryptoAlgorithmIdentifier::AES_CMAC:
419 case CryptoAlgorithmIdentifier::AES_GCM:
420 case CryptoAlgorithmIdentifier::AES_CFB:
421 case CryptoAlgorithmIdentifier::AES_KW:
422 setDOMException(exec, NOT_SUPPORTED_ERR);
424 case CryptoAlgorithmIdentifier::HMAC:
425 return createHmacParams(*exec, value);
426 case CryptoAlgorithmIdentifier::DH:
427 case CryptoAlgorithmIdentifier::SHA_1:
428 case CryptoAlgorithmIdentifier::SHA_224:
429 case CryptoAlgorithmIdentifier::SHA_256:
430 case CryptoAlgorithmIdentifier::SHA_384:
431 case CryptoAlgorithmIdentifier::SHA_512:
432 case CryptoAlgorithmIdentifier::CONCAT:
433 case CryptoAlgorithmIdentifier::HKDF_CTR:
434 case CryptoAlgorithmIdentifier::PBKDF2:
435 setDOMException(exec, NOT_SUPPORTED_ERR);
438 RELEASE_ASSERT_NOT_REACHED();
442 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForVerify(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
445 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
446 setDOMException(exec, NOT_SUPPORTED_ERR);
448 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
449 return createRsaSsaParams(*exec, value);
450 case CryptoAlgorithmIdentifier::RSA_PSS:
451 case CryptoAlgorithmIdentifier::RSA_OAEP:
452 case CryptoAlgorithmIdentifier::ECDSA:
453 case CryptoAlgorithmIdentifier::ECDH:
454 case CryptoAlgorithmIdentifier::AES_CTR:
455 case CryptoAlgorithmIdentifier::AES_CBC:
456 case CryptoAlgorithmIdentifier::AES_CMAC:
457 case CryptoAlgorithmIdentifier::AES_GCM:
458 case CryptoAlgorithmIdentifier::AES_CFB:
459 case CryptoAlgorithmIdentifier::AES_KW:
460 setDOMException(exec, NOT_SUPPORTED_ERR);
462 case CryptoAlgorithmIdentifier::HMAC:
463 return createHmacParams(*exec, value);
464 case CryptoAlgorithmIdentifier::DH:
465 case CryptoAlgorithmIdentifier::SHA_1:
466 case CryptoAlgorithmIdentifier::SHA_224:
467 case CryptoAlgorithmIdentifier::SHA_256:
468 case CryptoAlgorithmIdentifier::SHA_384:
469 case CryptoAlgorithmIdentifier::SHA_512:
470 case CryptoAlgorithmIdentifier::CONCAT:
471 case CryptoAlgorithmIdentifier::HKDF_CTR:
472 case CryptoAlgorithmIdentifier::PBKDF2:
473 setDOMException(exec, NOT_SUPPORTED_ERR);
476 RELEASE_ASSERT_NOT_REACHED();
480 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDigest(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
483 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
484 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
485 case CryptoAlgorithmIdentifier::RSA_PSS:
486 case CryptoAlgorithmIdentifier::RSA_OAEP:
487 case CryptoAlgorithmIdentifier::ECDSA:
488 case CryptoAlgorithmIdentifier::ECDH:
489 case CryptoAlgorithmIdentifier::AES_CTR:
490 case CryptoAlgorithmIdentifier::AES_CBC:
491 case CryptoAlgorithmIdentifier::AES_CMAC:
492 case CryptoAlgorithmIdentifier::AES_GCM:
493 case CryptoAlgorithmIdentifier::AES_CFB:
494 case CryptoAlgorithmIdentifier::AES_KW:
495 case CryptoAlgorithmIdentifier::HMAC:
496 case CryptoAlgorithmIdentifier::DH:
497 setDOMException(exec, NOT_SUPPORTED_ERR);
499 case CryptoAlgorithmIdentifier::SHA_1:
500 case CryptoAlgorithmIdentifier::SHA_224:
501 case CryptoAlgorithmIdentifier::SHA_256:
502 case CryptoAlgorithmIdentifier::SHA_384:
503 case CryptoAlgorithmIdentifier::SHA_512:
504 return adoptRef(*new CryptoAlgorithmParameters);
505 case CryptoAlgorithmIdentifier::CONCAT:
506 case CryptoAlgorithmIdentifier::HKDF_CTR:
507 case CryptoAlgorithmIdentifier::PBKDF2:
508 setDOMException(exec, NOT_SUPPORTED_ERR);
511 RELEASE_ASSERT_NOT_REACHED();
515 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
518 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
519 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
520 case CryptoAlgorithmIdentifier::RSA_PSS:
521 case CryptoAlgorithmIdentifier::RSA_OAEP:
522 return createRsaKeyGenParams(*exec, value);
523 case CryptoAlgorithmIdentifier::ECDSA:
524 case CryptoAlgorithmIdentifier::ECDH:
525 setDOMException(exec, NOT_SUPPORTED_ERR);
527 case CryptoAlgorithmIdentifier::AES_CTR:
528 case CryptoAlgorithmIdentifier::AES_CBC:
529 case CryptoAlgorithmIdentifier::AES_CMAC:
530 case CryptoAlgorithmIdentifier::AES_GCM:
531 case CryptoAlgorithmIdentifier::AES_CFB:
532 case CryptoAlgorithmIdentifier::AES_KW:
533 return createAesKeyGenParams(*exec, value);
534 case CryptoAlgorithmIdentifier::HMAC:
535 return createHmacKeyParams(*exec, value);
536 case CryptoAlgorithmIdentifier::DH:
537 case CryptoAlgorithmIdentifier::SHA_1:
538 case CryptoAlgorithmIdentifier::SHA_224:
539 case CryptoAlgorithmIdentifier::SHA_256:
540 case CryptoAlgorithmIdentifier::SHA_384:
541 case CryptoAlgorithmIdentifier::SHA_512:
542 case CryptoAlgorithmIdentifier::CONCAT:
543 case CryptoAlgorithmIdentifier::HKDF_CTR:
544 case CryptoAlgorithmIdentifier::PBKDF2:
545 setDOMException(exec, NOT_SUPPORTED_ERR);
548 RELEASE_ASSERT_NOT_REACHED();
552 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
555 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
556 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
557 case CryptoAlgorithmIdentifier::RSA_PSS:
558 case CryptoAlgorithmIdentifier::RSA_OAEP:
559 case CryptoAlgorithmIdentifier::ECDSA:
560 case CryptoAlgorithmIdentifier::ECDH:
561 case CryptoAlgorithmIdentifier::AES_CTR:
562 case CryptoAlgorithmIdentifier::AES_CBC:
563 case CryptoAlgorithmIdentifier::AES_CMAC:
564 case CryptoAlgorithmIdentifier::AES_GCM:
565 case CryptoAlgorithmIdentifier::AES_CFB:
566 case CryptoAlgorithmIdentifier::AES_KW:
567 case CryptoAlgorithmIdentifier::HMAC:
568 case CryptoAlgorithmIdentifier::DH:
569 case CryptoAlgorithmIdentifier::SHA_1:
570 case CryptoAlgorithmIdentifier::SHA_224:
571 case CryptoAlgorithmIdentifier::SHA_256:
572 case CryptoAlgorithmIdentifier::SHA_384:
573 case CryptoAlgorithmIdentifier::SHA_512:
574 case CryptoAlgorithmIdentifier::CONCAT:
575 case CryptoAlgorithmIdentifier::HKDF_CTR:
576 case CryptoAlgorithmIdentifier::PBKDF2:
577 setDOMException(exec, NOT_SUPPORTED_ERR);
580 RELEASE_ASSERT_NOT_REACHED();
584 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
587 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
588 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
589 case CryptoAlgorithmIdentifier::RSA_PSS:
590 case CryptoAlgorithmIdentifier::RSA_OAEP:
591 case CryptoAlgorithmIdentifier::ECDSA:
592 case CryptoAlgorithmIdentifier::ECDH:
593 case CryptoAlgorithmIdentifier::AES_CTR:
594 case CryptoAlgorithmIdentifier::AES_CBC:
595 case CryptoAlgorithmIdentifier::AES_CMAC:
596 case CryptoAlgorithmIdentifier::AES_GCM:
597 case CryptoAlgorithmIdentifier::AES_CFB:
598 case CryptoAlgorithmIdentifier::AES_KW:
599 case CryptoAlgorithmIdentifier::HMAC:
600 case CryptoAlgorithmIdentifier::DH:
601 case CryptoAlgorithmIdentifier::SHA_1:
602 case CryptoAlgorithmIdentifier::SHA_224:
603 case CryptoAlgorithmIdentifier::SHA_256:
604 case CryptoAlgorithmIdentifier::SHA_384:
605 case CryptoAlgorithmIdentifier::SHA_512:
606 case CryptoAlgorithmIdentifier::CONCAT:
607 case CryptoAlgorithmIdentifier::HKDF_CTR:
608 case CryptoAlgorithmIdentifier::PBKDF2:
609 setDOMException(exec, NOT_SUPPORTED_ERR);
612 RELEASE_ASSERT_NOT_REACHED();
616 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
619 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
620 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
621 case CryptoAlgorithmIdentifier::RSA_PSS:
622 case CryptoAlgorithmIdentifier::RSA_OAEP:
623 return createRsaKeyParamsWithHash(*exec, value);
624 case CryptoAlgorithmIdentifier::ECDSA:
625 case CryptoAlgorithmIdentifier::ECDH:
626 case CryptoAlgorithmIdentifier::AES_CTR:
627 case CryptoAlgorithmIdentifier::AES_CBC:
628 case CryptoAlgorithmIdentifier::AES_CMAC:
629 case CryptoAlgorithmIdentifier::AES_GCM:
630 case CryptoAlgorithmIdentifier::AES_CFB:
631 case CryptoAlgorithmIdentifier::AES_KW:
632 return adoptRef(*new CryptoAlgorithmParameters);
633 case CryptoAlgorithmIdentifier::HMAC:
634 return createHmacParams(*exec, value);
635 case CryptoAlgorithmIdentifier::DH:
636 return adoptRef(*new CryptoAlgorithmParameters);
637 case CryptoAlgorithmIdentifier::SHA_1:
638 case CryptoAlgorithmIdentifier::SHA_224:
639 case CryptoAlgorithmIdentifier::SHA_256:
640 case CryptoAlgorithmIdentifier::SHA_384:
641 case CryptoAlgorithmIdentifier::SHA_512:
642 case CryptoAlgorithmIdentifier::CONCAT:
643 case CryptoAlgorithmIdentifier::HKDF_CTR:
644 case CryptoAlgorithmIdentifier::PBKDF2:
645 setDOMException(exec, NOT_SUPPORTED_ERR);
648 RELEASE_ASSERT_NOT_REACHED();
652 RefPtr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue)
655 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
656 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
657 case CryptoAlgorithmIdentifier::RSA_PSS:
658 case CryptoAlgorithmIdentifier::RSA_OAEP:
659 case CryptoAlgorithmIdentifier::ECDSA:
660 case CryptoAlgorithmIdentifier::ECDH:
661 case CryptoAlgorithmIdentifier::AES_CTR:
662 case CryptoAlgorithmIdentifier::AES_CBC:
663 case CryptoAlgorithmIdentifier::AES_CMAC:
664 case CryptoAlgorithmIdentifier::AES_GCM:
665 case CryptoAlgorithmIdentifier::AES_CFB:
666 case CryptoAlgorithmIdentifier::AES_KW:
667 case CryptoAlgorithmIdentifier::HMAC:
668 case CryptoAlgorithmIdentifier::DH:
669 return adoptRef(*new CryptoAlgorithmParameters);
670 case CryptoAlgorithmIdentifier::SHA_1:
671 case CryptoAlgorithmIdentifier::SHA_224:
672 case CryptoAlgorithmIdentifier::SHA_256:
673 case CryptoAlgorithmIdentifier::SHA_384:
674 case CryptoAlgorithmIdentifier::SHA_512:
675 case CryptoAlgorithmIdentifier::CONCAT:
676 case CryptoAlgorithmIdentifier::HKDF_CTR:
677 case CryptoAlgorithmIdentifier::PBKDF2:
678 setDOMException(exec, NOT_SUPPORTED_ERR);
681 RELEASE_ASSERT_NOT_REACHED();
687 #endif // ENABLE(SUBTLE_CRYPTO)