| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
| 9 #include "content/child/webcrypto/generate_key_result.h" | 9 #include "content/child/webcrypto/generate_key_result.h" |
| 10 #include "content/child/webcrypto/jwk.h" | 10 #include "content/child/webcrypto/jwk.h" |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 605 |
| 606 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( | 606 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( |
| 607 blink::WebCryptoKeyFormat format, | 607 blink::WebCryptoKeyFormat format, |
| 608 blink::WebCryptoKeyUsageMask usages) const { | 608 blink::WebCryptoKeyUsageMask usages) const { |
| 609 switch (format) { | 609 switch (format) { |
| 610 case blink::WebCryptoKeyFormatSpki: | 610 case blink::WebCryptoKeyFormatSpki: |
| 611 return CheckKeyCreationUsages(all_public_key_usages_, usages); | 611 return CheckKeyCreationUsages(all_public_key_usages_, usages); |
| 612 case blink::WebCryptoKeyFormatPkcs8: | 612 case blink::WebCryptoKeyFormatPkcs8: |
| 613 return CheckKeyCreationUsages(all_private_key_usages_, usages); | 613 return CheckKeyCreationUsages(all_private_key_usages_, usages); |
| 614 case blink::WebCryptoKeyFormatJwk: | 614 case blink::WebCryptoKeyFormatJwk: |
| 615 return CheckKeyCreationUsages( | 615 // The JWK could represent either a public key or private key. The usages |
| 616 all_public_key_usages_ | all_private_key_usages_, usages); | 616 // must make sense for one of the two. The usages will be checked again by |
| 617 // ImportKeyJwk() once the key type has been determined. |
| 618 if (CheckKeyCreationUsages(all_private_key_usages_, usages) |
| 619 .IsSuccess() || |
| 620 CheckKeyCreationUsages(all_public_key_usages_, usages) |
| 621 .IsSuccess()) { |
| 622 return Status::Success(); |
| 623 } |
| 624 return Status::ErrorCreateKeyBadUsages(); |
| 617 default: | 625 default: |
| 618 return Status::ErrorUnsupportedImportKeyFormat(); | 626 return Status::ErrorUnsupportedImportKeyFormat(); |
| 619 } | 627 } |
| 620 } | 628 } |
| 621 | 629 |
| 622 Status RsaHashedAlgorithm::ImportKeyPkcs8( | 630 Status RsaHashedAlgorithm::ImportKeyPkcs8( |
| 623 const CryptoData& key_data, | 631 const CryptoData& key_data, |
| 624 const blink::WebCryptoAlgorithm& algorithm, | 632 const blink::WebCryptoAlgorithm& algorithm, |
| 625 bool extractable, | 633 bool extractable, |
| 626 blink::WebCryptoKeyUsageMask usages, | 634 blink::WebCryptoKeyUsageMask usages, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 return Status::Success(); | 843 return Status::Success(); |
| 836 } | 844 } |
| 837 default: | 845 default: |
| 838 return Status::ErrorUnexpected(); | 846 return Status::ErrorUnexpected(); |
| 839 } | 847 } |
| 840 } | 848 } |
| 841 | 849 |
| 842 } // namespace webcrypto | 850 } // namespace webcrypto |
| 843 | 851 |
| 844 } // namespace content | 852 } // namespace content |
| OLD | NEW |