| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 private: | 240 private: |
| 241 AlgorithmOperation m_op; | 241 AlgorithmOperation m_op; |
| 242 | 242 |
| 243 // This inline size is large enough to avoid having to grow the Vector in | 243 // This inline size is large enough to avoid having to grow the Vector in |
| 244 // the majority of cases (up to 1 nested algorithm identifier). | 244 // the majority of cases (up to 1 nested algorithm identifier). |
| 245 Vector<const char*, 10> m_messages; | 245 Vector<const char*, 10> m_messages; |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 bool getArrayBufferView(const Dictionary& raw, const char* propertyName, RefPtr<
ArrayBufferView>& buffer, const ExceptionContext& context, ExceptionState& es) | 248 bool getArrayBufferView(const Dictionary& raw, const char* propertyName, RefPtr<
ArrayBufferView>& buffer, const ExceptionContext& context, ExceptionState& excep
tionState) |
| 249 { | 249 { |
| 250 if (!raw.get(propertyName, buffer) || !buffer) { | 250 if (!raw.get(propertyName, buffer) || !buffer) { |
| 251 es.throwTypeError(context.toString(propertyName, "Missing or not a Array
BufferView")); | 251 exceptionState.throwTypeError(context.toString(propertyName, "Missing or
not a ArrayBufferView")); |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool getUint8Array(const Dictionary& raw, const char* propertyName, RefPtr<Uint8
Array>& array, const ExceptionContext& context, ExceptionState& es) | 257 bool getUint8Array(const Dictionary& raw, const char* propertyName, RefPtr<Uint8
Array>& array, const ExceptionContext& context, ExceptionState& exceptionState) |
| 258 { | 258 { |
| 259 if (!raw.get(propertyName, array) || !array) { | 259 if (!raw.get(propertyName, array) || !array) { |
| 260 es.throwTypeError(context.toString(propertyName, "Missing or not a Uint8
Array")); | 260 exceptionState.throwTypeError(context.toString(propertyName, "Missing or
not a Uint8Array")); |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 return true; | 263 return true; |
| 264 } | 264 } |
| 265 | 265 |
| 266 // Gets an integer according to WebIDL's [EnforceRange]. | 266 // Gets an integer according to WebIDL's [EnforceRange]. |
| 267 bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& h
asProperty, double& value, double minValue, double maxValue, const ExceptionCont
ext& context, ExceptionState& es) | 267 bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& h
asProperty, double& value, double minValue, double maxValue, const ExceptionCont
ext& context, ExceptionState& exceptionState) |
| 268 { | 268 { |
| 269 double number; | 269 double number; |
| 270 bool ok = raw.get(propertyName, number, hasProperty); | 270 bool ok = raw.get(propertyName, number, hasProperty); |
| 271 | 271 |
| 272 if (!hasProperty) | 272 if (!hasProperty) |
| 273 return true; | 273 return true; |
| 274 | 274 |
| 275 if (!ok || std::isnan(number)) { | 275 if (!ok || std::isnan(number)) { |
| 276 es.throwTypeError(context.toString(propertyName, "Is not a number")); | 276 exceptionState.throwTypeError(context.toString(propertyName, "Is not a n
umber")); |
| 277 return false; | 277 return false; |
| 278 } | 278 } |
| 279 | 279 |
| 280 number = trunc(number); | 280 number = trunc(number); |
| 281 | 281 |
| 282 if (std::isinf(number) || number < minValue || number > maxValue) { | 282 if (std::isinf(number) || number < minValue || number > maxValue) { |
| 283 es.throwTypeError(context.toString(propertyName, "Outside of numeric ran
ge")); | 283 exceptionState.throwTypeError(context.toString(propertyName, "Outside of
numeric range")); |
| 284 return false; | 284 return false; |
| 285 } | 285 } |
| 286 | 286 |
| 287 value = number; | 287 value = number; |
| 288 return true; | 288 return true; |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool getInteger(const Dictionary& raw, const char* propertyName, double& value,
double minValue, double maxValue, const ExceptionContext& context, ExceptionStat
e& es) | 291 bool getInteger(const Dictionary& raw, const char* propertyName, double& value,
double minValue, double maxValue, const ExceptionContext& context, ExceptionStat
e& exceptionState) |
| 292 { | 292 { |
| 293 bool hasProperty; | 293 bool hasProperty; |
| 294 if (!getOptionalInteger(raw, propertyName, hasProperty, value, minValue, max
Value, context, es)) | 294 if (!getOptionalInteger(raw, propertyName, hasProperty, value, minValue, max
Value, context, exceptionState)) |
| 295 return false; | 295 return false; |
| 296 | 296 |
| 297 if (!hasProperty) { | 297 if (!hasProperty) { |
| 298 es.throwTypeError(context.toString(propertyName, "Missing required prope
rty")); | 298 exceptionState.throwTypeError(context.toString(propertyName, "Missing re
quired property")); |
| 299 return false; | 299 return false; |
| 300 } | 300 } |
| 301 | 301 |
| 302 return true; | 302 return true; |
| 303 } | 303 } |
| 304 | 304 |
| 305 bool getUint32(const Dictionary& raw, const char* propertyName, uint32_t& value,
const ExceptionContext& context, ExceptionState& es) | 305 bool getUint32(const Dictionary& raw, const char* propertyName, uint32_t& value,
const ExceptionContext& context, ExceptionState& exceptionState) |
| 306 { | 306 { |
| 307 double number; | 307 double number; |
| 308 if (!getInteger(raw, propertyName, number, 0, 0xFFFFFFFF, context, es)) | 308 if (!getInteger(raw, propertyName, number, 0, 0xFFFFFFFF, context, exception
State)) |
| 309 return false; | 309 return false; |
| 310 value = number; | 310 value = number; |
| 311 return true; | 311 return true; |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool getUint16(const Dictionary& raw, const char* propertyName, uint16_t& value,
const ExceptionContext& context, ExceptionState& es) | 314 bool getUint16(const Dictionary& raw, const char* propertyName, uint16_t& value,
const ExceptionContext& context, ExceptionState& exceptionState) |
| 315 { | 315 { |
| 316 double number; | 316 double number; |
| 317 if (!getInteger(raw, propertyName, number, 0, 0xFFFF, context, es)) | 317 if (!getInteger(raw, propertyName, number, 0, 0xFFFF, context, exceptionStat
e)) |
| 318 return false; | 318 return false; |
| 319 value = number; | 319 value = number; |
| 320 return true; | 320 return true; |
| 321 } | 321 } |
| 322 | 322 |
| 323 bool getOptionalUint32(const Dictionary& raw, const char* propertyName, bool& ha
sValue, uint32_t& value, const ExceptionContext& context, ExceptionState& es) | 323 bool getOptionalUint32(const Dictionary& raw, const char* propertyName, bool& ha
sValue, uint32_t& value, const ExceptionContext& context, ExceptionState& except
ionState) |
| 324 { | 324 { |
| 325 double number; | 325 double number; |
| 326 if (!getOptionalInteger(raw, propertyName, hasValue, number, 0, 0xFFFFFFFF,
context, es)) | 326 if (!getOptionalInteger(raw, propertyName, hasValue, number, 0, 0xFFFFFFFF,
context, exceptionState)) |
| 327 return false; | 327 return false; |
| 328 if (hasValue) | 328 if (hasValue) |
| 329 value = number; | 329 value = number; |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool parseAesCbcParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa
rams>& params, const ExceptionContext& context, ExceptionState& es) | 333 bool parseAesCbcParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa
rams>& params, const ExceptionContext& context, ExceptionState& exceptionState) |
| 334 { | 334 { |
| 335 RefPtr<ArrayBufferView> iv; | 335 RefPtr<ArrayBufferView> iv; |
| 336 if (!getArrayBufferView(raw, "iv", iv, context, es)) | 336 if (!getArrayBufferView(raw, "iv", iv, context, exceptionState)) |
| 337 return false; | 337 return false; |
| 338 | 338 |
| 339 if (iv->byteLength() != 16) { | 339 if (iv->byteLength() != 16) { |
| 340 es.throwTypeError(context.toString("iv", "Must be 16 bytes")); | 340 exceptionState.throwTypeError(context.toString("iv", "Must be 16 bytes")
); |
| 341 return false; | 341 return false; |
| 342 } | 342 } |
| 343 | 343 |
| 344 params = adoptPtr(new blink::WebCryptoAesCbcParams(static_cast<unsigned char
*>(iv->baseAddress()), iv->byteLength())); | 344 params = adoptPtr(new blink::WebCryptoAesCbcParams(static_cast<unsigned char
*>(iv->baseAddress()), iv->byteLength())); |
| 345 return true; | 345 return true; |
| 346 } | 346 } |
| 347 | 347 |
| 348 bool parseAesKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith
mParams>& params, const ExceptionContext& context, ExceptionState& es) | 348 bool parseAesKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith
mParams>& params, const ExceptionContext& context, ExceptionState& exceptionStat
e) |
| 349 { | 349 { |
| 350 uint16_t length; | 350 uint16_t length; |
| 351 if (!getUint16(raw, "length", length, context, es)) | 351 if (!getUint16(raw, "length", length, context, exceptionState)) |
| 352 return false; | 352 return false; |
| 353 | 353 |
| 354 params = adoptPtr(new blink::WebCryptoAesKeyGenParams(length)); | 354 params = adoptPtr(new blink::WebCryptoAesKeyGenParams(length)); |
| 355 return true; | 355 return true; |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool normalizeAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoA
lgorithm&, ExceptionContext, ExceptionState&); | 358 bool normalizeAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoA
lgorithm&, ExceptionContext, ExceptionState&); |
| 359 | 359 |
| 360 bool parseHash(const Dictionary& raw, blink::WebCryptoAlgorithm& hash, Exception
Context context, ExceptionState& es) | 360 bool parseHash(const Dictionary& raw, blink::WebCryptoAlgorithm& hash, Exception
Context context, ExceptionState& exceptionState) |
| 361 { | 361 { |
| 362 Dictionary rawHash; | 362 Dictionary rawHash; |
| 363 if (!raw.get("hash", rawHash)) { | 363 if (!raw.get("hash", rawHash)) { |
| 364 es.throwTypeError(context.toString("hash", "Missing or not a dictionary"
)); | 364 exceptionState.throwTypeError(context.toString("hash", "Missing or not a
dictionary")); |
| 365 return false; | 365 return false; |
| 366 } | 366 } |
| 367 | 367 |
| 368 context.add("hash"); | 368 context.add("hash"); |
| 369 return normalizeAlgorithm(rawHash, Digest, hash, context, es); | 369 return normalizeAlgorithm(rawHash, Digest, hash, context, exceptionState); |
| 370 } | 370 } |
| 371 | 371 |
| 372 bool parseHmacParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPara
ms>& params, const ExceptionContext& context, ExceptionState& es) | 372 bool parseHmacParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPara
ms>& params, const ExceptionContext& context, ExceptionState& exceptionState) |
| 373 { | 373 { |
| 374 blink::WebCryptoAlgorithm hash; | 374 blink::WebCryptoAlgorithm hash; |
| 375 if (!parseHash(raw, hash, context, es)) | 375 if (!parseHash(raw, hash, context, exceptionState)) |
| 376 return false; | 376 return false; |
| 377 | 377 |
| 378 params = adoptPtr(new blink::WebCryptoHmacParams(hash)); | 378 params = adoptPtr(new blink::WebCryptoHmacParams(hash)); |
| 379 return true; | 379 return true; |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool parseHmacKeyParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmP
arams>& params, const ExceptionContext& context, ExceptionState& es) | 382 bool parseHmacKeyParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmP
arams>& params, const ExceptionContext& context, ExceptionState& exceptionState) |
| 383 { | 383 { |
| 384 blink::WebCryptoAlgorithm hash; | 384 blink::WebCryptoAlgorithm hash; |
| 385 if (!parseHash(raw, hash, context, es)) | 385 if (!parseHash(raw, hash, context, exceptionState)) |
| 386 return false; | 386 return false; |
| 387 | 387 |
| 388 bool hasLength; | 388 bool hasLength; |
| 389 uint32_t length = 0; | 389 uint32_t length = 0; |
| 390 if (!getOptionalUint32(raw, "length", hasLength, length, context, es)) | 390 if (!getOptionalUint32(raw, "length", hasLength, length, context, exceptionS
tate)) |
| 391 return false; | 391 return false; |
| 392 | 392 |
| 393 params = adoptPtr(new blink::WebCryptoHmacKeyParams(hash, hasLength, length)
); | 393 params = adoptPtr(new blink::WebCryptoHmacKeyParams(hash, hasLength, length)
); |
| 394 return true; | 394 return true; |
| 395 } | 395 } |
| 396 | 396 |
| 397 bool parseRsaSsaParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa
rams>& params, const ExceptionContext& context, ExceptionState& es) | 397 bool parseRsaSsaParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa
rams>& params, const ExceptionContext& context, ExceptionState& exceptionState) |
| 398 { | 398 { |
| 399 blink::WebCryptoAlgorithm hash; | 399 blink::WebCryptoAlgorithm hash; |
| 400 if (!parseHash(raw, hash, context, es)) | 400 if (!parseHash(raw, hash, context, exceptionState)) |
| 401 return false; | 401 return false; |
| 402 | 402 |
| 403 params = adoptPtr(new blink::WebCryptoRsaSsaParams(hash)); | 403 params = adoptPtr(new blink::WebCryptoRsaSsaParams(hash)); |
| 404 return true; | 404 return true; |
| 405 } | 405 } |
| 406 | 406 |
| 407 bool parseRsaKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith
mParams>& params, const ExceptionContext& context, ExceptionState& es) | 407 bool parseRsaKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith
mParams>& params, const ExceptionContext& context, ExceptionState& exceptionStat
e) |
| 408 { | 408 { |
| 409 uint32_t modulusLength; | 409 uint32_t modulusLength; |
| 410 if (!getUint32(raw, "modulusLength", modulusLength, context, es)) | 410 if (!getUint32(raw, "modulusLength", modulusLength, context, exceptionState)
) |
| 411 return false; | 411 return false; |
| 412 | 412 |
| 413 RefPtr<Uint8Array> publicExponent; | 413 RefPtr<Uint8Array> publicExponent; |
| 414 if (!getUint8Array(raw, "publicExponent", publicExponent, context, es)) | 414 if (!getUint8Array(raw, "publicExponent", publicExponent, context, exception
State)) |
| 415 return false; | 415 return false; |
| 416 | 416 |
| 417 params = adoptPtr(new blink::WebCryptoRsaKeyGenParams(modulusLength, static_
cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteL
ength())); | 417 params = adoptPtr(new blink::WebCryptoRsaKeyGenParams(modulusLength, static_
cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteL
ength())); |
| 418 return true; | 418 return true; |
| 419 } | 419 } |
| 420 | 420 |
| 421 bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParams
Type type, OwnPtr<blink::WebCryptoAlgorithmParams>& params, ExceptionContext& co
ntext, ExceptionState& es) | 421 bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParams
Type type, OwnPtr<blink::WebCryptoAlgorithmParams>& params, ExceptionContext& co
ntext, ExceptionState& exceptionState) |
| 422 { | 422 { |
| 423 switch (type) { | 423 switch (type) { |
| 424 case blink::WebCryptoAlgorithmParamsTypeNone: | 424 case blink::WebCryptoAlgorithmParamsTypeNone: |
| 425 return true; | 425 return true; |
| 426 case blink::WebCryptoAlgorithmParamsTypeAesCbcParams: | 426 case blink::WebCryptoAlgorithmParamsTypeAesCbcParams: |
| 427 context.add("AesCbcParams"); | 427 context.add("AesCbcParams"); |
| 428 return parseAesCbcParams(raw, params, context, es); | 428 return parseAesCbcParams(raw, params, context, exceptionState); |
| 429 case blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams: | 429 case blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams: |
| 430 context.add("AesKeyGenParams"); | 430 context.add("AesKeyGenParams"); |
| 431 return parseAesKeyGenParams(raw, params, context, es); | 431 return parseAesKeyGenParams(raw, params, context, exceptionState); |
| 432 case blink::WebCryptoAlgorithmParamsTypeHmacParams: | 432 case blink::WebCryptoAlgorithmParamsTypeHmacParams: |
| 433 context.add("HmacParams"); | 433 context.add("HmacParams"); |
| 434 return parseHmacParams(raw, params, context, es); | 434 return parseHmacParams(raw, params, context, exceptionState); |
| 435 case blink::WebCryptoAlgorithmParamsTypeHmacKeyParams: | 435 case blink::WebCryptoAlgorithmParamsTypeHmacKeyParams: |
| 436 context.add("HmacKeyParams"); | 436 context.add("HmacKeyParams"); |
| 437 return parseHmacKeyParams(raw, params, context, es); | 437 return parseHmacKeyParams(raw, params, context, exceptionState); |
| 438 case blink::WebCryptoAlgorithmParamsTypeRsaSsaParams: | 438 case blink::WebCryptoAlgorithmParamsTypeRsaSsaParams: |
| 439 context.add("RsaSSaParams"); | 439 context.add("RsaSSaParams"); |
| 440 return parseRsaSsaParams(raw, params, context, es); | 440 return parseRsaSsaParams(raw, params, context, exceptionState); |
| 441 case blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams: | 441 case blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams: |
| 442 context.add("RsaKeyGenParams"); | 442 context.add("RsaKeyGenParams"); |
| 443 return parseRsaKeyGenParams(raw, params, context, es); | 443 return parseRsaKeyGenParams(raw, params, context, exceptionState); |
| 444 case blink::WebCryptoAlgorithmParamsTypeAesGcmParams: | 444 case blink::WebCryptoAlgorithmParamsTypeAesGcmParams: |
| 445 case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams: | 445 case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams: |
| 446 // TODO | 446 // TODO |
| 447 notImplemented(); | 447 notImplemented(); |
| 448 break; | 448 break; |
| 449 } | 449 } |
| 450 ASSERT_NOT_REACHED(); | 450 ASSERT_NOT_REACHED(); |
| 451 return false; | 451 return false; |
| 452 } | 452 } |
| 453 | 453 |
| 454 const AlgorithmInfo* algorithmInfo(const Dictionary& raw, const ExceptionContext
& context, ExceptionState& es) | 454 const AlgorithmInfo* algorithmInfo(const Dictionary& raw, const ExceptionContext
& context, ExceptionState& exceptionState) |
| 455 { | 455 { |
| 456 if (!raw.isObject()) { | 456 if (!raw.isObject()) { |
| 457 es.throwTypeError(context.toString("Not an object")); | 457 exceptionState.throwTypeError(context.toString("Not an object")); |
| 458 return 0; | 458 return 0; |
| 459 } | 459 } |
| 460 | 460 |
| 461 String algorithmName; | 461 String algorithmName; |
| 462 if (!raw.get("name", algorithmName)) { | 462 if (!raw.get("name", algorithmName)) { |
| 463 es.throwTypeError(context.toString("name", "Missing or not a string")); | 463 exceptionState.throwTypeError(context.toString("name", "Missing or not a
string")); |
| 464 return 0; | 464 return 0; |
| 465 } | 465 } |
| 466 | 466 |
| 467 const AlgorithmInfo* info = AlgorithmRegistry::instance().lookupAlgorithmByN
ame(algorithmName); | 467 const AlgorithmInfo* info = AlgorithmRegistry::instance().lookupAlgorithmByN
ame(algorithmName); |
| 468 if (!info) { | 468 if (!info) { |
| 469 es.throwDOMException(NotSupportedError, context.toString("Unrecognized a
lgorithm name")); | 469 exceptionState.throwDOMException(NotSupportedError, context.toString("Un
recognized algorithm name")); |
| 470 return 0; | 470 return 0; |
| 471 } | 471 } |
| 472 | 472 |
| 473 return info; | 473 return info; |
| 474 } | 474 } |
| 475 | 475 |
| 476 // This implementation corresponds with: | 476 // This implementation corresponds with: |
| 477 // http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules | 477 // http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules |
| 478 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::Web
CryptoAlgorithm& algorithm, ExceptionContext context, ExceptionState& es) | 478 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::Web
CryptoAlgorithm& algorithm, ExceptionContext context, ExceptionState& exceptionS
tate) |
| 479 { | 479 { |
| 480 context.add("Algorithm"); | 480 context.add("Algorithm"); |
| 481 | 481 |
| 482 const AlgorithmInfo* info = algorithmInfo(raw, context, es); | 482 const AlgorithmInfo* info = algorithmInfo(raw, context, exceptionState); |
| 483 if (!info) | 483 if (!info) |
| 484 return false; | 484 return false; |
| 485 | 485 |
| 486 context.add(info->algorithmName); | 486 context.add(info->algorithmName); |
| 487 | 487 |
| 488 if (info->paramsForOperation[op] == UnsupportedOp) { | 488 if (info->paramsForOperation[op] == UnsupportedOp) { |
| 489 es.throwDOMException(NotSupportedError, context.toString("Unsupported op
eration")); | 489 exceptionState.throwDOMException(NotSupportedError, context.toString("Un
supported operation")); |
| 490 return false; | 490 return false; |
| 491 } | 491 } |
| 492 | 492 |
| 493 blink::WebCryptoAlgorithmParamsType paramsType = static_cast<blink::WebCrypt
oAlgorithmParamsType>(info->paramsForOperation[op]); | 493 blink::WebCryptoAlgorithmParamsType paramsType = static_cast<blink::WebCrypt
oAlgorithmParamsType>(info->paramsForOperation[op]); |
| 494 OwnPtr<blink::WebCryptoAlgorithmParams> params; | 494 OwnPtr<blink::WebCryptoAlgorithmParams> params; |
| 495 if (!parseAlgorithmParams(raw, paramsType, params, context, es)) | 495 if (!parseAlgorithmParams(raw, paramsType, params, context, exceptionState)) |
| 496 return false; | 496 return false; |
| 497 | 497 |
| 498 algorithm = blink::WebCryptoAlgorithm(info->algorithmId, params.release()); | 498 algorithm = blink::WebCryptoAlgorithm(info->algorithmId, params.release()); |
| 499 return true; | 499 return true; |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace | 502 } // namespace |
| 503 | 503 |
| 504 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::Web
CryptoAlgorithm& algorithm, ExceptionState& es) | 504 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::Web
CryptoAlgorithm& algorithm, ExceptionState& exceptionState) |
| 505 { | 505 { |
| 506 return normalizeAlgorithm(raw, op, algorithm, ExceptionContext(op), es); | 506 return normalizeAlgorithm(raw, op, algorithm, ExceptionContext(op), exceptio
nState); |
| 507 } | 507 } |
| 508 | 508 |
| 509 const char* algorithmIdToName(blink::WebCryptoAlgorithmId id) | 509 const char* algorithmIdToName(blink::WebCryptoAlgorithmId id) |
| 510 { | 510 { |
| 511 return AlgorithmRegistry::instance().lookupAlgorithmById(id)->algorithmName; | 511 return AlgorithmRegistry::instance().lookupAlgorithmById(id)->algorithmName; |
| 512 } | 512 } |
| 513 | 513 |
| 514 const char* algorithmOperationToName(AlgorithmOperation op) | 514 const char* algorithmOperationToName(AlgorithmOperation op) |
| 515 { | 515 { |
| 516 switch (op) { | 516 switch (op) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 536 return "unwrapKey"; | 536 return "unwrapKey"; |
| 537 case NumberOfAlgorithmOperations: | 537 case NumberOfAlgorithmOperations: |
| 538 ASSERT_NOT_REACHED(); | 538 ASSERT_NOT_REACHED(); |
| 539 return "unknown"; | 539 return "unknown"; |
| 540 }; | 540 }; |
| 541 ASSERT_NOT_REACHED(); | 541 ASSERT_NOT_REACHED(); |
| 542 return "unknown"; | 542 return "unknown"; |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace WebCore | 545 } // namespace WebCore |
| OLD | NEW |