| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |