| 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 "net/quic/core/crypto/channel_id.h" | 5 #include "net/quic/core/crypto/channel_id.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "net/quic/test_tools/crypto_test_utils.h" | 9 #include "net/quic/test_tools/crypto_test_utils.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 EXPECT_EQ(test_vector[i].result, | 277 EXPECT_EQ(test_vector[i].result, |
| 278 ChannelIDVerifier::VerifyRaw( | 278 ChannelIDVerifier::VerifyRaw( |
| 279 StringPiece(key, sizeof(key)), StringPiece(msg, msg_len), | 279 StringPiece(key, sizeof(key)), StringPiece(msg, msg_len), |
| 280 StringPiece(signature, sizeof(signature)), false)); | 280 StringPiece(signature, sizeof(signature)), false)); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 TEST(ChannelIDTest, SignAndVerify) { | 284 TEST(ChannelIDTest, SignAndVerify) { |
| 285 std::unique_ptr<ChannelIDSource> source( | 285 std::unique_ptr<ChannelIDSource> source( |
| 286 CryptoTestUtils::ChannelIDSourceForTesting()); | 286 crypto_test_utils::ChannelIDSourceForTesting()); |
| 287 | 287 |
| 288 const string signed_data = "signed data"; | 288 const string signed_data = "signed data"; |
| 289 const string hostname = "foo.example.com"; | 289 const string hostname = "foo.example.com"; |
| 290 std::unique_ptr<ChannelIDKey> channel_id_key; | 290 std::unique_ptr<ChannelIDKey> channel_id_key; |
| 291 QuicAsyncStatus status = | 291 QuicAsyncStatus status = |
| 292 source->GetChannelIDKey(hostname, &channel_id_key, nullptr); | 292 source->GetChannelIDKey(hostname, &channel_id_key, nullptr); |
| 293 ASSERT_EQ(QUIC_SUCCESS, status); | 293 ASSERT_EQ(QUIC_SUCCESS, status); |
| 294 | 294 |
| 295 string signature; | 295 string signature; |
| 296 ASSERT_TRUE(channel_id_key->Sign(signed_data, &signature)); | 296 ASSERT_TRUE(channel_id_key->Sign(signed_data, &signature)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 311 memcpy(bad_signature.get(), signature.data(), signature.size()); | 311 memcpy(bad_signature.get(), signature.data(), signature.size()); |
| 312 bad_signature[1] ^= 0x80; | 312 bad_signature[1] ^= 0x80; |
| 313 EXPECT_FALSE(ChannelIDVerifier::Verify( | 313 EXPECT_FALSE(ChannelIDVerifier::Verify( |
| 314 key, signed_data, string(bad_signature.get(), signature.size()))); | 314 key, signed_data, string(bad_signature.get(), signature.size()))); |
| 315 | 315 |
| 316 EXPECT_FALSE(ChannelIDVerifier::Verify(key, "wrong signed data", signature)); | 316 EXPECT_FALSE(ChannelIDVerifier::Verify(key, "wrong signed data", signature)); |
| 317 } | 317 } |
| 318 | 318 |
| 319 } // namespace test | 319 } // namespace test |
| 320 } // namespace net | 320 } // namespace net |
| OLD | NEW |