Changeset 209900 in webkit
- Timestamp:
- Dec 15, 2016 7:01:14 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r209897 r209900 1 2016-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 1 16 2016-12-15 Filip Pizlo <fpizlo@apple.com> 2 17 -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp
r209801 r209900 33 33 #include "CryptoAlgorithmHmacKeyParamsDeprecated.h" 34 34 #include "CryptoAlgorithmHmacParamsDeprecated.h" 35 #include "CryptoAlgorithmParameters.h" 35 36 #include "CryptoAlgorithmRegistry.h" 36 37 #include "CryptoAlgorithmRsaKeyGenParamsDeprecated.h" … … 38 39 #include "CryptoAlgorithmRsaOaepParamsDeprecated.h" 39 40 #include "CryptoAlgorithmRsaSsaParamsDeprecated.h" 40 #include "Dictionary.h"41 41 #include "ExceptionCode.h" 42 42 #include "JSCryptoOperationData.h" … … 53 53 }; 54 54 55 bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier) 56 { 57 VM& vm = exec->vm(); 58 auto scope = DECLARE_THROW_SCOPE(vm); 55 static inline JSValue getProperty(ExecState& state, JSObject* object, const char* name) 56 { 57 return object->get(&state, Identifier::fromString(&state, name)); 58 } 59 60 bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState& state, JSValue value, CryptoAlgorithmIdentifier& algorithmIdentifier) 61 { 62 auto scope = DECLARE_THROW_SCOPE(state.vm()); 59 63 60 64 // typedef (Algorithm or DOMString) AlgorithmIdentifier; … … 62 66 String algorithmName; 63 67 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 { 70 76 // FIXME: This doesn't perform some checks mandated by WebIDL for dictionaries: 71 77 // - null and undefined input should be treated as if all elements in the dictionary were undefined; … … 76 82 // WebCrypto doesn't yet clearly specify what to do with non-present values in most cases anyway. 77 83 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); 80 89 } 81 90 } 82 91 83 RETURN_IF_EXCEPTION(scope, false);84 85 92 if (!algorithmName.containsOnlyASCII()) { 86 throwSyntaxError( exec, scope);93 throwSyntaxError(&state, scope); 87 94 return false; 88 95 } … … 90 97 auto identifier = CryptoAlgorithmRegistry::singleton().identifier(algorithmName); 91 98 if (!identifier) { 92 setDOMException( exec, NOT_SUPPORTED_ERR);99 setDOMException(&state, NOT_SUPPORTED_ERR); 93 100 return false; 94 101 } … … 98 105 } 99 106 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"); 107 static 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"); 117 112 RETURN_IF_EXCEPTION(scope, false); 118 113 119 114 if (hash.isUndefinedOrNull()) { 120 115 if (isRequired == HashRequirement::Required) 121 setDOMException( exec, NOT_SUPPORTED_ERR);116 setDOMException(&state, NOT_SUPPORTED_ERR); 122 117 return false; 123 118 } 124 119 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 123 static RefPtr<CryptoAlgorithmParametersDeprecated> createAesCbcParams(ExecState& state, JSValue value) 124 { 125 auto scope = DECLARE_THROW_SCOPE(state.vm()); 132 126 133 127 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"); 139 133 RETURN_IF_EXCEPTION(scope, nullptr); 140 134 … … 142 136 143 137 CryptoOperationData ivData; 144 auto success = cryptoOperationDataFromJSValue( exec, iv, ivData);138 auto success = cryptoOperationDataFromJSValue(state, iv, ivData); 145 139 ASSERT(scope.exception() || success); 146 140 if (!success) … … 148 142 149 143 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")); 151 145 return nullptr; 152 146 } … … 159 153 static RefPtr<CryptoAlgorithmParametersDeprecated> createAesKeyGenParams(ExecState& state, JSValue value) 160 154 { 161 VM& vm = state.vm(); 162 auto scope = DECLARE_THROW_SCOPE(vm); 155 auto scope = DECLARE_THROW_SCOPE(state.vm()); 163 156 164 157 if (!value.isObject()) { … … 169 162 auto result = adoptRef(*new CryptoAlgorithmAesKeyGenParamsDeprecated); 170 163 171 JSValue lengthValue = getProperty(&state, value.getObject(), "length");164 auto lengthValue = getProperty(state, asObject(value), "length"); 172 165 RETURN_IF_EXCEPTION(scope, nullptr); 173 166 … … 179 172 static RefPtr<CryptoAlgorithmParametersDeprecated> createHmacParams(ExecState& state, JSValue value) 180 173 { 181 VM& vm = state.vm(); 182 auto scope = DECLARE_THROW_SCOPE(vm); 174 auto scope = DECLARE_THROW_SCOPE(state.vm()); 183 175 184 176 if (!value.isObject()) { … … 187 179 } 188 180 189 Dictionary dictionary(&state, value.getObject());190 181 auto result = adoptRef(*new CryptoAlgorithmHmacParamsDeprecated); 191 182 192 auto success = getHashAlgorithm( dictionary, result->hash, HashRequirement::Required);183 auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required); 193 184 ASSERT_UNUSED(scope, scope.exception() || success); 194 185 if (!success) … … 200 191 static RefPtr<CryptoAlgorithmParametersDeprecated> createHmacKeyParams(ExecState& state, JSValue value) 201 192 { 202 VM& vm = state.vm(); 203 auto scope = DECLARE_THROW_SCOPE(vm); 193 auto scope = DECLARE_THROW_SCOPE(state.vm()); 204 194 205 195 if (!value.isObject()) { … … 208 198 } 209 199 210 Dictionary dictionary(&state, value.getObject());211 200 auto result = adoptRef(*new CryptoAlgorithmHmacKeyParamsDeprecated); 212 201 213 auto success = getHashAlgorithm( dictionary, result->hash, HashRequirement::Required);202 auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required); 214 203 ASSERT(scope.exception() || success); 215 204 if (!success) 216 205 return nullptr; 217 206 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; 220 214 221 215 return WTFMove(result); … … 224 218 static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaKeyGenParams(ExecState& state, JSValue value) 225 219 { 226 VM& vm = state.vm(); 227 auto scope = DECLARE_THROW_SCOPE(vm); 220 auto scope = DECLARE_THROW_SCOPE(state.vm()); 228 221 229 222 if (!value.isObject()) { … … 232 225 } 233 226 234 Dictionary dictionary(&state, value.getObject());235 227 auto result = adoptRef(*new CryptoAlgorithmRsaKeyGenParamsDeprecated); 236 228 237 JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength");229 auto modulusLengthValue = getProperty(state, asObject(value), "modulusLength"); 238 230 RETURN_IF_EXCEPTION(scope, nullptr); 239 231 … … 242 234 RETURN_IF_EXCEPTION(scope, nullptr); 243 235 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); 248 240 if (!publicExponentArray) { 249 241 throwTypeError(&state, scope, ASCIILiteral("Expected a Uint8Array in publicExponent")); … … 252 244 result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength()); 253 245 254 result->hasHash = getHashAlgorithm( dictionary, result->hash, HashRequirement::Optional);246 result->hasHash = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Optional); 255 247 256 248 return WTFMove(result); … … 263 255 } 264 256 265 static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaOaepParams(ExecState* exec, JSValue value) 266 { 267 VM& vm = exec->vm(); 268 auto scope = DECLARE_THROW_SCOPE(vm); 257 static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaOaepParams(ExecState& state, JSValue value) 258 { 259 auto scope = DECLARE_THROW_SCOPE(state.vm()); 269 260 270 261 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 276 266 auto result = adoptRef(*new CryptoAlgorithmRsaOaepParamsDeprecated); 277 267 278 auto success = getHashAlgorithm( dictionary, result->hash, HashRequirement::Required);268 auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required); 279 269 ASSERT(scope.exception() || success); 280 270 if (!success) 281 271 return nullptr; 282 272 283 JSValue labelValue = getProperty(exec, value.getObject(), "label");273 auto labelValue = getProperty(state, asObject(value), "label"); 284 274 RETURN_IF_EXCEPTION(scope, nullptr); 285 275 … … 289 279 290 280 CryptoOperationData labelData; 291 success = cryptoOperationDataFromJSValue( exec, labelValue, labelData);281 success = cryptoOperationDataFromJSValue(state, labelValue, labelData); 292 282 ASSERT(scope.exception() || success); 293 283 if (!success) … … 301 291 static RefPtr<CryptoAlgorithmParametersDeprecated> createRsaSsaParams(ExecState& state, JSValue value) 302 292 { 303 VM& vm = state.vm(); 304 auto scope = DECLARE_THROW_SCOPE(vm); 293 auto scope = DECLARE_THROW_SCOPE(state.vm()); 305 294 306 295 if (!value.isObject()) { … … 309 298 } 310 299 311 Dictionary dictionary(&state, value.getObject());312 300 auto result = adoptRef(*new CryptoAlgorithmRsaSsaParamsDeprecated); 313 301 314 auto success = getHashAlgorithm( dictionary, result->hash, HashRequirement::Required);302 auto success = getHashAlgorithm(state, asObject(value), result->hash, HashRequirement::Required); 315 303 ASSERT(scope.exception() || success); 316 304 if (!success) … … 320 308 } 321 309 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);310 RefPtr<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 352 RefPtr<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 394 RefPtr<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 432 RefPtr<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 470 RefPtr<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 505 RefPtr<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 542 RefPtr<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 574 RefPtr<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 606 RefPtr<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 642 RefPtr<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); 681 669 return nullptr; 682 670 } -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.h
r208179 r209900 42 42 class JSCryptoAlgorithmDictionary { 43 43 public: 44 static bool getAlgorithmIdentifier(JSC::ExecState *, JSC::JSValue, CryptoAlgorithmIdentifier&);44 static bool getAlgorithmIdentifier(JSC::ExecState&, JSC::JSValue, CryptoAlgorithmIdentifier&); 45 45 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); 56 56 }; 57 57 -
trunk/Source/WebCore/bindings/js/JSCryptoOperationData.cpp
r208209 r209900 35 35 namespace WebCore { 36 36 37 bool cryptoOperationDataFromJSValue(ExecState * exec, JSValue value, CryptoOperationData& result)37 bool cryptoOperationDataFromJSValue(ExecState& state, JSValue value, CryptoOperationData& result) 38 38 { 39 VM& vm = exec->vm(); 40 auto scope = DECLARE_THROW_SCOPE(vm); 39 auto scope = DECLARE_THROW_SCOPE(state.vm()); 41 40 42 41 if (ArrayBuffer* buffer = toUnsharedArrayBuffer(value)) … … 45 44 result = std::make_pair(static_cast<uint8_t*>(bufferView->baseAddress()), bufferView->byteLength()); 46 45 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")); 48 47 return false; 49 48 } -
trunk/Source/WebCore/bindings/js/JSCryptoOperationData.h
r208179 r209900 37 37 typedef std::pair<const uint8_t*, size_t> CryptoOperationData; 38 38 39 bool cryptoOperationDataFromJSValue(JSC::ExecState *, JSC::JSValue, CryptoOperationData&);39 bool cryptoOperationDataFromJSValue(JSC::ExecState&, JSC::JSValue, CryptoOperationData&); 40 40 41 41 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp
r209801 r209900 69 69 70 70 CryptoAlgorithmIdentifier algorithmIdentifier; 71 auto success = JSCryptoAlgorithmDictionary::getAlgorithmIdentifier( &state, value, algorithmIdentifier);71 auto success = JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(state, value, algorithmIdentifier); 72 72 ASSERT_UNUSED(scope, scope.exception() || success); 73 73 if (!success) … … 152 152 return jsUndefined(); 153 153 154 auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt( &state, algorithm->identifier(), state.uncheckedArgument(0));154 auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(state, algorithm->identifier(), state.uncheckedArgument(0)); 155 155 ASSERT(scope.exception() || parameters); 156 156 if (!parameters) … … 168 168 169 169 CryptoOperationData data; 170 auto success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(2), data);170 auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), data); 171 171 ASSERT(scope.exception() || success); 172 172 if (!success) … … 204 204 return jsUndefined(); 205 205 206 auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt( &state, algorithm->identifier(), state.uncheckedArgument(0));206 auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(state, algorithm->identifier(), state.uncheckedArgument(0)); 207 207 ASSERT(scope.exception() || parameters); 208 208 if (!parameters) … … 220 220 221 221 CryptoOperationData data; 222 auto success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(2), data);222 auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), data); 223 223 ASSERT(scope.exception() || success); 224 224 if (!success) … … 256 256 return jsUndefined(); 257 257 258 auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign( &state, algorithm->identifier(), state.uncheckedArgument(0));258 auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(state, algorithm->identifier(), state.uncheckedArgument(0)); 259 259 ASSERT(scope.exception() || parameters); 260 260 if (!parameters) … … 272 272 273 273 CryptoOperationData data; 274 auto success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(2), data);274 auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), data); 275 275 ASSERT(scope.exception() || success); 276 276 if (!success) … … 308 308 return jsUndefined(); 309 309 310 auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify( &state, algorithm->identifier(), state.uncheckedArgument(0));310 auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(state, algorithm->identifier(), state.uncheckedArgument(0)); 311 311 ASSERT(scope.exception() || parameters); 312 312 if (!parameters) … … 324 324 325 325 CryptoOperationData signature; 326 auto success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(2), signature);326 auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(2), signature); 327 327 ASSERT(scope.exception() || success); 328 328 if (!success) … … 330 330 331 331 CryptoOperationData data; 332 success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(3), data);332 success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(3), data); 333 333 ASSERT(scope.exception() || success); 334 334 if (!success) … … 366 366 return jsUndefined(); 367 367 368 auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest( &state, algorithm->identifier(), state.uncheckedArgument(0));368 auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(state, algorithm->identifier(), state.uncheckedArgument(0)); 369 369 ASSERT(scope.exception() || parameters); 370 370 if (!parameters) … … 372 372 373 373 CryptoOperationData data; 374 auto success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(1), data);374 auto success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(1), data); 375 375 ASSERT(scope.exception() || success); 376 376 if (!success) … … 408 408 return jsUndefined(); 409 409 410 auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey( &state, algorithm->identifier(), state.uncheckedArgument(0));410 auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(state, algorithm->identifier(), state.uncheckedArgument(0)); 411 411 ASSERT(scope.exception() || parameters); 412 412 if (!parameters) … … 522 522 523 523 CryptoOperationData data; 524 success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(1), data);524 success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(1), data); 525 525 ASSERT(scope.exception() || success); 526 526 if (!success) … … 535 535 return jsUndefined(); 536 536 537 parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey( &state, algorithm->identifier(), state.uncheckedArgument(2));537 parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(state, algorithm->identifier(), state.uncheckedArgument(2)); 538 538 ASSERT(scope.exception() || parameters); 539 539 if (!parameters) … … 670 670 return jsUndefined(); 671 671 672 auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt( &state, algorithm->identifier(), state.uncheckedArgument(3));672 auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(state, algorithm->identifier(), state.uncheckedArgument(3)); 673 673 ASSERT(scope.exception() || parameters); 674 674 if (!parameters) … … 716 716 717 717 CryptoOperationData wrappedKeyData; 718 success = cryptoOperationDataFromJSValue( &state, state.uncheckedArgument(1), wrappedKeyData);718 success = cryptoOperationDataFromJSValue(state, state.uncheckedArgument(1), wrappedKeyData); 719 719 ASSERT(scope.exception() || success); 720 720 if (!success) … … 735 735 if (!unwrapAlgorithm) 736 736 return jsUndefined(); 737 auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt( &state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3));737 auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3)); 738 738 ASSERT(scope.exception() || unwrapAlgorithmParameters); 739 739 if (!unwrapAlgorithmParameters) … … 748 748 return jsUndefined(); 749 749 750 unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey( &state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4));750 unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4)); 751 751 ASSERT(scope.exception() || unwrappedKeyAlgorithmParameters); 752 752 if (!unwrappedKeyAlgorithmParameters)
Note: See TracChangeset
for help on using the changeset viewer.