| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 if (!dict.get() || dict->empty()) | 662 if (!dict.get() || dict->empty()) |
| 663 return ::testing::AssertionFailure() << "JSON parsing failed"; | 663 return ::testing::AssertionFailure() << "JSON parsing failed"; |
| 664 | 664 |
| 665 // ---- k | 665 // ---- k |
| 666 std::string value_string; | 666 std::string value_string; |
| 667 if (!dict->GetString("k", &value_string)) | 667 if (!dict->GetString("k", &value_string)) |
| 668 return ::testing::AssertionFailure() << "Missing 'k'"; | 668 return ::testing::AssertionFailure() << "Missing 'k'"; |
| 669 std::string k_value; | 669 std::string k_value; |
| 670 if (!webcrypto::Base64DecodeUrlSafe(value_string, &k_value)) | 670 if (!webcrypto::Base64DecodeUrlSafe(value_string, &k_value)) |
| 671 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed"; | 671 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed"; |
| 672 if (!base::LowerCaseEqualsASCII( | 672 if (!LowerCaseEqualsASCII(base::HexEncode(k_value.data(), k_value.size()), |
| 673 base::HexEncode(k_value.data(), k_value.size()), | 673 k_expected_hex.c_str())) { |
| 674 k_expected_hex.c_str())) { | |
| 675 return ::testing::AssertionFailure() << "Expected 'k' to be " | 674 return ::testing::AssertionFailure() << "Expected 'k' to be " |
| 676 << k_expected_hex | 675 << k_expected_hex |
| 677 << " but found something different"; | 676 << " but found something different"; |
| 678 } | 677 } |
| 679 | 678 |
| 680 return VerifyJwk(dict, "oct", alg_expected, use_mask_expected); | 679 return VerifyJwk(dict, "oct", alg_expected, use_mask_expected); |
| 681 } | 680 } |
| 682 | 681 |
| 683 // Verifies that the JSON in the input vector contains the provided | 682 // Verifies that the JSON in the input vector contains the provided |
| 684 // expected values. Exact matches are required on the fields examined. | 683 // expected values. Exact matches are required on the fields examined. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 704 "value"; | 703 "value"; |
| 705 } | 704 } |
| 706 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! | 705 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! |
| 707 | 706 |
| 708 // ---- e | 707 // ---- e |
| 709 if (!dict->GetString("e", &value_string)) | 708 if (!dict->GetString("e", &value_string)) |
| 710 return ::testing::AssertionFailure() << "Missing 'e'"; | 709 return ::testing::AssertionFailure() << "Missing 'e'"; |
| 711 std::string e_value; | 710 std::string e_value; |
| 712 if (!webcrypto::Base64DecodeUrlSafe(value_string, &e_value)) | 711 if (!webcrypto::Base64DecodeUrlSafe(value_string, &e_value)) |
| 713 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed"; | 712 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed"; |
| 714 if (!base::LowerCaseEqualsASCII( | 713 if (!LowerCaseEqualsASCII(base::HexEncode(e_value.data(), e_value.size()), |
| 715 base::HexEncode(e_value.data(), e_value.size()), | 714 e_expected_hex.c_str())) { |
| 716 e_expected_hex.c_str())) { | |
| 717 return ::testing::AssertionFailure() << "Expected 'e' to be " | 715 return ::testing::AssertionFailure() << "Expected 'e' to be " |
| 718 << e_expected_hex | 716 << e_expected_hex |
| 719 << " but found something different"; | 717 << " but found something different"; |
| 720 } | 718 } |
| 721 | 719 |
| 722 return VerifyJwk(dict, "RSA", alg_expected, use_mask_expected); | 720 return VerifyJwk(dict, "RSA", alg_expected, use_mask_expected); |
| 723 } | 721 } |
| 724 | 722 |
| 725 } // namespace | 723 } // namespace |
| 726 | 724 |
| (...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4475 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); | 4473 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); |
| 4476 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); | 4474 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); |
| 4477 | 4475 |
| 4478 EXPECT_NE(public_key_spki, wrapped_public_key); | 4476 EXPECT_NE(public_key_spki, wrapped_public_key); |
| 4479 EXPECT_NE(private_key_pkcs8, wrapped_private_key); | 4477 EXPECT_NE(private_key_pkcs8, wrapped_private_key); |
| 4480 } | 4478 } |
| 4481 | 4479 |
| 4482 } // namespace webcrypto | 4480 } // namespace webcrypto |
| 4483 | 4481 |
| 4484 } // namespace content | 4482 } // namespace content |
| OLD | NEW |