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