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

Side by Side Diff: content/child/webcrypto/webcrypto_util.cc

Issue 786363002: Refactor: Extract common code for generating asymmetric keys to a helper. (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
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | 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 "content/child/webcrypto/webcrypto_util.h" 5 #include "content/child/webcrypto/webcrypto_util.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 // OpenSSL hangs when given bad public exponents, whereas NSS simply fails. To 257 // OpenSSL hangs when given bad public exponents, whereas NSS simply fails. To
258 // avoid feeding OpenSSL data that will hang use a whitelist. 258 // avoid feeding OpenSSL data that will hang use a whitelist.
259 if (*public_exponent != 3 && *public_exponent != 65537) 259 if (*public_exponent != 3 && *public_exponent != 65537)
260 return Status::ErrorGenerateKeyPublicExponent(); 260 return Status::ErrorGenerateKeyPublicExponent();
261 261
262 return Status::Success(); 262 return Status::Success();
263 } 263 }
264 264
265 Status GetUsagesForGenerateAsymmetricKey(
266 blink::WebCryptoKeyUsageMask combined_usages,
267 blink::WebCryptoKeyUsageMask all_public_usages,
268 blink::WebCryptoKeyUsageMask all_private_usages,
269 blink::WebCryptoKeyUsageMask* public_usages,
270 blink::WebCryptoKeyUsageMask* private_usages) {
271 *public_usages = combined_usages & all_public_usages;
272 *private_usages = combined_usages & all_private_usages;
273
274 Status status = CheckKeyCreationUsages(all_public_usages, *public_usages);
275 if (status.IsError())
276 return status;
277
278 status = CheckKeyCreationUsages(all_private_usages, *private_usages);
279 if (status.IsError())
280 return status;
281
282 if (private_usages == 0)
283 return Status::ErrorCreateKeyEmptyUsages();
284
285 return Status::Success();
286 }
287
265 } // namespace webcrypto 288 } // namespace webcrypto
266 289
267 } // namespace content 290 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698