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

Side by Side Diff: content/child/webcrypto/nss/aes_key_nss.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: Moved import key empty usage to CheckKeyCreationUsages 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/nss/aes_key_nss.h" 5 #include "content/child/webcrypto/nss/aes_key_nss.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/child/webcrypto/crypto_data.h" 8 #include "content/child/webcrypto/crypto_data.h"
9 #include "content/child/webcrypto/jwk.h" 9 #include "content/child/webcrypto/jwk.h"
10 #include "content/child/webcrypto/nss/key_nss.h" 10 #include "content/child/webcrypto/nss/key_nss.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return status; 52 return status;
53 53
54 return GenerateSecretKeyNss( 54 return GenerateSecretKeyNss(
55 blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), 55 blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits),
56 extractable, usages, keylen_bits / 8, CKM_AES_KEY_GEN, result); 56 extractable, usages, keylen_bits / 8, CKM_AES_KEY_GEN, result);
57 } 57 }
58 58
59 Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( 59 Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey(
60 blink::WebCryptoKeyFormat format, 60 blink::WebCryptoKeyFormat format,
61 blink::WebCryptoKeyUsageMask usages) const { 61 blink::WebCryptoKeyUsageMask usages) const {
62 bool checkEmptyUsage = true;
eroman 2014/12/09 17:42:55 Incorrect naming style, please read the chromium s
62 switch (format) { 63 switch (format) {
63 case blink::WebCryptoKeyFormatRaw: 64 case blink::WebCryptoKeyFormatRaw:
64 case blink::WebCryptoKeyFormatJwk: 65 case blink::WebCryptoKeyFormatJwk:
65 return CheckKeyCreationUsages(all_key_usages_, usages); 66 return CheckKeyCreationUsages(all_key_usages_, usages, checkEmptyUsage);
66 default: 67 default:
67 return Status::ErrorUnsupportedImportKeyFormat(); 68 return Status::ErrorUnsupportedImportKeyFormat();
68 } 69 }
69 } 70 }
70 Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, 71 Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data,
71 const blink::WebCryptoAlgorithm& algorithm, 72 const blink::WebCryptoAlgorithm& algorithm,
72 bool extractable, 73 bool extractable,
73 blink::WebCryptoKeyUsageMask usages, 74 blink::WebCryptoKeyUsageMask usages,
74 blink::WebCryptoKey* key) const { 75 blink::WebCryptoKey* key) const {
75 const unsigned int keylen_bytes = key_data.byte_length(); 76 const unsigned int keylen_bytes = key_data.byte_length();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 blink::WebCryptoKeyUsageMask usages, 134 blink::WebCryptoKeyUsageMask usages,
134 const CryptoData& key_data, 135 const CryptoData& key_data,
135 blink::WebCryptoKey* key) const { 136 blink::WebCryptoKey* key) const {
136 return ImportKeyRaw(key_data, CreateAlgorithm(algorithm.id()), extractable, 137 return ImportKeyRaw(key_data, CreateAlgorithm(algorithm.id()), extractable,
137 usages, key); 138 usages, key);
138 } 139 }
139 140
140 } // namespace webcrypto 141 } // namespace webcrypto
141 142
142 } // namespace content 143 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/nss/hmac_nss.cc » ('j') | content/child/webcrypto/nss/rsa_key_nss.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698