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/nss/rsa_key_nss.h" | 5 #include "content/child/webcrypto/nss/rsa_key_nss.h" |
6 | 6 |
7 #include <secasn1.h> | 7 #include <secasn1.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/child/webcrypto/crypto_data.h" | 10 #include "content/child/webcrypto/crypto_data.h" |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 Status status = CheckKeyCreationUsages( | 506 Status status = CheckKeyCreationUsages( |
507 all_public_key_usages_ | all_private_key_usages_, combined_usages); | 507 all_public_key_usages_ | all_private_key_usages_, combined_usages); |
508 if (status.IsError()) | 508 if (status.IsError()) |
509 return status; | 509 return status; |
510 | 510 |
511 const blink::WebCryptoKeyUsageMask public_usages = | 511 const blink::WebCryptoKeyUsageMask public_usages = |
512 combined_usages & all_public_key_usages_; | 512 combined_usages & all_public_key_usages_; |
513 const blink::WebCryptoKeyUsageMask private_usages = | 513 const blink::WebCryptoKeyUsageMask private_usages = |
514 combined_usages & all_private_key_usages_; | 514 combined_usages & all_private_key_usages_; |
515 | 515 |
| 516 if (private_usages == 0) |
| 517 return Status::ErrorCreateKeyEmptyUsages(); |
| 518 |
516 unsigned int public_exponent = 0; | 519 unsigned int public_exponent = 0; |
517 unsigned int modulus_length_bits = 0; | 520 unsigned int modulus_length_bits = 0; |
518 status = GetRsaKeyGenParameters(algorithm.rsaHashedKeyGenParams(), | 521 status = GetRsaKeyGenParameters(algorithm.rsaHashedKeyGenParams(), |
519 &public_exponent, &modulus_length_bits); | 522 &public_exponent, &modulus_length_bits); |
520 if (status.IsError()) | 523 if (status.IsError()) |
521 return status; | 524 return status; |
522 | 525 |
523 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); | 526 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); |
524 if (!slot) | 527 if (!slot) |
525 return Status::OperationError(); | 528 return Status::OperationError(); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 878 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
876 return Status::ErrorUnexpected(); | 879 return Status::ErrorUnexpected(); |
877 } | 880 } |
878 | 881 |
879 return Status::Success(); | 882 return Status::Success(); |
880 } | 883 } |
881 | 884 |
882 } // namespace webcrypto | 885 } // namespace webcrypto |
883 | 886 |
884 } // namespace content | 887 } // namespace content |
OLD | NEW |