Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: net/quic/core/crypto/channel_id_test.cc

Issue 2681793002: Landing Recent QUIC changes until 5:30 PM, Feb 3, 2017 UTC-5 (Closed)
Patch Set: sync and rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « net/quic/core/crypto/chacha20_poly1305_encrypter_test.cc ('k') | net/quic/core/crypto/crypto_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698