OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/webcrypto/webcrypto_impl.h" | 5 #include "content/renderer/webcrypto/webcrypto_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 std::vector<uint8> MakeJsonVector(const std::string& json_string) { | 42 std::vector<uint8> MakeJsonVector(const std::string& json_string) { |
43 return std::vector<uint8>(json_string.begin(), json_string.end()); | 43 return std::vector<uint8>(json_string.begin(), json_string.end()); |
44 } | 44 } |
45 | 45 |
46 std::vector<uint8> MakeJsonVector(const base::DictionaryValue& dict) { | 46 std::vector<uint8> MakeJsonVector(const base::DictionaryValue& dict) { |
47 std::string json; | 47 std::string json; |
48 base::JSONWriter::Write(&dict, &json); | 48 base::JSONWriter::Write(&dict, &json); |
49 return MakeJsonVector(json); | 49 return MakeJsonVector(json); |
50 } | 50 } |
51 | 51 |
52 // Helper for ImportJwkBadJwk; restores JWK JSON dictionary to a good state | 52 // Helper for ImportJwkFailures and ImportJwkOctFailures. Restores the JWK JSON |
53 void RestoreDictionaryForImportBadJwkTest(base::DictionaryValue* dict) { | 53 // dictionary to a good state |
| 54 void RestoreJwkOctDictionary(base::DictionaryValue* dict) { |
54 dict->Clear(); | 55 dict->Clear(); |
55 dict->SetString("kty", "oct"); | 56 dict->SetString("kty", "oct"); |
56 dict->SetString("alg", "A128CBC"); | 57 dict->SetString("alg", "A128CBC"); |
57 dict->SetString("use", "enc"); | 58 dict->SetString("use", "enc"); |
58 dict->SetBoolean("extractable", false); | 59 dict->SetBoolean("extractable", false); |
59 dict->SetString("k", "GADWrMRHwQfoNaXU5fZvTg=="); | 60 dict->SetString("k", "GADWrMRHwQfoNaXU5fZvTg=="); |
60 } | 61 } |
61 | 62 |
| 63 // Helper for ImportJwkRsaFailures. Restores the JWK JSON |
| 64 // dictionary to a good state |
| 65 void RestoreJwkRsaDictionary(base::DictionaryValue* dict) { |
| 66 dict->Clear(); |
| 67 dict->SetString("kty", "RSA"); |
| 68 dict->SetString("alg", "RSA1_5"); |
| 69 dict->SetString("use", "enc"); |
| 70 dict->SetBoolean("extractable", false); |
| 71 dict->SetString("n", |
| 72 "qLOyhK-OtQs4cDSoYPFGxJGfMYdjzWxVmMiuSBGh4KvEx-CwgtaTpef87Wdc9GaFEncsDLxk" |
| 73 "p0LGxjD1M8jMcvYq6DPEC_JYQumEu3i9v5fAEH1VvbZi9cTg-rmEXLUUjvc5LdOq_5OuHmtm" |
| 74 "e7PUJHYW1PW6ENTP0ibeiNOfFvs"); |
| 75 dict->SetString("e", "AQAB"); |
| 76 } |
| 77 |
62 #if !defined(USE_OPENSSL) | 78 #if !defined(USE_OPENSSL) |
63 blink::WebCryptoAlgorithm CreateRsaAlgorithm( | 79 blink::WebCryptoAlgorithm CreateRsaAlgorithm( |
64 blink::WebCryptoAlgorithmId algorithm_id, | 80 blink::WebCryptoAlgorithmId algorithm_id, |
65 unsigned modulus_length, | 81 unsigned modulus_length, |
66 const std::vector<uint8>& public_exponent) { | 82 const std::vector<uint8>& public_exponent) { |
67 DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || | 83 DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || |
68 algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || | 84 algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || |
69 algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep); | 85 algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep); |
70 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( | 86 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
71 algorithm_id, | 87 algorithm_id, |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 EXPECT_FALSE(ImportKeyInternal( | 700 EXPECT_FALSE(ImportKeyInternal( |
685 blink::WebCryptoKeyFormatRaw, | 701 blink::WebCryptoKeyFormatRaw, |
686 HexStringToBytes("00000000000000000000"), | 702 HexStringToBytes("00000000000000000000"), |
687 blink::WebCryptoAlgorithm::createNull(), | 703 blink::WebCryptoAlgorithm::createNull(), |
688 blink::WebCryptoKeyUsageSign, | 704 blink::WebCryptoKeyUsageSign, |
689 &key)); | 705 &key)); |
690 } | 706 } |
691 | 707 |
692 #endif //#if !defined(USE_OPENSSL) | 708 #endif //#if !defined(USE_OPENSSL) |
693 | 709 |
694 TEST_F(WebCryptoImplTest, ImportJwkBadJwk) { | 710 TEST_F(WebCryptoImplTest, ImportJwkFailures) { |
695 | 711 |
696 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 712 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
697 blink::WebCryptoAlgorithm algorithm = | 713 blink::WebCryptoAlgorithm algorithm = |
698 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); | 714 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); |
699 blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; | 715 blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; |
700 | 716 |
701 // Baseline pass: each test below breaks a single item, so we start with a | 717 // Baseline pass: each test below breaks a single item, so we start with a |
702 // passing case to make sure each failure is caused by the isolated break. | 718 // passing case to make sure each failure is caused by the isolated break. |
703 // Each breaking subtest below resets the dictionary to this passing case when | 719 // Each breaking subtest below resets the dictionary to this passing case when |
704 // complete. | 720 // complete. |
705 base::DictionaryValue dict; | 721 base::DictionaryValue dict; |
706 RestoreDictionaryForImportBadJwkTest(&dict); | 722 RestoreJwkOctDictionary(&dict); |
707 std::vector<uint8> json_vec = MakeJsonVector(dict); | 723 EXPECT_TRUE(ImportKeyJwk( |
708 EXPECT_TRUE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 724 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
709 | 725 |
710 // Fail on empty JSON. | 726 // Fail on empty JSON. |
711 EXPECT_FALSE(ImportKeyJwk( | 727 EXPECT_FALSE(ImportKeyJwk( |
712 MakeJsonVector(""), algorithm, false, usage_mask, &key)); | 728 MakeJsonVector(""), algorithm, false, usage_mask, &key)); |
713 | 729 |
714 // Fail on invalid JSON. | 730 // Fail on invalid JSON. |
715 const std::vector<uint8> bad_json_vec = MakeJsonVector( | 731 const std::vector<uint8> bad_json_vec = MakeJsonVector( |
716 "{" | 732 "{" |
717 "\"kty\" : \"oct\"," | 733 "\"kty\" : \"oct\"," |
718 "\"alg\" : \"HS256\"," | 734 "\"alg\" : \"HS256\"," |
719 "\"use\" : " | 735 "\"use\" : " |
720 ); | 736 ); |
721 EXPECT_FALSE(ImportKeyJwk(bad_json_vec, algorithm, false, usage_mask, &key)); | 737 EXPECT_FALSE(ImportKeyJwk(bad_json_vec, algorithm, false, usage_mask, &key)); |
722 | 738 |
723 // Fail on JWK alg present but unrecognized. | 739 // Fail on JWK alg present but unrecognized. |
724 dict.SetString("alg", "A127CBC"); | 740 dict.SetString("alg", "A127CBC"); |
725 json_vec = MakeJsonVector(dict); | 741 EXPECT_FALSE(ImportKeyJwk( |
726 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 742 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
727 RestoreDictionaryForImportBadJwkTest(&dict); | 743 RestoreJwkOctDictionary(&dict); |
728 | 744 |
729 // Fail on both JWK and input algorithm missing. | 745 // Fail on both JWK and input algorithm missing. |
730 dict.Remove("alg", NULL); | 746 dict.Remove("alg", NULL); |
731 json_vec = MakeJsonVector(dict); | 747 EXPECT_FALSE(ImportKeyJwk(MakeJsonVector(dict), |
732 EXPECT_FALSE(ImportKeyJwk(json_vec, | |
733 blink::WebCryptoAlgorithm::createNull(), | 748 blink::WebCryptoAlgorithm::createNull(), |
734 false, | 749 false, |
735 usage_mask, | 750 usage_mask, |
736 &key)); | 751 &key)); |
737 RestoreDictionaryForImportBadJwkTest(&dict); | 752 RestoreJwkOctDictionary(&dict); |
738 | 753 |
739 // Fail on invalid kty. | 754 // Fail on invalid kty. |
740 dict.SetString("kty", "foo"); | 755 dict.SetString("kty", "foo"); |
741 json_vec = MakeJsonVector(dict); | 756 EXPECT_FALSE(ImportKeyJwk( |
742 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 757 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
743 RestoreDictionaryForImportBadJwkTest(&dict); | 758 RestoreJwkOctDictionary(&dict); |
744 | 759 |
745 // Fail on missing kty. | 760 // Fail on missing kty. |
746 dict.Remove("kty", NULL); | 761 dict.Remove("kty", NULL); |
747 json_vec = MakeJsonVector(dict); | 762 EXPECT_FALSE(ImportKeyJwk( |
748 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 763 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
749 RestoreDictionaryForImportBadJwkTest(&dict); | 764 RestoreJwkOctDictionary(&dict); |
750 | 765 |
751 // Fail on invalid use. | 766 // Fail on invalid use. |
752 dict.SetString("use", "foo"); | 767 dict.SetString("use", "foo"); |
753 json_vec = MakeJsonVector(dict); | 768 EXPECT_FALSE(ImportKeyJwk( |
754 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 769 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
755 RestoreDictionaryForImportBadJwkTest(&dict); | 770 RestoreJwkOctDictionary(&dict); |
| 771 } |
756 | 772 |
757 // Fail on missing k when kty = "oct". | 773 TEST_F(WebCryptoImplTest, ImportJwkOctFailures) { |
| 774 |
| 775 base::DictionaryValue dict; |
| 776 RestoreJwkOctDictionary(&dict); |
| 777 blink::WebCryptoAlgorithm algorithm = |
| 778 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); |
| 779 blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; |
| 780 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
| 781 |
| 782 // Baseline pass. |
| 783 EXPECT_TRUE(ImportKeyJwk( |
| 784 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
| 785 EXPECT_EQ(algorithm.id(), key.algorithm().id()); |
| 786 EXPECT_FALSE(key.extractable()); |
| 787 EXPECT_EQ(blink::WebCryptoKeyUsageEncrypt, key.usages()); |
| 788 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
| 789 |
| 790 // The following are specific failure cases for when kty = "oct". |
| 791 |
| 792 // Fail on missing k. |
758 dict.Remove("k", NULL); | 793 dict.Remove("k", NULL); |
759 json_vec = MakeJsonVector(dict); | 794 EXPECT_FALSE(ImportKeyJwk( |
760 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 795 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
761 RestoreDictionaryForImportBadJwkTest(&dict); | 796 RestoreJwkOctDictionary(&dict); |
762 | 797 |
763 // Fail on bad b64 encoding for k. | 798 // Fail on bad b64 encoding for k. |
764 dict.SetString("k", "Qk3f0DsytU8lfza2au #$% Htaw2xpop9GYyTuH0p5GghxTI="); | 799 dict.SetString("k", "Qk3f0DsytU8lfza2au #$% Htaw2xpop9GYyTuH0p5GghxTI="); |
765 json_vec = MakeJsonVector(dict); | 800 EXPECT_FALSE(ImportKeyJwk( |
766 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 801 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
767 RestoreDictionaryForImportBadJwkTest(&dict); | 802 RestoreJwkOctDictionary(&dict); |
768 | 803 |
769 // Fail on empty k. | 804 // Fail on empty k. |
770 dict.SetString("k", ""); | 805 dict.SetString("k", ""); |
771 json_vec = MakeJsonVector(dict); | 806 EXPECT_FALSE(ImportKeyJwk( |
772 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 807 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
773 RestoreDictionaryForImportBadJwkTest(&dict); | 808 RestoreJwkOctDictionary(&dict); |
774 | 809 |
775 // Fail on k actual length (120 bits) inconsistent with the embedded JWK alg | 810 // Fail on k actual length (120 bits) inconsistent with the embedded JWK alg |
776 // value (128) for an AES key. | 811 // value (128) for an AES key. |
777 dict.SetString("k", "AVj42h0Y5aqGtE3yluKL"); | 812 dict.SetString("k", "AVj42h0Y5aqGtE3yluKL"); |
778 json_vec = MakeJsonVector(dict); | 813 EXPECT_FALSE(ImportKeyJwk( |
779 EXPECT_FALSE(ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); | 814 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
780 RestoreDictionaryForImportBadJwkTest(&dict); | 815 RestoreJwkOctDictionary(&dict); |
| 816 } |
781 | 817 |
782 // TODO(padolph) RSA public key bad data: | 818 #if !defined(USE_OPENSSL) |
783 // Missing n or e when kty = "RSA" | 819 |
784 // Bad encoding for n or e | 820 TEST_F(WebCryptoImplTest, ImportJwkRsaFailures) { |
785 // Size check on n?? | 821 |
786 // Value check on e?? | 822 base::DictionaryValue dict; |
| 823 RestoreJwkRsaDictionary(&dict); |
| 824 blink::WebCryptoAlgorithm algorithm = |
| 825 CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
| 826 blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; |
| 827 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
| 828 |
| 829 // An RSA public key JWK _must_ have an "n" (modulus) and an "e" (exponent) |
| 830 // entry, while an RSA private key must have those plus at least a "d" |
| 831 // (private exponent) entry. |
| 832 // See http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-18, |
| 833 // section 6.3. |
| 834 |
| 835 // Baseline pass. |
| 836 EXPECT_TRUE(ImportKeyJwk( |
| 837 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
| 838 EXPECT_EQ(algorithm.id(), key.algorithm().id()); |
| 839 EXPECT_FALSE(key.extractable()); |
| 840 EXPECT_EQ(blink::WebCryptoKeyUsageEncrypt, key.usages()); |
| 841 EXPECT_EQ(blink::WebCryptoKeyTypePublic, key.type()); |
| 842 |
| 843 // The following are specific failure cases for when kty = "RSA". |
| 844 |
| 845 // Fail if either "n" or "e" is not present or malformed. |
| 846 const std::string kKtyParmName[] = {"n", "e"}; |
| 847 for (size_t idx = 0; idx < ARRAYSIZE_UNSAFE(kKtyParmName); ++idx) { |
| 848 |
| 849 // Fail on missing parameter. |
| 850 dict.Remove(kKtyParmName[idx], NULL); |
| 851 EXPECT_FALSE(ImportKeyJwk( |
| 852 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
| 853 RestoreJwkRsaDictionary(&dict); |
| 854 |
| 855 // Fail on bad b64 parameter encoding. |
| 856 dict.SetString(kKtyParmName[idx], "Qk3f0DsytU8lfza2au #$% Htaw2xpop9yTuH0"); |
| 857 EXPECT_FALSE(ImportKeyJwk( |
| 858 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
| 859 RestoreJwkRsaDictionary(&dict); |
| 860 |
| 861 // Fail on empty parameter. |
| 862 dict.SetString(kKtyParmName[idx], ""); |
| 863 EXPECT_FALSE(ImportKeyJwk( |
| 864 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
| 865 RestoreJwkRsaDictionary(&dict); |
| 866 } |
| 867 |
| 868 // Fail if "d" parameter is present, implying the JWK is a private key, which |
| 869 // is not supported. |
| 870 dict.SetString("d", "Qk3f0Dsyt"); |
| 871 EXPECT_FALSE(ImportKeyJwk( |
| 872 MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
| 873 RestoreJwkRsaDictionary(&dict); |
787 } | 874 } |
788 | 875 |
| 876 #endif // #if !defined(USE_OPENSSL) |
| 877 |
789 TEST_F(WebCryptoImplTest, ImportJwkInputConsistency) { | 878 TEST_F(WebCryptoImplTest, ImportJwkInputConsistency) { |
790 // The Web Crypto spec says that if a JWK value is present, but is | 879 // The Web Crypto spec says that if a JWK value is present, but is |
791 // inconsistent with the input value, the operation must fail. | 880 // inconsistent with the input value, the operation must fail. |
792 | 881 |
793 // Consistency rules when JWK value is not present: Inputs should be used. | 882 // Consistency rules when JWK value is not present: Inputs should be used. |
794 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 883 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
795 bool extractable = false; | 884 bool extractable = false; |
796 blink::WebCryptoAlgorithm algorithm = | 885 blink::WebCryptoAlgorithm algorithm = |
797 CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256); | 886 CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256); |
798 blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageVerify; | 887 blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageVerify; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 blink::WebCryptoKeyUsageEncrypt, | 975 blink::WebCryptoKeyUsageEncrypt, |
887 &key)); | 976 &key)); |
888 | 977 |
889 // Fail: Input usage_mask (encrypt|sign|verify) is not a subset of the JWK | 978 // Fail: Input usage_mask (encrypt|sign|verify) is not a subset of the JWK |
890 // value (sign|verify) | 979 // value (sign|verify) |
891 usage_mask = blink::WebCryptoKeyUsageEncrypt | | 980 usage_mask = blink::WebCryptoKeyUsageEncrypt | |
892 blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify; | 981 blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify; |
893 EXPECT_FALSE(ImportKeyJwk( | 982 EXPECT_FALSE(ImportKeyJwk( |
894 json_vec, algorithm, extractable, usage_mask, &key)); | 983 json_vec, algorithm, extractable, usage_mask, &key)); |
895 usage_mask = blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify; | 984 usage_mask = blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify; |
| 985 |
| 986 // TODO(padolph): kty vs alg consistency tests: Depending on the kty value, |
| 987 // only certain alg values are permitted. For example, when kty = "RSA" alg |
| 988 // must be of the RSA family, or when kty = "oct" alg must be symmetric |
| 989 // algorithm. |
896 } | 990 } |
897 | 991 |
898 TEST_F(WebCryptoImplTest, ImportJwkHappy) { | 992 TEST_F(WebCryptoImplTest, ImportJwkHappy) { |
899 | 993 |
900 // This test verifies the happy path of JWK import, including the application | 994 // This test verifies the happy path of JWK import, including the application |
901 // of the imported key material. | 995 // of the imported key material. |
902 | 996 |
903 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 997 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
904 bool extractable = false; | 998 bool extractable = false; |
905 blink::WebCryptoAlgorithm algorithm = | 999 blink::WebCryptoAlgorithm algorithm = |
(...skipping 22 matching lines...) Expand all Loading... |
928 | 1022 |
929 blink::WebArrayBuffer output; | 1023 blink::WebArrayBuffer output; |
930 | 1024 |
931 ASSERT_TRUE(SignInternal(algorithm, key, message_raw, &output)); | 1025 ASSERT_TRUE(SignInternal(algorithm, key, message_raw, &output)); |
932 | 1026 |
933 const std::string mac_raw = | 1027 const std::string mac_raw = |
934 "769f00d3e6a6cc1fb426a14a4f76c6462e6149726e0dee0ec0cf97a16605ac8b"; | 1028 "769f00d3e6a6cc1fb426a14a4f76c6462e6149726e0dee0ec0cf97a16605ac8b"; |
935 | 1029 |
936 ExpectArrayBufferMatchesHex(mac_raw, output); | 1030 ExpectArrayBufferMatchesHex(mac_raw, output); |
937 | 1031 |
938 // TODO(padolph) | 1032 // TODO(padolph): Import an RSA public key JWK and use it |
939 // Import an RSA public key JWK and use it | |
940 } | 1033 } |
941 | 1034 |
942 #if !defined(USE_OPENSSL) | 1035 #if !defined(USE_OPENSSL) |
943 | 1036 |
944 TEST_F(WebCryptoImplTest, GenerateKeyPairRsa) { | 1037 TEST_F(WebCryptoImplTest, GenerateKeyPairRsa) { |
945 // Note: using unrealistic short key lengths here to avoid bogging down tests. | 1038 // Note: using unrealistic short key lengths here to avoid bogging down tests. |
946 | 1039 |
947 // Successful WebCryptoAlgorithmIdRsaEsPkcs1v1_5 key generation. | 1040 // Successful WebCryptoAlgorithmIdRsaEsPkcs1v1_5 key generation. |
948 const unsigned modulus_length = 256; | 1041 const unsigned modulus_length = 256; |
949 const std::vector<uint8> public_exponent = HexStringToBytes("010001"); | 1042 const std::vector<uint8> public_exponent = HexStringToBytes("010001"); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key.type()); | 1134 EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key.type()); |
1042 EXPECT_EQ(extractable, public_key.extractable()); | 1135 EXPECT_EQ(extractable, public_key.extractable()); |
1043 EXPECT_EQ(extractable, private_key.extractable()); | 1136 EXPECT_EQ(extractable, private_key.extractable()); |
1044 EXPECT_EQ(usage_mask, public_key.usages()); | 1137 EXPECT_EQ(usage_mask, public_key.usages()); |
1045 EXPECT_EQ(usage_mask, private_key.usages()); | 1138 EXPECT_EQ(usage_mask, private_key.usages()); |
1046 } | 1139 } |
1047 | 1140 |
1048 #endif // #if !defined(USE_OPENSSL) | 1141 #endif // #if !defined(USE_OPENSSL) |
1049 | 1142 |
1050 } // namespace content | 1143 } // namespace content |
OLD | NEW |