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

Side by Side Diff: components/webcrypto/algorithms/ec.cc

Issue 2544533002: Have all overloads of webcrypto::AlgorithmImplementation::DeserializeKeyForClone check the params t… (Closed)
Patch Set: add a test for a case similar to the one the fuzzer found Created 4 years 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/webcrypto/algorithms/ec.h" 5 #include "components/webcrypto/algorithms/ec.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 } 649 }
650 650
651 // TODO(eroman): Defer import to the crypto thread. http://crbug.com/430763 651 // TODO(eroman): Defer import to the crypto thread. http://crbug.com/430763
652 Status EcAlgorithm::DeserializeKeyForClone( 652 Status EcAlgorithm::DeserializeKeyForClone(
653 const blink::WebCryptoKeyAlgorithm& algorithm, 653 const blink::WebCryptoKeyAlgorithm& algorithm,
654 blink::WebCryptoKeyType type, 654 blink::WebCryptoKeyType type,
655 bool extractable, 655 bool extractable,
656 blink::WebCryptoKeyUsageMask usages, 656 blink::WebCryptoKeyUsageMask usages,
657 const CryptoData& key_data, 657 const CryptoData& key_data,
658 blink::WebCryptoKey* key) const { 658 blink::WebCryptoKey* key) const {
659 if (algorithm.paramsType() != blink::WebCryptoKeyAlgorithmParamsTypeEc)
660 return Status::ErrorUnexpected();
661
659 blink::WebCryptoAlgorithm import_algorithm = 662 blink::WebCryptoAlgorithm import_algorithm =
660 SynthesizeImportAlgorithmForClone(algorithm); 663 SynthesizeImportAlgorithmForClone(algorithm);
661 664
662 Status status; 665 Status status;
663 666
664 // The serialized data will be either SPKI or PKCS8 formatted. 667 // The serialized data will be either SPKI or PKCS8 formatted.
665 switch (type) { 668 switch (type) {
666 case blink::WebCryptoKeyTypePublic: 669 case blink::WebCryptoKeyTypePublic:
667 status = 670 status =
668 ImportKeySpki(key_data, import_algorithm, extractable, usages, key); 671 ImportKeySpki(key_data, import_algorithm, extractable, usages, key);
(...skipping 19 matching lines...) Expand all
688 691
689 if (algorithm.ecParams()->namedCurve() != 692 if (algorithm.ecParams()->namedCurve() !=
690 key->algorithm().ecParams()->namedCurve()) { 693 key->algorithm().ecParams()->namedCurve()) {
691 return Status::ErrorUnexpected(); 694 return Status::ErrorUnexpected();
692 } 695 }
693 696
694 return Status::Success(); 697 return Status::Success();
695 } 698 }
696 699
697 } // namespace webcrypto 700 } // namespace webcrypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698