| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 return Status::Success(); | 496 return Status::Success(); |
| 497 } | 497 } |
| 498 | 498 |
| 499 } // namespace | 499 } // namespace |
| 500 | 500 |
| 501 Status RsaHashedAlgorithm::GenerateKey( | 501 Status RsaHashedAlgorithm::GenerateKey( |
| 502 const blink::WebCryptoAlgorithm& algorithm, | 502 const blink::WebCryptoAlgorithm& algorithm, |
| 503 bool extractable, | 503 bool extractable, |
| 504 blink::WebCryptoKeyUsageMask combined_usages, | 504 blink::WebCryptoKeyUsageMask combined_usages, |
| 505 GenerateKeyResult* result) const { | 505 GenerateKeyResult* result) const { |
| 506 Status status = CheckKeyCreationUsages( | 506 blink::WebCryptoKeyUsageMask public_usages = 0; |
| 507 all_public_key_usages_ | all_private_key_usages_, combined_usages); | 507 blink::WebCryptoKeyUsageMask private_usages = 0; |
| 508 |
| 509 Status status = GetUsagesForGenerateAsymmetricKey( |
| 510 combined_usages, all_public_key_usages_, all_private_key_usages_, |
| 511 &public_usages, &private_usages); |
| 508 if (status.IsError()) | 512 if (status.IsError()) |
| 509 return status; | 513 return status; |
| 510 | 514 |
| 511 const blink::WebCryptoKeyUsageMask public_usages = | |
| 512 combined_usages & all_public_key_usages_; | |
| 513 const blink::WebCryptoKeyUsageMask private_usages = | |
| 514 combined_usages & all_private_key_usages_; | |
| 515 | |
| 516 if (private_usages == 0) | |
| 517 return Status::ErrorCreateKeyEmptyUsages(); | |
| 518 | |
| 519 unsigned int public_exponent = 0; | 515 unsigned int public_exponent = 0; |
| 520 unsigned int modulus_length_bits = 0; | 516 unsigned int modulus_length_bits = 0; |
| 521 status = GetRsaKeyGenParameters(algorithm.rsaHashedKeyGenParams(), | 517 status = GetRsaKeyGenParameters(algorithm.rsaHashedKeyGenParams(), |
| 522 &public_exponent, &modulus_length_bits); | 518 &public_exponent, &modulus_length_bits); |
| 523 if (status.IsError()) | 519 if (status.IsError()) |
| 524 return status; | 520 return status; |
| 525 | 521 |
| 526 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); | 522 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); |
| 527 if (!slot) | 523 if (!slot) |
| 528 return Status::OperationError(); | 524 return Status::OperationError(); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 860 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
| 865 return Status::ErrorUnexpected(); | 861 return Status::ErrorUnexpected(); |
| 866 } | 862 } |
| 867 | 863 |
| 868 return Status::Success(); | 864 return Status::Success(); |
| 869 } | 865 } |
| 870 | 866 |
| 871 } // namespace webcrypto | 867 } // namespace webcrypto |
| 872 | 868 |
| 873 } // namespace content | 869 } // namespace content |
| OLD | NEW |