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

Side by Side Diff: content/child/webcrypto/nss/aes_gcm_nss.cc

Issue 670773003: Cleanup: rename usage_mask --> usages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « content/child/webcrypto/jwk.cc ('k') | content/child/webcrypto/nss/aes_key_nss.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/numerics/safe_math.h" 5 #include "base/numerics/safe_math.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "content/child/webcrypto/crypto_data.h" 7 #include "content/child/webcrypto/crypto_data.h"
8 #include "content/child/webcrypto/nss/aes_key_nss.h" 8 #include "content/child/webcrypto/nss/aes_key_nss.h"
9 #include "content/child/webcrypto/nss/key_nss.h" 9 #include "content/child/webcrypto/nss/key_nss.h"
10 #include "content/child/webcrypto/nss/util_nss.h" 10 #include "content/child/webcrypto/nss/util_nss.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 return Status::Success(); 139 return Status::Success();
140 } 140 }
141 141
142 class AesGcmImplementation : public AesAlgorithm { 142 class AesGcmImplementation : public AesAlgorithm {
143 public: 143 public:
144 AesGcmImplementation() : AesAlgorithm(CKM_AES_GCM, "GCM") {} 144 AesGcmImplementation() : AesAlgorithm(CKM_AES_GCM, "GCM") {}
145 145
146 virtual Status VerifyKeyUsagesBeforeImportKey( 146 virtual Status VerifyKeyUsagesBeforeImportKey(
147 blink::WebCryptoKeyFormat format, 147 blink::WebCryptoKeyFormat format,
148 blink::WebCryptoKeyUsageMask usage_mask) const override { 148 blink::WebCryptoKeyUsageMask usages) const override {
149 // Prevent importing AES-GCM keys if it is unavailable. 149 // Prevent importing AES-GCM keys if it is unavailable.
150 Status status = NssSupportsAesGcm(); 150 Status status = NssSupportsAesGcm();
151 if (status.IsError()) 151 if (status.IsError())
152 return status; 152 return status;
153 return AesAlgorithm::VerifyKeyUsagesBeforeImportKey(format, usage_mask); 153 return AesAlgorithm::VerifyKeyUsagesBeforeImportKey(format, usages);
154 } 154 }
155 155
156 virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, 156 virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
157 bool extractable, 157 bool extractable,
158 blink::WebCryptoKeyUsageMask usage_mask, 158 blink::WebCryptoKeyUsageMask usages,
159 GenerateKeyResult* result) const override { 159 GenerateKeyResult* result) const override {
160 // Prevent generating AES-GCM keys if it is unavailable. 160 // Prevent generating AES-GCM keys if it is unavailable.
161 Status status = NssSupportsAesGcm(); 161 Status status = NssSupportsAesGcm();
162 if (status.IsError()) 162 if (status.IsError())
163 return status; 163 return status;
164 164
165 return AesAlgorithm::GenerateKey( 165 return AesAlgorithm::GenerateKey(algorithm, extractable, usages, result);
166 algorithm, extractable, usage_mask, result);
167 } 166 }
168 167
169 virtual Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, 168 virtual Status Encrypt(const blink::WebCryptoAlgorithm& algorithm,
170 const blink::WebCryptoKey& key, 169 const blink::WebCryptoKey& key,
171 const CryptoData& data, 170 const CryptoData& data,
172 std::vector<uint8_t>* buffer) const override { 171 std::vector<uint8_t>* buffer) const override {
173 return AesGcmEncryptDecrypt(ENCRYPT, algorithm, key, data, buffer); 172 return AesGcmEncryptDecrypt(ENCRYPT, algorithm, key, data, buffer);
174 } 173 }
175 174
176 virtual Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, 175 virtual Status Decrypt(const blink::WebCryptoAlgorithm& algorithm,
177 const blink::WebCryptoKey& key, 176 const blink::WebCryptoKey& key,
178 const CryptoData& data, 177 const CryptoData& data,
179 std::vector<uint8_t>* buffer) const override { 178 std::vector<uint8_t>* buffer) const override {
180 return AesGcmEncryptDecrypt(DECRYPT, algorithm, key, data, buffer); 179 return AesGcmEncryptDecrypt(DECRYPT, algorithm, key, data, buffer);
181 } 180 }
182 }; 181 };
183 182
184 } // namespace 183 } // namespace
185 184
186 AlgorithmImplementation* CreatePlatformAesGcmImplementation() { 185 AlgorithmImplementation* CreatePlatformAesGcmImplementation() {
187 return new AesGcmImplementation; 186 return new AesGcmImplementation;
188 } 187 }
189 188
190 } // namespace webcrypto 189 } // namespace webcrypto
191 190
192 } // namespace content 191 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/jwk.cc ('k') | content/child/webcrypto/nss/aes_key_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698