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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 Status status = CheckKeyCreationUsages( | 516 Status status = CheckKeyCreationUsages( |
517 all_public_key_usages_ | all_private_key_usages_, combined_usages); | 517 all_public_key_usages_ | all_private_key_usages_, combined_usages); |
518 if (status.IsError()) | 518 if (status.IsError()) |
519 return status; | 519 return status; |
520 | 520 |
521 const blink::WebCryptoKeyUsageMask public_usages = | 521 const blink::WebCryptoKeyUsageMask public_usages = |
522 combined_usages & all_public_key_usages_; | 522 combined_usages & all_public_key_usages_; |
523 const blink::WebCryptoKeyUsageMask private_usages = | 523 const blink::WebCryptoKeyUsageMask private_usages = |
524 combined_usages & all_private_key_usages_; | 524 combined_usages & all_private_key_usages_; |
525 | 525 |
| 526 if (private_usages == 0) |
| 527 return Status::ErrorCreateKeyEmptyUsages(); |
| 528 |
526 unsigned int public_exponent = 0; | 529 unsigned int public_exponent = 0; |
527 unsigned int modulus_length_bits = 0; | 530 unsigned int modulus_length_bits = 0; |
528 status = GetRsaKeyGenParameters(algorithm.rsaHashedKeyGenParams(), | 531 status = GetRsaKeyGenParameters(algorithm.rsaHashedKeyGenParams(), |
529 &public_exponent, | 532 &public_exponent, |
530 &modulus_length_bits); | 533 &modulus_length_bits); |
531 if (status.IsError()) | 534 if (status.IsError()) |
532 return status; | 535 return status; |
533 | 536 |
534 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); | 537 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); |
535 if (!slot) | 538 if (!slot) |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 921 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
919 return Status::ErrorUnexpected(); | 922 return Status::ErrorUnexpected(); |
920 } | 923 } |
921 | 924 |
922 return Status::Success(); | 925 return Status::Success(); |
923 } | 926 } |
924 | 927 |
925 } // namespace webcrypto | 928 } // namespace webcrypto |
926 | 929 |
927 } // namespace content | 930 } // namespace content |
OLD | NEW |