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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/stl_util.h" | |
7 #include "base/values.h" | 6 #include "base/values.h" |
8 #include "components/webcrypto/algorithm_dispatch.h" | 7 #include "components/webcrypto/algorithm_dispatch.h" |
9 #include "components/webcrypto/algorithms/test_helpers.h" | 8 #include "components/webcrypto/algorithms/test_helpers.h" |
10 #include "components/webcrypto/crypto_data.h" | 9 #include "components/webcrypto/crypto_data.h" |
11 #include "components/webcrypto/status.h" | 10 #include "components/webcrypto/status.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
14 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
15 | 14 |
16 namespace webcrypto { | 15 namespace webcrypto { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 84 |
86 bool signature_match = false; | 85 bool signature_match = false; |
87 EXPECT_EQ(Status::Success(), | 86 EXPECT_EQ(Status::Success(), |
88 Verify(algorithm, key, CryptoData(output), | 87 Verify(algorithm, key, CryptoData(output), |
89 CryptoData(test_message), &signature_match)); | 88 CryptoData(test_message), &signature_match)); |
90 EXPECT_TRUE(signature_match); | 89 EXPECT_TRUE(signature_match); |
91 | 90 |
92 // Ensure truncated signature does not verify by passing one less byte. | 91 // Ensure truncated signature does not verify by passing one less byte. |
93 EXPECT_EQ(Status::Success(), | 92 EXPECT_EQ(Status::Success(), |
94 Verify(algorithm, key, | 93 Verify(algorithm, key, |
95 CryptoData(vector_as_array(&output), | 94 CryptoData(output.data(), |
96 static_cast<unsigned int>(output.size()) - 1), | 95 static_cast<unsigned int>(output.size()) - 1), |
97 CryptoData(test_message), &signature_match)); | 96 CryptoData(test_message), &signature_match)); |
98 EXPECT_FALSE(signature_match); | 97 EXPECT_FALSE(signature_match); |
99 | 98 |
100 // Ensure truncated signature does not verify by passing no bytes. | 99 // Ensure truncated signature does not verify by passing no bytes. |
101 EXPECT_EQ(Status::Success(), | 100 EXPECT_EQ(Status::Success(), |
102 Verify(algorithm, key, CryptoData(), CryptoData(test_message), | 101 Verify(algorithm, key, CryptoData(), CryptoData(test_message), |
103 &signature_match)); | 102 &signature_match)); |
104 EXPECT_FALSE(signature_match); | 103 EXPECT_FALSE(signature_match); |
105 | 104 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 // On export the last 4 bits has been set to zero. | 592 // On export the last 4 bits has been set to zero. |
594 std::vector<uint8_t> raw_key; | 593 std::vector<uint8_t> raw_key; |
595 EXPECT_EQ(Status::Success(), | 594 EXPECT_EQ(Status::Success(), |
596 ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); | 595 ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
597 EXPECT_BYTES_EQ(HexStringToBytes("b1f0"), raw_key); | 596 EXPECT_BYTES_EQ(HexStringToBytes("b1f0"), raw_key); |
598 } | 597 } |
599 | 598 |
600 } // namespace | 599 } // namespace |
601 | 600 |
602 } // namespace webcrypto | 601 } // namespace webcrypto |
OLD | NEW |