| 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 738 |
| 739 JwkRsaInfo jwk; | 739 JwkRsaInfo jwk; |
| 740 Status status = | 740 Status status = |
| 741 ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usages, &jwk); | 741 ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usages, &jwk); |
| 742 if (status.IsError()) | 742 if (status.IsError()) |
| 743 return status; | 743 return status; |
| 744 | 744 |
| 745 // Once the key type is known, verify the usages. | 745 // Once the key type is known, verify the usages. |
| 746 status = CheckKeyCreationUsages( | 746 status = CheckKeyCreationUsages( |
| 747 jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, | 747 jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, |
| 748 usages); | 748 usages, jwk.is_private_key); |
| 749 if (status.IsError()) | 749 if (status.IsError()) |
| 750 return Status::ErrorCreateKeyBadUsages(); | 750 return status; |
| 751 | 751 |
| 752 return jwk.is_private_key | 752 return jwk.is_private_key |
| 753 ? ImportRsaPrivateKey(algorithm, extractable, usages, jwk, key) | 753 ? ImportRsaPrivateKey(algorithm, extractable, usages, jwk, key) |
| 754 : ImportRsaPublicKey(algorithm, extractable, usages, | 754 : ImportRsaPublicKey(algorithm, extractable, usages, |
| 755 CryptoData(jwk.n), CryptoData(jwk.e), key); | 755 CryptoData(jwk.n), CryptoData(jwk.e), key); |
| 756 } | 756 } |
| 757 | 757 |
| 758 Status RsaHashedAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, | 758 Status RsaHashedAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, |
| 759 std::vector<uint8_t>* buffer) const { | 759 std::vector<uint8_t>* buffer) const { |
| 760 const char* jwk_algorithm = | 760 const char* jwk_algorithm = |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 860 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
| 861 return Status::ErrorUnexpected(); | 861 return Status::ErrorUnexpected(); |
| 862 } | 862 } |
| 863 | 863 |
| 864 return Status::Success(); | 864 return Status::Success(); |
| 865 } | 865 } |
| 866 | 866 |
| 867 } // namespace webcrypto | 867 } // namespace webcrypto |
| 868 | 868 |
| 869 } // namespace content | 869 } // namespace content |
| OLD | NEW |