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

Side by Side Diff: components/webcrypto/algorithms/aes.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/aes.h" 5 #include "components/webcrypto/algorithms/aes.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "components/webcrypto/algorithms/secret_key_util.h" 10 #include "components/webcrypto/algorithms/secret_key_util.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return Status::Success(); 192 return Status::Success();
193 } 193 }
194 194
195 Status AesAlgorithm::DeserializeKeyForClone( 195 Status AesAlgorithm::DeserializeKeyForClone(
196 const blink::WebCryptoKeyAlgorithm& algorithm, 196 const blink::WebCryptoKeyAlgorithm& algorithm,
197 blink::WebCryptoKeyType type, 197 blink::WebCryptoKeyType type,
198 bool extractable, 198 bool extractable,
199 blink::WebCryptoKeyUsageMask usages, 199 blink::WebCryptoKeyUsageMask usages,
200 const CryptoData& key_data, 200 const CryptoData& key_data,
201 blink::WebCryptoKey* key) const { 201 blink::WebCryptoKey* key) const {
202 if (algorithm.paramsType() != blink::WebCryptoKeyAlgorithmParamsTypeAes)
203 return Status::ErrorUnexpected();
204
eroman 2016/11/30 19:15:50 Can you also add a test for type == WebCryptoKey
202 return ImportKeyRaw(key_data, SynthesizeImportAlgorithmForClone(algorithm), 205 return ImportKeyRaw(key_data, SynthesizeImportAlgorithmForClone(algorithm),
203 extractable, usages, key); 206 extractable, usages, key);
204 } 207 }
205 208
206 Status AesAlgorithm::GetKeyLength( 209 Status AesAlgorithm::GetKeyLength(
207 const blink::WebCryptoAlgorithm& key_length_algorithm, 210 const blink::WebCryptoAlgorithm& key_length_algorithm,
208 bool* has_length_bits, 211 bool* has_length_bits,
209 unsigned int* length_bits) const { 212 unsigned int* length_bits) const {
210 *has_length_bits = true; 213 *has_length_bits = true;
211 *length_bits = key_length_algorithm.aesDerivedKeyParams()->lengthBits(); 214 *length_bits = key_length_algorithm.aesDerivedKeyParams()->lengthBits();
212 215
213 if (*length_bits == 128 || *length_bits == 256) 216 if (*length_bits == 128 || *length_bits == 256)
214 return Status::Success(); 217 return Status::Success();
215 218
216 // 192-bit AES is intentionally unsupported (http://crbug.com/533699). 219 // 192-bit AES is intentionally unsupported (http://crbug.com/533699).
217 if (*length_bits == 192) 220 if (*length_bits == 192)
218 return Status::ErrorAes192BitUnsupported(); 221 return Status::ErrorAes192BitUnsupported();
219 222
220 return Status::ErrorGetAesKeyLength(); 223 return Status::ErrorGetAesKeyLength();
221 } 224 }
222 225
223 } // namespace webcrypto 226 } // namespace webcrypto
OLDNEW
« no previous file with comments | « no previous file | components/webcrypto/algorithms/ec.cc » ('j') | components/webcrypto/algorithms/hkdf.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698