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: content/child/webcrypto/algorithm_dispatch.cc

Issue 777403004: [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 "content/child/webcrypto/algorithm_dispatch.h" 5 #include "content/child/webcrypto/algorithm_dispatch.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/child/webcrypto/algorithm_implementation.h" 8 #include "content/child/webcrypto/algorithm_implementation.h"
9 #include "content/child/webcrypto/algorithm_registry.h" 9 #include "content/child/webcrypto/algorithm_registry.h"
10 #include "content/child/webcrypto/crypto_data.h" 10 #include "content/child/webcrypto/crypto_data.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 blink::WebCryptoKey* key) { 122 blink::WebCryptoKey* key) {
123 const AlgorithmImplementation* impl = NULL; 123 const AlgorithmImplementation* impl = NULL;
124 Status status = GetAlgorithmImplementation(algorithm.id(), &impl); 124 Status status = GetAlgorithmImplementation(algorithm.id(), &impl);
125 if (status.IsError()) 125 if (status.IsError())
126 return status; 126 return status;
127 127
128 status = impl->VerifyKeyUsagesBeforeImportKey(format, usages); 128 status = impl->VerifyKeyUsagesBeforeImportKey(format, usages);
129 if (status.IsError()) 129 if (status.IsError())
130 return status; 130 return status;
131 131
132 if (usages == 0)
eroman 2014/12/05 20:45:51 This is not correct. Some key types are allowed
Habib Virji 2014/12/08 15:05:21 Updated. Have found usages only in AES and HMAC.
133 return Status::ErrorImportEmptyKeyUsage();
134
132 switch (format) { 135 switch (format) {
133 case blink::WebCryptoKeyFormatRaw: 136 case blink::WebCryptoKeyFormatRaw:
134 return impl->ImportKeyRaw(key_data, algorithm, extractable, usages, key); 137 return impl->ImportKeyRaw(key_data, algorithm, extractable, usages, key);
135 case blink::WebCryptoKeyFormatSpki: 138 case blink::WebCryptoKeyFormatSpki:
136 return impl->ImportKeySpki(key_data, algorithm, extractable, usages, key); 139 return impl->ImportKeySpki(key_data, algorithm, extractable, usages, key);
137 case blink::WebCryptoKeyFormatPkcs8: 140 case blink::WebCryptoKeyFormatPkcs8:
138 return impl->ImportKeyPkcs8(key_data, algorithm, extractable, usages, 141 return impl->ImportKeyPkcs8(key_data, algorithm, extractable, usages,
139 key); 142 key);
140 case blink::WebCryptoKeyFormatJwk: 143 case blink::WebCryptoKeyFormatJwk:
141 return impl->ImportKeyJwk(key_data, algorithm, extractable, usages, key); 144 return impl->ImportKeyJwk(key_data, algorithm, extractable, usages, key);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return false; 291 return false;
289 292
290 status = impl->DeserializeKeyForClone(algorithm, type, extractable, usages, 293 status = impl->DeserializeKeyForClone(algorithm, type, extractable, usages,
291 key_data, key); 294 key_data, key);
292 return status.IsSuccess(); 295 return status.IsSuccess();
293 } 296 }
294 297
295 } // namespace webcrypto 298 } // namespace webcrypto
296 299
297 } // namespace content 300 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/status.h » ('j') | content/child/webcrypto/test/rsa_ssa_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698