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

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: rebase again sigh 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/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 *length_bits = params->optionalLengthBits(); 374 *length_bits = params->optionalLengthBits();
375 if (*length_bits == 0) 375 if (*length_bits == 0)
376 return Status::ErrorGetHmacKeyLengthZero(); 376 return Status::ErrorGetHmacKeyLengthZero();
377 return Status::Success(); 377 return Status::Success();
378 } 378 }
379 379
380 *has_length_bits = true; 380 *has_length_bits = true;
381 return GetShaBlockSizeBits(params->hash(), length_bits); 381 return GetShaBlockSizeBits(params->hash(), length_bits);
382 } 382 }
383 383
384 Status GetUsagesForGenerateAsymmetricKey(
385 blink::WebCryptoKeyUsageMask combined_usages,
386 blink::WebCryptoKeyUsageMask all_public_usages,
387 blink::WebCryptoKeyUsageMask all_private_usages,
388 blink::WebCryptoKeyUsageMask* public_usages,
389 blink::WebCryptoKeyUsageMask* private_usages) {
390 Status status = CheckKeyCreationUsages(all_public_usages | all_private_usages,
391 combined_usages);
392 if (status.IsError())
393 return status;
394
395 *public_usages = combined_usages & all_public_usages;
396 *private_usages = combined_usages & all_private_usages;
397
398 if (*private_usages == 0)
399 return Status::ErrorCreateKeyEmptyUsages();
400
401 return Status::Success();
402 }
403
384 } // namespace webcrypto 404 } // namespace webcrypto
385 405
386 } // namespace content 406 } // 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