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/shared_crypto.h" | 5 #include "content/child/webcrypto/shared_crypto.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 if (!dict.get() || dict->empty()) | 630 if (!dict.get() || dict->empty()) |
631 return ::testing::AssertionFailure() << "JSON parsing failed"; | 631 return ::testing::AssertionFailure() << "JSON parsing failed"; |
632 | 632 |
633 // ---- n | 633 // ---- n |
634 std::string value_string; | 634 std::string value_string; |
635 if (!dict->GetString("n", &value_string)) | 635 if (!dict->GetString("n", &value_string)) |
636 return ::testing::AssertionFailure() << "Missing 'n'"; | 636 return ::testing::AssertionFailure() << "Missing 'n'"; |
637 std::string n_value; | 637 std::string n_value; |
638 if (!webcrypto::Base64DecodeUrlSafe(value_string, &n_value)) | 638 if (!webcrypto::Base64DecodeUrlSafe(value_string, &n_value)) |
639 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(n) failed"; | 639 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(n) failed"; |
640 if (base::HexEncode(n_value.data(), n_value.size()) != n_expected_hex) { | 640 DLOG(INFO) << base::HexEncode(n_value.data(), n_value.size()); |
| 641 DLOG(INFO) << n_expected_hex; |
| 642 if (!LowerCaseEqualsASCII(base::HexEncode(n_value.data(), n_value.size()), |
| 643 n_expected_hex.c_str())) { |
641 return ::testing::AssertionFailure() << "'n' does not match the expected " | 644 return ::testing::AssertionFailure() << "'n' does not match the expected " |
642 "value"; | 645 "value"; |
643 } | 646 } |
644 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! | 647 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! |
645 | 648 |
646 // ---- e | 649 // ---- e |
647 if (!dict->GetString("e", &value_string)) | 650 if (!dict->GetString("e", &value_string)) |
648 return ::testing::AssertionFailure() << "Missing 'e'"; | 651 return ::testing::AssertionFailure() << "Missing 'e'"; |
649 std::string e_value; | 652 std::string e_value; |
650 if (!webcrypto::Base64DecodeUrlSafe(value_string, &e_value)) | 653 if (!webcrypto::Base64DecodeUrlSafe(value_string, &e_value)) |
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3179 algorithm, | 3182 algorithm, |
3180 CreateAesCbcAlgorithm(std::vector<uint8>(0, 16)), | 3183 CreateAesCbcAlgorithm(std::vector<uint8>(0, 16)), |
3181 true, | 3184 true, |
3182 blink::WebCryptoKeyUsageEncrypt, | 3185 blink::WebCryptoKeyUsageEncrypt, |
3183 &unwrapped_key)); | 3186 &unwrapped_key)); |
3184 } | 3187 } |
3185 | 3188 |
3186 } // namespace webcrypto | 3189 } // namespace webcrypto |
3187 | 3190 |
3188 } // namespace content | 3191 } // namespace content |
OLD | NEW |