| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 | 732 |
| 733 JwkRsaInfo jwk; | 733 JwkRsaInfo jwk; |
| 734 Status status = | 734 Status status = |
| 735 ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usages, &jwk); | 735 ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usages, &jwk); |
| 736 if (status.IsError()) | 736 if (status.IsError()) |
| 737 return status; | 737 return status; |
| 738 | 738 |
| 739 // Once the key type is known, verify the usages. | 739 // Once the key type is known, verify the usages. |
| 740 status = CheckKeyCreationUsages( | 740 status = CheckKeyCreationUsages( |
| 741 jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, | 741 jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, |
| 742 usages); | 742 usages, !jwk.is_private_key); |
| 743 if (status.IsError()) | 743 if (status.IsError()) |
| 744 return Status::ErrorCreateKeyBadUsages(); | 744 return status; |
| 745 | 745 |
| 746 return jwk.is_private_key | 746 return jwk.is_private_key |
| 747 ? ImportRsaPrivateKey(algorithm, extractable, usages, jwk, key) | 747 ? ImportRsaPrivateKey(algorithm, extractable, usages, jwk, key) |
| 748 : ImportRsaPublicKey(algorithm, extractable, usages, | 748 : ImportRsaPublicKey(algorithm, extractable, usages, |
| 749 CryptoData(jwk.n), CryptoData(jwk.e), key); | 749 CryptoData(jwk.n), CryptoData(jwk.e), key); |
| 750 } | 750 } |
| 751 | 751 |
| 752 Status RsaHashedAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, | 752 Status RsaHashedAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, |
| 753 std::vector<uint8_t>* buffer) const { | 753 std::vector<uint8_t>* buffer) const { |
| 754 const char* jwk_algorithm = | 754 const char* jwk_algorithm = |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 854 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
| 855 return Status::ErrorUnexpected(); | 855 return Status::ErrorUnexpected(); |
| 856 } | 856 } |
| 857 | 857 |
| 858 return Status::Success(); | 858 return Status::Success(); |
| 859 } | 859 } |
| 860 | 860 |
| 861 } // namespace webcrypto | 861 } // namespace webcrypto |
| 862 | 862 |
| 863 } // namespace content | 863 } // namespace content |
| OLD | NEW |