Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1006)

Side by Side Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 295423004: Expose WebCrypto's algorithm normalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comments. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/crypto/NormalizeAlgorithm.h" 32 #include "modules/crypto/NormalizeAlgorithm.h"
33 33
34 #include "bindings/v8/Dictionary.h" 34 #include "bindings/v8/Dictionary.h"
35 #include "platform/CryptoResult.h"
36 #include "platform/NotImplemented.h" 35 #include "platform/NotImplemented.h"
37 #include "public/platform/WebCryptoAlgorithmParams.h" 36 #include "public/platform/WebCryptoAlgorithmParams.h"
38 #include "public/platform/WebString.h" 37 #include "public/platform/WebString.h"
39 #include "wtf/ArrayBuffer.h" 38 #include "wtf/ArrayBuffer.h"
40 #include "wtf/ArrayBufferView.h" 39 #include "wtf/ArrayBufferView.h"
41 #include "wtf/MathExtras.h" 40 #include "wtf/MathExtras.h"
42 #include "wtf/Uint8Array.h" 41 #include "wtf/Uint8Array.h"
43 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
44 #include "wtf/text/StringBuilder.h" 43 #include "wtf/text/StringBuilder.h"
45 #include <algorithm> 44 #include <algorithm>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 77
79 typedef char ParamsTypeOrUndefined; 78 typedef char ParamsTypeOrUndefined;
80 const ParamsTypeOrUndefined Undefined = -1; 79 const ParamsTypeOrUndefined Undefined = -1;
81 80
82 struct AlgorithmInfo { 81 struct AlgorithmInfo {
83 // The canonical (case-sensitive) name for the algorithm. 82 // The canonical (case-sensitive) name for the algorithm.
84 const char* name; 83 const char* name;
85 84
86 // A map from the operation to the expected parameter type of the algorithm. 85 // A map from the operation to the expected parameter type of the algorithm.
87 // If an operation is not applicable for the algorithm, set to Undefined. 86 // If an operation is not applicable for the algorithm, set to Undefined.
88 const ParamsTypeOrUndefined operationToParamsType[LastAlgorithmOperation + 1 ]; 87 const ParamsTypeOrUndefined operationToParamsType[blink::WebCryptoOperationL ast + 1];
89 }; 88 };
90 89
91 // A mapping from the algorithm ID to information about the algorithm. 90 // A mapping from the algorithm ID to information about the algorithm.
92 const AlgorithmInfo algorithmIdToInfo[] = { 91 const AlgorithmInfo algorithmIdToInfo[] = {
93 { // Index 0 92 { // Index 0
94 "AES-CBC", { 93 "AES-CBC", {
95 blink::WebCryptoAlgorithmParamsTypeAesCbcParams, // Encrypt 94 blink::WebCryptoAlgorithmParamsTypeAesCbcParams, // Encrypt
96 blink::WebCryptoAlgorithmParamsTypeAesCbcParams, // Decrypt 95 blink::WebCryptoAlgorithmParamsTypeAesCbcParams, // Decrypt
97 Undefined, // Sign 96 Undefined, // Sign
98 Undefined, // Verify 97 Undefined, // Verify
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_ idDoesntMatch); 254 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_ idDoesntMatch);
256 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch); 255 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch);
257 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch); 256 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch);
258 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch); 257 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch);
259 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch); 258 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch);
260 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch); 259 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch);
261 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch); 260 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch);
262 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch); 261 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch);
263 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch); 262 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch);
264 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdLast == 10, Last_idDoesntMatch); 263 COMPILE_ASSERT(blink::WebCryptoAlgorithmIdLast == 10, Last_idDoesntMatch);
265 COMPILE_ASSERT(10 == LastAlgorithmOperation, UpdateParamsMapping); 264 COMPILE_ASSERT(10 == blink::WebCryptoOperationLast, UpdateParamsMapping);
266 265
267 #if ASSERT_ENABLED 266 #if ASSERT_ENABLED
268 267
269 // Essentially std::is_sorted() (however that function is new to C++11). 268 // Essentially std::is_sorted() (however that function is new to C++11).
270 template <typename Iterator> 269 template <typename Iterator>
271 bool isSorted(Iterator begin, Iterator end) 270 bool isSorted(Iterator begin, Iterator end)
272 { 271 {
273 if (begin == end) 272 if (begin == end)
274 return true; 273 return true;
275 274
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return true; 372 return true;
374 } 373 }
375 374
376 const AlgorithmInfo* lookupAlgorithmInfo(blink::WebCryptoAlgorithmId id) 375 const AlgorithmInfo* lookupAlgorithmInfo(blink::WebCryptoAlgorithmId id)
377 { 376 {
378 if (id < 0 || id >= WTF_ARRAY_LENGTH(algorithmIdToInfo)) 377 if (id < 0 || id >= WTF_ARRAY_LENGTH(algorithmIdToInfo))
379 return 0; 378 return 0;
380 return &algorithmIdToInfo[id]; 379 return &algorithmIdToInfo[id];
381 } 380 }
382 381
383 void completeWithSyntaxError(const String& message, CryptoResult* result) 382 void setSyntaxError(const String& message, AlgorithmError* error)
384 { 383 {
385 result->completeWithError(blink::WebCryptoErrorTypeSyntax, message); 384 error->errorType = blink::WebCryptoErrorTypeSyntax;
385 error->errorDetails = message;
386 } 386 }
387 387
388 void completeWithNotSupportedError(const String& message, CryptoResult* result) 388 void setNotSupportedError(const String& message, AlgorithmError* error)
389 { 389 {
390 result->completeWithError(blink::WebCryptoErrorTypeNotSupported, message); 390 error->errorType = blink::WebCryptoErrorTypeNotSupported;
391 error->errorDetails = message;
391 } 392 }
392 393
393 void completeWithDataError(const String& message, CryptoResult* result) 394 void setDataError(const String& message, AlgorithmError* error)
394 { 395 {
395 result->completeWithError(blink::WebCryptoErrorTypeData, message); 396 error->errorType = blink::WebCryptoErrorTypeData;
397 error->errorDetails = message;
396 } 398 }
397 399
398 // ErrorContext holds a stack of string literals which describe what was 400 // ErrorContext holds a stack of string literals which describe what was
399 // happening at the time the error occurred. This is helpful because 401 // happening at the time the error occurred. This is helpful because
400 // parsing of the algorithm dictionary can be recursive and it is difficult to 402 // parsing of the algorithm dictionary can be recursive and it is difficult to
401 // tell what went wrong from a failure alone. 403 // tell what went wrong from a failure alone.
402 class ErrorContext { 404 class ErrorContext {
403 public: 405 public:
404 void add(const char* message) 406 void add(const char* message)
405 { 407 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // This inline size is large enough to avoid having to grow the Vector in 455 // This inline size is large enough to avoid having to grow the Vector in
454 // the majority of cases (up to 1 nested algorithm identifier). 456 // the majority of cases (up to 1 nested algorithm identifier).
455 Vector<const char*, 10> m_messages; 457 Vector<const char*, 10> m_messages;
456 }; 458 };
457 459
458 // Defined by the WebCrypto spec as: 460 // Defined by the WebCrypto spec as:
459 // 461 //
460 // typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData; 462 // typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData;
461 // 463 //
462 // FIXME: Currently only supports ArrayBufferView. 464 // FIXME: Currently only supports ArrayBufferView.
463 bool getOptionalCryptoOperationData(const Dictionary& raw, const char* propertyN ame, bool& hasProperty, RefPtr<ArrayBufferView>& buffer, const ErrorContext& con text, CryptoResult* result) 465 bool getOptionalCryptoOperationData(const Dictionary& raw, const char* propertyN ame, bool& hasProperty, RefPtr<ArrayBufferView>& buffer, const ErrorContext& con text, AlgorithmError* error)
464 { 466 {
465 if (!raw.get(propertyName, buffer)) { 467 if (!raw.get(propertyName, buffer)) {
466 hasProperty = false; 468 hasProperty = false;
467 return true; 469 return true;
468 } 470 }
469 471
470 hasProperty = true; 472 hasProperty = true;
471 473
472 if (!buffer) { 474 if (!buffer) {
473 completeWithSyntaxError(context.toString(propertyName, "Not an ArrayBuff erView"), result); 475 setSyntaxError(context.toString(propertyName, "Not an ArrayBufferView"), error);
474 return false; 476 return false;
475 } 477 }
476 478
477 return true; 479 return true;
478 } 480 }
479 481
480 // Defined by the WebCrypto spec as: 482 // Defined by the WebCrypto spec as:
481 // 483 //
482 // typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData; 484 // typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData;
483 // 485 //
484 // FIXME: Currently only supports ArrayBufferView. 486 // FIXME: Currently only supports ArrayBufferView.
485 bool getCryptoOperationData(const Dictionary& raw, const char* propertyName, Ref Ptr<ArrayBufferView>& buffer, const ErrorContext& context, CryptoResult* result) 487 bool getCryptoOperationData(const Dictionary& raw, const char* propertyName, Ref Ptr<ArrayBufferView>& buffer, const ErrorContext& context, AlgorithmError* error )
486 { 488 {
487 bool hasProperty; 489 bool hasProperty;
488 bool ok = getOptionalCryptoOperationData(raw, propertyName, hasProperty, buf fer, context, result); 490 bool ok = getOptionalCryptoOperationData(raw, propertyName, hasProperty, buf fer, context, error);
489 if (!hasProperty) { 491 if (!hasProperty) {
490 completeWithSyntaxError(context.toString(propertyName, "Missing required property"), result); 492 setSyntaxError(context.toString(propertyName, "Missing required property "), error);
491 return false; 493 return false;
492 } 494 }
493 return ok; 495 return ok;
494 } 496 }
495 497
496 bool getUint8Array(const Dictionary& raw, const char* propertyName, RefPtr<Uint8 Array>& array, const ErrorContext& context, CryptoResult* result) 498 bool getUint8Array(const Dictionary& raw, const char* propertyName, RefPtr<Uint8 Array>& array, const ErrorContext& context, AlgorithmError* error)
497 { 499 {
498 if (!raw.get(propertyName, array) || !array) { 500 if (!raw.get(propertyName, array) || !array) {
499 completeWithSyntaxError(context.toString(propertyName, "Missing or not a Uint8Array"), result); 501 setSyntaxError(context.toString(propertyName, "Missing or not a Uint8Arr ay"), error);
500 return false; 502 return false;
501 } 503 }
502 return true; 504 return true;
503 } 505 }
504 506
505 // Defined by the WebCrypto spec as: 507 // Defined by the WebCrypto spec as:
506 // 508 //
507 // typedef Uint8Array BigInteger; 509 // typedef Uint8Array BigInteger;
508 bool getBigInteger(const Dictionary& raw, const char* propertyName, RefPtr<Uint8 Array>& array, const ErrorContext& context, CryptoResult* result) 510 bool getBigInteger(const Dictionary& raw, const char* propertyName, RefPtr<Uint8 Array>& array, const ErrorContext& context, AlgorithmError* error)
509 { 511 {
510 if (!getUint8Array(raw, propertyName, array, context, result)) 512 if (!getUint8Array(raw, propertyName, array, context, error))
511 return false; 513 return false;
512 514
513 if (!array->byteLength()) { 515 if (!array->byteLength()) {
514 completeWithSyntaxError(context.toString(propertyName, "BigInteger shoul d not be empty"), result); 516 setSyntaxError(context.toString(propertyName, "BigInteger should not be empty"), error);
515 return false; 517 return false;
516 } 518 }
517 519
518 if (!raw.get(propertyName, array) || !array) { 520 if (!raw.get(propertyName, array) || !array) {
519 completeWithSyntaxError(context.toString(propertyName, "Missing or not a Uint8Array"), result); 521 setSyntaxError(context.toString(propertyName, "Missing or not a Uint8Arr ay"), error);
520 return false; 522 return false;
521 } 523 }
522 return true; 524 return true;
523 } 525 }
524 526
525 // Gets an integer according to WebIDL's [EnforceRange]. 527 // Gets an integer according to WebIDL's [EnforceRange].
526 bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& h asProperty, double& value, double minValue, double maxValue, const ErrorContext& context, CryptoResult* result) 528 bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& h asProperty, double& value, double minValue, double maxValue, const ErrorContext& context, AlgorithmError* error)
527 { 529 {
528 double number; 530 double number;
529 bool ok = raw.get(propertyName, number, hasProperty); 531 bool ok = raw.get(propertyName, number, hasProperty);
530 532
531 if (!hasProperty) 533 if (!hasProperty)
532 return true; 534 return true;
533 535
534 if (!ok || std::isnan(number)) { 536 if (!ok || std::isnan(number)) {
535 completeWithSyntaxError(context.toString(propertyName, "Is not a number" ), result); 537 setSyntaxError(context.toString(propertyName, "Is not a number"), error) ;
536 return false; 538 return false;
537 } 539 }
538 540
539 number = trunc(number); 541 number = trunc(number);
540 542
541 if (std::isinf(number) || number < minValue || number > maxValue) { 543 if (std::isinf(number) || number < minValue || number > maxValue) {
542 completeWithSyntaxError(context.toString(propertyName, "Outside of numer ic range"), result); 544 setSyntaxError(context.toString(propertyName, "Outside of numeric range" ), error);
543 return false; 545 return false;
544 } 546 }
545 547
546 value = number; 548 value = number;
547 return true; 549 return true;
548 } 550 }
549 551
550 bool getInteger(const Dictionary& raw, const char* propertyName, double& value, double minValue, double maxValue, const ErrorContext& context, CryptoResult* res ult) 552 bool getInteger(const Dictionary& raw, const char* propertyName, double& value, double minValue, double maxValue, const ErrorContext& context, AlgorithmError* e rror)
551 { 553 {
552 bool hasProperty; 554 bool hasProperty;
553 if (!getOptionalInteger(raw, propertyName, hasProperty, value, minValue, max Value, context, result)) 555 if (!getOptionalInteger(raw, propertyName, hasProperty, value, minValue, max Value, context, error))
554 return false; 556 return false;
555 557
556 if (!hasProperty) { 558 if (!hasProperty) {
557 completeWithSyntaxError(context.toString(propertyName, "Missing required property"), result); 559 setSyntaxError(context.toString(propertyName, "Missing required property "), error);
558 return false; 560 return false;
559 } 561 }
560 562
561 return true; 563 return true;
562 } 564 }
563 565
564 bool getUint32(const Dictionary& raw, const char* propertyName, uint32_t& value, const ErrorContext& context, CryptoResult* result) 566 bool getUint32(const Dictionary& raw, const char* propertyName, uint32_t& value, const ErrorContext& context, AlgorithmError* error)
565 { 567 {
566 double number; 568 double number;
567 if (!getInteger(raw, propertyName, number, 0, 0xFFFFFFFF, context, result)) 569 if (!getInteger(raw, propertyName, number, 0, 0xFFFFFFFF, context, error))
568 return false; 570 return false;
569 value = number; 571 value = number;
570 return true; 572 return true;
571 } 573 }
572 574
573 bool getUint16(const Dictionary& raw, const char* propertyName, uint16_t& value, const ErrorContext& context, CryptoResult* result) 575 bool getUint16(const Dictionary& raw, const char* propertyName, uint16_t& value, const ErrorContext& context, AlgorithmError* error)
574 { 576 {
575 double number; 577 double number;
576 if (!getInteger(raw, propertyName, number, 0, 0xFFFF, context, result)) 578 if (!getInteger(raw, propertyName, number, 0, 0xFFFF, context, error))
577 return false; 579 return false;
578 value = number; 580 value = number;
579 return true; 581 return true;
580 } 582 }
581 583
582 bool getUint8(const Dictionary& raw, const char* propertyName, uint8_t& value, c onst ErrorContext& context, CryptoResult* result) 584 bool getUint8(const Dictionary& raw, const char* propertyName, uint8_t& value, c onst ErrorContext& context, AlgorithmError* error)
583 { 585 {
584 double number; 586 double number;
585 if (!getInteger(raw, propertyName, number, 0, 0xFF, context, result)) 587 if (!getInteger(raw, propertyName, number, 0, 0xFF, context, error))
586 return false; 588 return false;
587 value = number; 589 value = number;
588 return true; 590 return true;
589 } 591 }
590 592
591 bool getOptionalUint32(const Dictionary& raw, const char* propertyName, bool& ha sValue, uint32_t& value, const ErrorContext& context, CryptoResult* result) 593 bool getOptionalUint32(const Dictionary& raw, const char* propertyName, bool& ha sValue, uint32_t& value, const ErrorContext& context, AlgorithmError* error)
592 { 594 {
593 double number; 595 double number;
594 if (!getOptionalInteger(raw, propertyName, hasValue, number, 0, 0xFFFFFFFF, context, result)) 596 if (!getOptionalInteger(raw, propertyName, hasValue, number, 0, 0xFFFFFFFF, context, error))
595 return false; 597 return false;
596 if (hasValue) 598 if (hasValue)
597 value = number; 599 value = number;
598 return true; 600 return true;
599 } 601 }
600 602
601 // Defined by the WebCrypto spec as: 603 // Defined by the WebCrypto spec as:
602 // 604 //
603 // dictionary AesCbcParams : Algorithm { 605 // dictionary AesCbcParams : Algorithm {
604 // CryptoOperationData iv; 606 // CryptoOperationData iv;
605 // }; 607 // };
606 bool parseAesCbcParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, CryptoResult* result) 608 bool parseAesCbcParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, AlgorithmError* error)
607 { 609 {
608 RefPtr<ArrayBufferView> iv; 610 RefPtr<ArrayBufferView> iv;
609 if (!getCryptoOperationData(raw, "iv", iv, context, result)) 611 if (!getCryptoOperationData(raw, "iv", iv, context, error))
610 return false; 612 return false;
611 613
612 if (iv->byteLength() != 16) { 614 if (iv->byteLength() != 16) {
613 completeWithDataError(context.toString("iv", "Must be 16 bytes"), result ); 615 setDataError(context.toString("iv", "Must be 16 bytes"), error);
614 return false; 616 return false;
615 } 617 }
616 618
617 params = adoptPtr(new blink::WebCryptoAesCbcParams(static_cast<unsigned char *>(iv->baseAddress()), iv->byteLength())); 619 params = adoptPtr(new blink::WebCryptoAesCbcParams(static_cast<unsigned char *>(iv->baseAddress()), iv->byteLength()));
618 return true; 620 return true;
619 } 621 }
620 622
621 // Defined by the WebCrypto spec as: 623 // Defined by the WebCrypto spec as:
622 // 624 //
623 // dictionary AesKeyGenParams : Algorithm { 625 // dictionary AesKeyGenParams : Algorithm {
624 // [EnforceRange] unsigned short length; 626 // [EnforceRange] unsigned short length;
625 // }; 627 // };
626 bool parseAesKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith mParams>& params, const ErrorContext& context, CryptoResult* result) 628 bool parseAesKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorith mParams>& params, const ErrorContext& context, AlgorithmError* error)
627 { 629 {
628 uint16_t length; 630 uint16_t length;
629 if (!getUint16(raw, "length", length, context, result)) 631 if (!getUint16(raw, "length", length, context, error))
630 return false; 632 return false;
631 633
632 params = adoptPtr(new blink::WebCryptoAesKeyGenParams(length)); 634 params = adoptPtr(new blink::WebCryptoAesKeyGenParams(length));
633 return true; 635 return true;
634 } 636 }
635 637
636 bool parseAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoAlgor ithm&, ErrorContext, CryptoResult*); 638 bool parseAlgorithm(const Dictionary&, blink::WebCryptoOperation, blink::WebCryp toAlgorithm&, ErrorContext, AlgorithmError*);
637 639
638 bool parseHash(const Dictionary& raw, blink::WebCryptoAlgorithm& hash, ErrorCont ext context, CryptoResult* result) 640 bool parseHash(const Dictionary& raw, blink::WebCryptoAlgorithm& hash, ErrorCont ext context, AlgorithmError* error)
639 { 641 {
640 Dictionary rawHash; 642 Dictionary rawHash;
641 if (!raw.get("hash", rawHash)) { 643 if (!raw.get("hash", rawHash)) {
642 completeWithSyntaxError(context.toString("hash", "Missing or not a dicti onary"), result); 644 setSyntaxError(context.toString("hash", "Missing or not a dictionary"), error);
643 return false; 645 return false;
644 } 646 }
645 647
646 context.add("hash"); 648 context.add("hash");
647 return parseAlgorithm(rawHash, Digest, hash, context, result); 649 return parseAlgorithm(rawHash, blink::WebCryptoOperationDigest, hash, contex t, error);
648 } 650 }
649 651
650 // Defined by the WebCrypto spec as: 652 // Defined by the WebCrypto spec as:
651 // 653 //
652 // dictionary HmacImportParams : Algorithm { 654 // dictionary HmacImportParams : Algorithm {
653 // AlgorithmIdentifier hash; 655 // AlgorithmIdentifier hash;
654 // }; 656 // };
655 bool parseHmacImportParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorit hmParams>& params, const ErrorContext& context, CryptoResult* result) 657 bool parseHmacImportParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorit hmParams>& params, const ErrorContext& context, AlgorithmError* error)
656 { 658 {
657 blink::WebCryptoAlgorithm hash; 659 blink::WebCryptoAlgorithm hash;
658 if (!parseHash(raw, hash, context, result)) 660 if (!parseHash(raw, hash, context, error))
659 return false; 661 return false;
660 662
661 params = adoptPtr(new blink::WebCryptoHmacImportParams(hash)); 663 params = adoptPtr(new blink::WebCryptoHmacImportParams(hash));
662 return true; 664 return true;
663 } 665 }
664 666
665 // Defined by the WebCrypto spec as: 667 // Defined by the WebCrypto spec as:
666 // 668 //
667 // dictionary HmacKeyGenParams : Algorithm { 669 // dictionary HmacKeyGenParams : Algorithm {
668 // AlgorithmIdentifier hash; 670 // AlgorithmIdentifier hash;
669 // // The length (in bits) of the key to generate. If unspecified, the 671 // // The length (in bits) of the key to generate. If unspecified, the
670 // // recommended length will be used, which is the size of the associated hash function's block 672 // // recommended length will be used, which is the size of the associated hash function's block
671 // // size. 673 // // size.
672 // unsigned long length; 674 // unsigned long length;
673 // }; 675 // };
674 bool parseHmacKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorit hmParams>& params, const ErrorContext& context, CryptoResult* result) 676 bool parseHmacKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorit hmParams>& params, const ErrorContext& context, AlgorithmError* error)
675 { 677 {
676 blink::WebCryptoAlgorithm hash; 678 blink::WebCryptoAlgorithm hash;
677 if (!parseHash(raw, hash, context, result)) 679 if (!parseHash(raw, hash, context, error))
678 return false; 680 return false;
679 681
680 bool hasLength; 682 bool hasLength;
681 uint32_t length = 0; 683 uint32_t length = 0;
682 if (!getOptionalUint32(raw, "length", hasLength, length, context, result)) 684 if (!getOptionalUint32(raw, "length", hasLength, length, context, error))
683 return false; 685 return false;
684 686
685 params = adoptPtr(new blink::WebCryptoHmacKeyGenParams(hash, hasLength, leng th)); 687 params = adoptPtr(new blink::WebCryptoHmacKeyGenParams(hash, hasLength, leng th));
686 return true; 688 return true;
687 } 689 }
688 690
689 // Defined by the WebCrypto spec as: 691 // Defined by the WebCrypto spec as:
690 // 692 //
691 // dictionary RsaHashedImportParams { 693 // dictionary RsaHashedImportParams {
692 // AlgorithmIdentifier hash; 694 // AlgorithmIdentifier hash;
693 // }; 695 // };
694 bool parseRsaHashedImportParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAl gorithmParams>& params, const ErrorContext& context, CryptoResult* result) 696 bool parseRsaHashedImportParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAl gorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
695 { 697 {
696 blink::WebCryptoAlgorithm hash; 698 blink::WebCryptoAlgorithm hash;
697 if (!parseHash(raw, hash, context, result)) 699 if (!parseHash(raw, hash, context, error))
698 return false; 700 return false;
699 701
700 params = adoptPtr(new blink::WebCryptoRsaHashedImportParams(hash)); 702 params = adoptPtr(new blink::WebCryptoRsaHashedImportParams(hash));
701 return true; 703 return true;
702 } 704 }
703 705
704 // Defined by the WebCrypto spec as: 706 // Defined by the WebCrypto spec as:
705 // 707 //
706 // dictionary RsaHashedKeyGenParams : RsaKeyGenParams { 708 // dictionary RsaHashedKeyGenParams : RsaKeyGenParams {
707 // AlgorithmIdentifier hash; 709 // AlgorithmIdentifier hash;
708 // }; 710 // };
709 // 711 //
710 // dictionary RsaKeyGenParams : Algorithm { 712 // dictionary RsaKeyGenParams : Algorithm {
711 // unsigned long modulusLength; 713 // unsigned long modulusLength;
712 // BigInteger publicExponent; 714 // BigInteger publicExponent;
713 // }; 715 // };
714 bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAl gorithmParams>& params, const ErrorContext& context, CryptoResult* result) 716 bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAl gorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
715 { 717 {
716 uint32_t modulusLength; 718 uint32_t modulusLength;
717 if (!getUint32(raw, "modulusLength", modulusLength, context, result)) 719 if (!getUint32(raw, "modulusLength", modulusLength, context, error))
718 return false; 720 return false;
719 721
720 RefPtr<Uint8Array> publicExponent; 722 RefPtr<Uint8Array> publicExponent;
721 if (!getBigInteger(raw, "publicExponent", publicExponent, context, result)) 723 if (!getBigInteger(raw, "publicExponent", publicExponent, context, error))
722 return false; 724 return false;
723 725
724 blink::WebCryptoAlgorithm hash; 726 blink::WebCryptoAlgorithm hash;
725 if (!parseHash(raw, hash, context, result)) 727 if (!parseHash(raw, hash, context, error))
726 return false; 728 return false;
727 729
728 params = adoptPtr(new blink::WebCryptoRsaHashedKeyGenParams(hash, modulusLen gth, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExp onent->byteLength())); 730 params = adoptPtr(new blink::WebCryptoRsaHashedKeyGenParams(hash, modulusLen gth, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExp onent->byteLength()));
729 return true; 731 return true;
730 } 732 }
731 733
732 // Defined by the WebCrypto spec as: 734 // Defined by the WebCrypto spec as:
733 // 735 //
734 // dictionary AesCtrParams : Algorithm { 736 // dictionary AesCtrParams : Algorithm {
735 // CryptoOperationData counter; 737 // CryptoOperationData counter;
736 // [EnforceRange] octet length; 738 // [EnforceRange] octet length;
737 // }; 739 // };
738 bool parseAesCtrParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, CryptoResult* result) 740 bool parseAesCtrParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, AlgorithmError* error)
739 { 741 {
740 RefPtr<ArrayBufferView> counter; 742 RefPtr<ArrayBufferView> counter;
741 if (!getCryptoOperationData(raw, "counter", counter, context, result)) 743 if (!getCryptoOperationData(raw, "counter", counter, context, error))
742 return false; 744 return false;
743 745
744 uint8_t length; 746 uint8_t length;
745 if (!getUint8(raw, "length", length, context, result)) 747 if (!getUint8(raw, "length", length, context, error))
746 return false; 748 return false;
747 749
748 params = adoptPtr(new blink::WebCryptoAesCtrParams(length, static_cast<const unsigned char*>(counter->baseAddress()), counter->byteLength())); 750 params = adoptPtr(new blink::WebCryptoAesCtrParams(length, static_cast<const unsigned char*>(counter->baseAddress()), counter->byteLength()));
749 return true; 751 return true;
750 } 752 }
751 753
752 // Defined by the WebCrypto spec as: 754 // Defined by the WebCrypto spec as:
753 // 755 //
754 // dictionary AesGcmParams : Algorithm { 756 // dictionary AesGcmParams : Algorithm {
755 // CryptoOperationData iv; 757 // CryptoOperationData iv;
756 // CryptoOperationData? additionalData; 758 // CryptoOperationData? additionalData;
757 // [EnforceRange] octet? tagLength; // May be 0-128 759 // [EnforceRange] octet? tagLength; // May be 0-128
758 // } 760 // }
759 bool parseAesGcmParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, CryptoResult* result) 761 bool parseAesGcmParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa rams>& params, const ErrorContext& context, AlgorithmError* error)
760 { 762 {
761 RefPtr<ArrayBufferView> iv; 763 RefPtr<ArrayBufferView> iv;
762 if (!getCryptoOperationData(raw, "iv", iv, context, result)) 764 if (!getCryptoOperationData(raw, "iv", iv, context, error))
763 return false; 765 return false;
764 766
765 bool hasAdditionalData; 767 bool hasAdditionalData;
766 RefPtr<ArrayBufferView> additionalData; 768 RefPtr<ArrayBufferView> additionalData;
767 if (!getOptionalCryptoOperationData(raw, "additionalData", hasAdditionalData , additionalData, context, result)) 769 if (!getOptionalCryptoOperationData(raw, "additionalData", hasAdditionalData , additionalData, context, error))
768 return false; 770 return false;
769 771
770 double tagLength; 772 double tagLength;
771 bool hasTagLength; 773 bool hasTagLength;
772 if (!getOptionalInteger(raw, "tagLength", hasTagLength, tagLength, 0, 128, c ontext, result)) 774 if (!getOptionalInteger(raw, "tagLength", hasTagLength, tagLength, 0, 128, c ontext, error))
773 return false; 775 return false;
774 776
775 const unsigned char* ivStart = static_cast<const unsigned char*>(iv->baseAdd ress()); 777 const unsigned char* ivStart = static_cast<const unsigned char*>(iv->baseAdd ress());
776 unsigned ivLength = iv->byteLength(); 778 unsigned ivLength = iv->byteLength();
777 779
778 const unsigned char* additionalDataStart = hasAdditionalData ? static_cast<c onst unsigned char*>(additionalData->baseAddress()) : 0; 780 const unsigned char* additionalDataStart = hasAdditionalData ? static_cast<c onst unsigned char*>(additionalData->baseAddress()) : 0;
779 unsigned additionalDataLength = hasAdditionalData ? additionalData->byteLeng th() : 0; 781 unsigned additionalDataLength = hasAdditionalData ? additionalData->byteLeng th() : 0;
780 782
781 params = adoptPtr(new blink::WebCryptoAesGcmParams(ivStart, ivLength, hasAdd itionalData, additionalDataStart, additionalDataLength, hasTagLength, tagLength) ); 783 params = adoptPtr(new blink::WebCryptoAesGcmParams(ivStart, ivLength, hasAdd itionalData, additionalDataStart, additionalDataLength, hasTagLength, tagLength) );
782 return true; 784 return true;
783 } 785 }
784 786
785 // Defined by the WebCrypto spec as: 787 // Defined by the WebCrypto spec as:
786 // 788 //
787 // dictionary RsaOaepParams : Algorithm { 789 // dictionary RsaOaepParams : Algorithm {
788 // CryptoOperationData? label; 790 // CryptoOperationData? label;
789 // }; 791 // };
790 bool parseRsaOaepParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmP arams>& params, const ErrorContext& context, CryptoResult* result) 792 bool parseRsaOaepParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmP arams>& params, const ErrorContext& context, AlgorithmError* error)
791 { 793 {
792 bool hasLabel; 794 bool hasLabel;
793 RefPtr<ArrayBufferView> label; 795 RefPtr<ArrayBufferView> label;
794 if (!getOptionalCryptoOperationData(raw, "label", hasLabel, label, context, result)) 796 if (!getOptionalCryptoOperationData(raw, "label", hasLabel, label, context, error))
795 return false; 797 return false;
796 798
797 const unsigned char* labelStart = hasLabel ? static_cast<const unsigned char *>(label->baseAddress()) : 0; 799 const unsigned char* labelStart = hasLabel ? static_cast<const unsigned char *>(label->baseAddress()) : 0;
798 unsigned labelLength = hasLabel ? label->byteLength() : 0; 800 unsigned labelLength = hasLabel ? label->byteLength() : 0;
799 801
800 params = adoptPtr(new blink::WebCryptoRsaOaepParams(hasLabel, labelStart, la belLength)); 802 params = adoptPtr(new blink::WebCryptoRsaOaepParams(hasLabel, labelStart, la belLength));
801 return true; 803 return true;
802 } 804 }
803 805
804 bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParams Type type, OwnPtr<blink::WebCryptoAlgorithmParams>& params, ErrorContext& contex t, CryptoResult* result) 806 bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParams Type type, OwnPtr<blink::WebCryptoAlgorithmParams>& params, ErrorContext& contex t, AlgorithmError* error)
805 { 807 {
806 switch (type) { 808 switch (type) {
807 case blink::WebCryptoAlgorithmParamsTypeNone: 809 case blink::WebCryptoAlgorithmParamsTypeNone:
808 return true; 810 return true;
809 case blink::WebCryptoAlgorithmParamsTypeAesCbcParams: 811 case blink::WebCryptoAlgorithmParamsTypeAesCbcParams:
810 context.add("AesCbcParams"); 812 context.add("AesCbcParams");
811 return parseAesCbcParams(raw, params, context, result); 813 return parseAesCbcParams(raw, params, context, error);
812 case blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams: 814 case blink::WebCryptoAlgorithmParamsTypeAesKeyGenParams:
813 context.add("AesKeyGenParams"); 815 context.add("AesKeyGenParams");
814 return parseAesKeyGenParams(raw, params, context, result); 816 return parseAesKeyGenParams(raw, params, context, error);
815 case blink::WebCryptoAlgorithmParamsTypeHmacImportParams: 817 case blink::WebCryptoAlgorithmParamsTypeHmacImportParams:
816 context.add("HmacImportParams"); 818 context.add("HmacImportParams");
817 return parseHmacImportParams(raw, params, context, result); 819 return parseHmacImportParams(raw, params, context, error);
818 case blink::WebCryptoAlgorithmParamsTypeHmacKeyGenParams: 820 case blink::WebCryptoAlgorithmParamsTypeHmacKeyGenParams:
819 context.add("HmacKeyGenParams"); 821 context.add("HmacKeyGenParams");
820 return parseHmacKeyGenParams(raw, params, context, result); 822 return parseHmacKeyGenParams(raw, params, context, error);
821 case blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams: 823 case blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams:
822 context.add("RsaHashedKeyGenParams"); 824 context.add("RsaHashedKeyGenParams");
823 return parseRsaHashedKeyGenParams(raw, params, context, result); 825 return parseRsaHashedKeyGenParams(raw, params, context, error);
824 case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams: 826 case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams:
825 context.add("RsaHashedImportParams"); 827 context.add("RsaHashedImportParams");
826 return parseRsaHashedImportParams(raw, params, context, result); 828 return parseRsaHashedImportParams(raw, params, context, error);
827 case blink::WebCryptoAlgorithmParamsTypeAesCtrParams: 829 case blink::WebCryptoAlgorithmParamsTypeAesCtrParams:
828 context.add("AesCtrParams"); 830 context.add("AesCtrParams");
829 return parseAesCtrParams(raw, params, context, result); 831 return parseAesCtrParams(raw, params, context, error);
830 case blink::WebCryptoAlgorithmParamsTypeAesGcmParams: 832 case blink::WebCryptoAlgorithmParamsTypeAesGcmParams:
831 context.add("AesGcmParams"); 833 context.add("AesGcmParams");
832 return parseAesGcmParams(raw, params, context, result); 834 return parseAesGcmParams(raw, params, context, error);
833 case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams: 835 case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams:
834 context.add("RsaOaepParams"); 836 context.add("RsaOaepParams");
835 return parseRsaOaepParams(raw, params, context, result); 837 return parseRsaOaepParams(raw, params, context, error);
836 break; 838 break;
837 } 839 }
838 ASSERT_NOT_REACHED(); 840 ASSERT_NOT_REACHED();
839 return false; 841 return false;
840 } 842 }
841 843
842 const char* operationToString(AlgorithmOperation op) 844 const char* operationToString(blink::WebCryptoOperation op)
843 { 845 {
844 switch (op) { 846 switch (op) {
845 case Encrypt: 847 case blink::WebCryptoOperationEncrypt:
846 return "encrypt"; 848 return "encrypt";
847 case Decrypt: 849 case blink::WebCryptoOperationDecrypt:
848 return "decrypt"; 850 return "decrypt";
849 case Sign: 851 case blink::WebCryptoOperationSign:
850 return "sign"; 852 return "sign";
851 case Verify: 853 case blink::WebCryptoOperationVerify:
852 return "verify"; 854 return "verify";
853 case Digest: 855 case blink::WebCryptoOperationDigest:
854 return "digest"; 856 return "digest";
855 case GenerateKey: 857 case blink::WebCryptoOperationGenerateKey:
856 return "generateKey"; 858 return "generateKey";
857 case ImportKey: 859 case blink::WebCryptoOperationImportKey:
858 return "importKey"; 860 return "importKey";
859 case DeriveKey: 861 case blink::WebCryptoOperationDeriveKey:
860 return "deriveKey"; 862 return "deriveKey";
861 case DeriveBits: 863 case blink::WebCryptoOperationDeriveBits:
862 return "deriveBits"; 864 return "deriveBits";
863 case WrapKey: 865 case blink::WebCryptoOperationWrapKey:
864 return "wrapKey"; 866 return "wrapKey";
865 case UnwrapKey: 867 case blink::WebCryptoOperationUnwrapKey:
866 return "unwrapKey"; 868 return "unwrapKey";
867 } 869 }
868 return 0; 870 return 0;
869 } 871 }
870 872
871 bool parseAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::WebCryp toAlgorithm& algorithm, ErrorContext context, CryptoResult* result) 873 bool parseAlgorithm(const Dictionary& raw, blink::WebCryptoOperation op, blink:: WebCryptoAlgorithm& algorithm, ErrorContext context, AlgorithmError* error)
872 { 874 {
873 context.add("Algorithm"); 875 context.add("Algorithm");
874 876
875 if (!raw.isObject()) { 877 if (!raw.isObject()) {
876 completeWithSyntaxError(context.toString("Not an object"), result); 878 setSyntaxError(context.toString("Not an object"), error);
877 return false; 879 return false;
878 } 880 }
879 881
880 String algorithmName; 882 String algorithmName;
881 if (!raw.get("name", algorithmName)) { 883 if (!raw.get("name", algorithmName)) {
882 completeWithSyntaxError(context.toString("name", "Missing or not a strin g"), result); 884 setSyntaxError(context.toString("name", "Missing or not a string"), erro r);
883 return false; 885 return false;
884 } 886 }
885 887
886 blink::WebCryptoAlgorithmId algorithmId; 888 blink::WebCryptoAlgorithmId algorithmId;
887 if (!lookupAlgorithmIdByName(algorithmName, algorithmId)) { 889 if (!lookupAlgorithmIdByName(algorithmName, algorithmId)) {
888 // FIXME: The spec says to return a SyntaxError if the input contains 890 // FIXME: The spec says to return a SyntaxError if the input contains
889 // any non-ASCII characters. 891 // any non-ASCII characters.
890 completeWithNotSupportedError(context.toString("Unrecognized name"), res ult); 892 setNotSupportedError(context.toString("Unrecognized name"), error);
891 return false; 893 return false;
892 } 894 }
893 895
894 // Remove the "Algorithm:" prefix for all subsequent errors. 896 // Remove the "Algorithm:" prefix for all subsequent errors.
895 context.removeLast(); 897 context.removeLast();
896 898
897 const AlgorithmInfo* algorithmInfo = lookupAlgorithmInfo(algorithmId); 899 const AlgorithmInfo* algorithmInfo = lookupAlgorithmInfo(algorithmId);
898 900
899 if (algorithmInfo->operationToParamsType[op] == Undefined) { 901 if (algorithmInfo->operationToParamsType[op] == Undefined) {
900 context.add(algorithmIdToName(algorithmId)); 902 context.add(algorithmIdToName(algorithmId));
901 completeWithNotSupportedError(context.toString("Unsupported operation", operationToString(op)), result); 903 setNotSupportedError(context.toString("Unsupported operation", operation ToString(op)), error);
902 return false; 904 return false;
903 } 905 }
904 906
905 blink::WebCryptoAlgorithmParamsType paramsType = static_cast<blink::WebCrypt oAlgorithmParamsType>(algorithmInfo->operationToParamsType[op]); 907 blink::WebCryptoAlgorithmParamsType paramsType = static_cast<blink::WebCrypt oAlgorithmParamsType>(algorithmInfo->operationToParamsType[op]);
906 908
907 OwnPtr<blink::WebCryptoAlgorithmParams> params; 909 OwnPtr<blink::WebCryptoAlgorithmParams> params;
908 if (!parseAlgorithmParams(raw, paramsType, params, context, result)) 910 if (!parseAlgorithmParams(raw, paramsType, params, context, error))
909 return false; 911 return false;
910 912
911 algorithm = blink::WebCryptoAlgorithm(algorithmId, params.release()); 913 algorithm = blink::WebCryptoAlgorithm(algorithmId, params.release());
912 return true; 914 return true;
913 } 915 }
914 916
915 } // namespace 917 } // namespace
916 918
917 bool parseAlgorithm(const Dictionary& raw, AlgorithmOperation op, blink::WebCryp toAlgorithm& algorithm, CryptoResult* result) 919 bool normalizeAlgorithm(const Dictionary& raw, blink::WebCryptoOperation op, bli nk::WebCryptoAlgorithm& algorithm, AlgorithmError* error)
918 { 920 {
919 return parseAlgorithm(raw, op, algorithm, ErrorContext(), result); 921 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error);
920 } 922 }
921 923
922 const char* algorithmIdToName(blink::WebCryptoAlgorithmId id) 924 const char* algorithmIdToName(blink::WebCryptoAlgorithmId id)
923 { 925 {
924 return lookupAlgorithmInfo(id)->name; 926 return lookupAlgorithmInfo(id)->name;
925 } 927 }
926 928
927 } // namespace WebCore 929 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698