| 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 "components/webcrypto/algorithms/test_helpers.h" | 5 #include "components/webcrypto/algorithms/test_helpers.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 return ::testing::AssertionFailure() << "JSON parsing failed"; | 457 return ::testing::AssertionFailure() << "JSON parsing failed"; |
| 458 | 458 |
| 459 // ---- k | 459 // ---- k |
| 460 std::string value_string; | 460 std::string value_string; |
| 461 if (!dict->GetString("k", &value_string)) | 461 if (!dict->GetString("k", &value_string)) |
| 462 return ::testing::AssertionFailure() << "Missing 'k'"; | 462 return ::testing::AssertionFailure() << "Missing 'k'"; |
| 463 std::string k_value; | 463 std::string k_value; |
| 464 if (!Base64DecodeUrlSafe(value_string, &k_value)) | 464 if (!Base64DecodeUrlSafe(value_string, &k_value)) |
| 465 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed"; | 465 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed"; |
| 466 if (!base::LowerCaseEqualsASCII( | 466 if (!base::LowerCaseEqualsASCII( |
| 467 base::HexEncode(k_value.data(), k_value.size()), | 467 base::HexEncode(k_value.data(), k_value.size()), k_expected_hex)) { |
| 468 k_expected_hex.c_str())) { | |
| 469 return ::testing::AssertionFailure() << "Expected 'k' to be " | 468 return ::testing::AssertionFailure() << "Expected 'k' to be " |
| 470 << k_expected_hex | 469 << k_expected_hex |
| 471 << " but found something different"; | 470 << " but found something different"; |
| 472 } | 471 } |
| 473 | 472 |
| 474 return VerifyJwk(dict, "oct", alg_expected, use_mask_expected); | 473 return VerifyJwk(dict, "oct", alg_expected, use_mask_expected); |
| 475 } | 474 } |
| 476 | 475 |
| 477 ::testing::AssertionResult VerifyPublicJwk( | 476 ::testing::AssertionResult VerifyPublicJwk( |
| 478 const std::vector<uint8_t>& json, | 477 const std::vector<uint8_t>& json, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 497 } | 496 } |
| 498 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! | 497 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! |
| 499 | 498 |
| 500 // ---- e | 499 // ---- e |
| 501 if (!dict->GetString("e", &value_string)) | 500 if (!dict->GetString("e", &value_string)) |
| 502 return ::testing::AssertionFailure() << "Missing 'e'"; | 501 return ::testing::AssertionFailure() << "Missing 'e'"; |
| 503 std::string e_value; | 502 std::string e_value; |
| 504 if (!Base64DecodeUrlSafe(value_string, &e_value)) | 503 if (!Base64DecodeUrlSafe(value_string, &e_value)) |
| 505 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed"; | 504 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed"; |
| 506 if (!base::LowerCaseEqualsASCII( | 505 if (!base::LowerCaseEqualsASCII( |
| 507 base::HexEncode(e_value.data(), e_value.size()), | 506 base::HexEncode(e_value.data(), e_value.size()), e_expected_hex)) { |
| 508 e_expected_hex.c_str())) { | |
| 509 return ::testing::AssertionFailure() << "Expected 'e' to be " | 507 return ::testing::AssertionFailure() << "Expected 'e' to be " |
| 510 << e_expected_hex | 508 << e_expected_hex |
| 511 << " but found something different"; | 509 << " but found something different"; |
| 512 } | 510 } |
| 513 | 511 |
| 514 return VerifyJwk(dict, "RSA", alg_expected, use_mask_expected); | 512 return VerifyJwk(dict, "RSA", alg_expected, use_mask_expected); |
| 515 } | 513 } |
| 516 | 514 |
| 517 void ImportExportJwkSymmetricKey( | 515 void ImportExportJwkSymmetricKey( |
| 518 int key_len_bits, | 516 int key_len_bits, |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 } | 684 } |
| 687 | 685 |
| 688 blink::WebCryptoAlgorithm CreateEcImportAlgorithm( | 686 blink::WebCryptoAlgorithm CreateEcImportAlgorithm( |
| 689 blink::WebCryptoAlgorithmId id, | 687 blink::WebCryptoAlgorithmId id, |
| 690 blink::WebCryptoNamedCurve named_curve) { | 688 blink::WebCryptoNamedCurve named_curve) { |
| 691 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( | 689 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
| 692 id, new blink::WebCryptoEcKeyImportParams(named_curve)); | 690 id, new blink::WebCryptoEcKeyImportParams(named_curve)); |
| 693 } | 691 } |
| 694 | 692 |
| 695 } // namespace webcrypto | 693 } // namespace webcrypto |
| OLD | NEW |