OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
6 | 6 |
7 #include "net/quic/crypto/channel_id.h" | 7 #include "net/quic/crypto/channel_id.h" |
8 #include "net/quic/crypto/common_cert_set.h" | 8 #include "net/quic/crypto/common_cert_set.h" |
9 #include "net/quic/crypto/crypto_handshake.h" | 9 #include "net/quic/crypto/crypto_handshake.h" |
10 #include "net/quic/crypto/quic_crypto_server_config.h" | 10 #include "net/quic/crypto/quic_crypto_server_config.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 StringPiece server_decrypter_iv = server_decrypter->GetNoncePrefix(); | 445 StringPiece server_decrypter_iv = server_decrypter->GetNoncePrefix(); |
446 StringPiece server_forward_secure_encrypter_key = | 446 StringPiece server_forward_secure_encrypter_key = |
447 server_forward_secure_encrypter->GetKey(); | 447 server_forward_secure_encrypter->GetKey(); |
448 StringPiece server_forward_secure_encrypter_iv = | 448 StringPiece server_forward_secure_encrypter_iv = |
449 server_forward_secure_encrypter->GetNoncePrefix(); | 449 server_forward_secure_encrypter->GetNoncePrefix(); |
450 StringPiece server_forward_secure_decrypter_key = | 450 StringPiece server_forward_secure_decrypter_key = |
451 server_forward_secure_decrypter->GetKey(); | 451 server_forward_secure_decrypter->GetKey(); |
452 StringPiece server_forward_secure_decrypter_iv = | 452 StringPiece server_forward_secure_decrypter_iv = |
453 server_forward_secure_decrypter->GetNoncePrefix(); | 453 server_forward_secure_decrypter->GetNoncePrefix(); |
454 | 454 |
455 StringPiece client_subkey_secret = | |
456 client->crypto_negotiated_params().subkey_secret; | |
457 StringPiece server_subkey_secret = | |
458 server->crypto_negotiated_params().subkey_secret; | |
459 | |
460 | |
461 const char kSampleLabel[] = "label"; | |
462 const char kSampleContext[] = "context"; | |
463 const int kSampleOutputLength = 32; | |
dmz
2014/07/30 17:58:26
Do you want to use size_t here like you suggested
wtc
2014/07/30 18:09:35
Done. Originally I wanted to see if it caused a co
| |
464 string client_key_extraction; | |
465 string server_key_extraction; | |
466 EXPECT_TRUE(client->ExportKeyingMaterial(kSampleLabel, | |
467 kSampleContext, | |
468 kSampleOutputLength, | |
469 &client_key_extraction)); | |
470 EXPECT_TRUE(server->ExportKeyingMaterial(kSampleLabel, | |
471 kSampleContext, | |
472 kSampleOutputLength, | |
473 &server_key_extraction)); | |
474 | |
455 CompareCharArraysWithHexError("client write key", | 475 CompareCharArraysWithHexError("client write key", |
456 client_encrypter_key.data(), | 476 client_encrypter_key.data(), |
457 client_encrypter_key.length(), | 477 client_encrypter_key.length(), |
458 server_decrypter_key.data(), | 478 server_decrypter_key.data(), |
459 server_decrypter_key.length()); | 479 server_decrypter_key.length()); |
460 CompareCharArraysWithHexError("client write IV", | 480 CompareCharArraysWithHexError("client write IV", |
461 client_encrypter_iv.data(), | 481 client_encrypter_iv.data(), |
462 client_encrypter_iv.length(), | 482 client_encrypter_iv.length(), |
463 server_decrypter_iv.data(), | 483 server_decrypter_iv.data(), |
464 server_decrypter_iv.length()); | 484 server_decrypter_iv.length()); |
(...skipping 20 matching lines...) Expand all Loading... | |
485 CompareCharArraysWithHexError("server forward secure write key", | 505 CompareCharArraysWithHexError("server forward secure write key", |
486 server_forward_secure_encrypter_key.data(), | 506 server_forward_secure_encrypter_key.data(), |
487 server_forward_secure_encrypter_key.length(), | 507 server_forward_secure_encrypter_key.length(), |
488 client_forward_secure_decrypter_key.data(), | 508 client_forward_secure_decrypter_key.data(), |
489 client_forward_secure_decrypter_key.length()); | 509 client_forward_secure_decrypter_key.length()); |
490 CompareCharArraysWithHexError("server forward secure write IV", | 510 CompareCharArraysWithHexError("server forward secure write IV", |
491 server_forward_secure_encrypter_iv.data(), | 511 server_forward_secure_encrypter_iv.data(), |
492 server_forward_secure_encrypter_iv.length(), | 512 server_forward_secure_encrypter_iv.length(), |
493 client_forward_secure_decrypter_iv.data(), | 513 client_forward_secure_decrypter_iv.data(), |
494 client_forward_secure_decrypter_iv.length()); | 514 client_forward_secure_decrypter_iv.length()); |
515 CompareCharArraysWithHexError("subkey secret", | |
516 client_subkey_secret.data(), | |
517 client_subkey_secret.length(), | |
518 server_subkey_secret.data(), | |
519 server_subkey_secret.length()); | |
520 CompareCharArraysWithHexError("sample key extraction", | |
521 client_key_extraction.data(), | |
522 client_key_extraction.length(), | |
523 server_key_extraction.data(), | |
524 server_key_extraction.length()); | |
495 } | 525 } |
496 | 526 |
497 // static | 527 // static |
498 QuicTag CryptoTestUtils::ParseTag(const char* tagstr) { | 528 QuicTag CryptoTestUtils::ParseTag(const char* tagstr) { |
499 const size_t len = strlen(tagstr); | 529 const size_t len = strlen(tagstr); |
500 CHECK_NE(0u, len); | 530 CHECK_NE(0u, len); |
501 | 531 |
502 QuicTag tag = 0; | 532 QuicTag tag = 0; |
503 | 533 |
504 if (tagstr[0] == '#') { | 534 if (tagstr[0] == '#') { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); | 624 scoped_ptr<QuicData> bytes(CryptoFramer::ConstructHandshakeMessage(msg)); |
595 scoped_ptr<CryptoHandshakeMessage> parsed( | 625 scoped_ptr<CryptoHandshakeMessage> parsed( |
596 CryptoFramer::ParseMessage(bytes->AsStringPiece())); | 626 CryptoFramer::ParseMessage(bytes->AsStringPiece())); |
597 CHECK(parsed.get()); | 627 CHECK(parsed.get()); |
598 | 628 |
599 return *parsed; | 629 return *parsed; |
600 } | 630 } |
601 | 631 |
602 } // namespace test | 632 } // namespace test |
603 } // namespace net | 633 } // namespace net |
OLD | NEW |