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

Side by Side Diff: components/webcrypto/algorithms/hkdf.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "components/webcrypto/algorithm_implementation.h" 9 #include "components/webcrypto/algorithm_implementation.h"
10 #include "components/webcrypto/algorithms/secret_key_util.h" 10 #include "components/webcrypto/algorithms/secret_key_util.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 TruncateToBitLength(optional_length_bits, derived_bytes); 98 TruncateToBitLength(optional_length_bits, derived_bytes);
99 return Status::Success(); 99 return Status::Success();
100 } 100 }
101 101
102 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, 102 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
103 blink::WebCryptoKeyType type, 103 blink::WebCryptoKeyType type,
104 bool extractable, 104 bool extractable,
105 blink::WebCryptoKeyUsageMask usages, 105 blink::WebCryptoKeyUsageMask usages,
106 const CryptoData& key_data, 106 const CryptoData& key_data,
107 blink::WebCryptoKey* key) const override { 107 blink::WebCryptoKey* key) const override {
108 if (algorithm.paramsType() != blink::WebCryptoKeyAlgorithmParamsTypeNone)
109 return Status::ErrorUnexpected();
110
eroman 2016/11/30 19:15:50 Can you also add a test for: type == WebCryptoK
108 // NOTE: Unlike ImportKeyRaw(), this does not enforce extractable==false. 111 // NOTE: Unlike ImportKeyRaw(), this does not enforce extractable==false.
109 // This is intentional. Although keys cannot currently be created with 112 // This is intentional. Although keys cannot currently be created with
110 // extractable==true, earlier implementations permitted this, so 113 // extractable==true, earlier implementations permitted this, so
111 // de-serialization by structured clone should not reject them. 114 // de-serialization by structured clone should not reject them.
112 return CreateWebCryptoSecretKey(key_data, algorithm, extractable, usages, 115 return CreateWebCryptoSecretKey(key_data, algorithm, extractable, usages,
113 key); 116 key);
114 } 117 }
115 118
116 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, 119 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm,
117 bool* has_length_bits, 120 bool* has_length_bits,
118 unsigned int* length_bits) const override { 121 unsigned int* length_bits) const override {
119 *has_length_bits = false; 122 *has_length_bits = false;
120 return Status::Success(); 123 return Status::Success();
121 } 124 }
122 }; 125 };
123 126
124 } // namespace 127 } // namespace
125 128
126 std::unique_ptr<AlgorithmImplementation> CreateHkdfImplementation() { 129 std::unique_ptr<AlgorithmImplementation> CreateHkdfImplementation() {
127 return base::WrapUnique(new HkdfImplementation); 130 return base::WrapUnique(new HkdfImplementation);
128 } 131 }
129 132
130 } // namespace webcrypto 133 } // namespace webcrypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698