This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/quic-latest by this push:
new 83bc828 Fix test_QUICLossDetector
83bc828 is described below
commit 83bc8289e3de15bc3bb036d2a103ddc21b4f7d6a
Author: Masaori Koshiba <[email protected]>
AuthorDate: Mon Apr 8 14:36:22 2019 +0900
Fix test_QUICLossDetector
---
iocore/net/quic/QUICPacketPayloadProtector.cc | 9 +++++----
iocore/net/quic/QUICPacketProtectionKeyInfo.cc | 1 -
iocore/net/quic/test/test_QUICKeyGenerator.cc | 1 -
iocore/net/quic/test/test_QUICLossDetector.cc | 3 +++
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/iocore/net/quic/QUICPacketPayloadProtector.cc
b/iocore/net/quic/QUICPacketPayloadProtector.cc
index f79e2ef..35c44b5 100644
--- a/iocore/net/quic/QUICPacketPayloadProtector.cc
+++ b/iocore/net/quic/QUICPacketPayloadProtector.cc
@@ -34,14 +34,15 @@ QUICPacketPayloadProtector::protect(const
Ptr<IOBufferBlock> unprotected_header,
Ptr<IOBufferBlock> protected_payload;
protected_payload = nullptr;
+ if (!this->_pp_key_info.is_encryption_key_available(phase)) {
+ Debug(tag, "Failed to encrypt a packet: keys for %s is not ready",
QUICDebugNames::key_phase(phase));
+ return protected_payload;
+ }
+
size_t tag_len = this->_pp_key_info.get_tag_len(phase);
const uint8_t *key = this->_pp_key_info.encryption_key(phase);
const uint8_t *iv = this->_pp_key_info.encryption_iv(phase);
size_t iv_len = *this->_pp_key_info.encryption_iv_len(phase);
- if (!key || key[0] == 0x00) {
- Debug(tag, "Failed to encrypt a packet: keys for %s is not ready",
QUICDebugNames::key_phase(phase));
- return protected_payload;
- }
const QUIC_EVP_CIPHER *aead = this->_pp_key_info.get_cipher(phase);
diff --git a/iocore/net/quic/QUICPacketProtectionKeyInfo.cc
b/iocore/net/quic/QUICPacketProtectionKeyInfo.cc
index f782d35..2f791cb 100644
--- a/iocore/net/quic/QUICPacketProtectionKeyInfo.cc
+++ b/iocore/net/quic/QUICPacketProtectionKeyInfo.cc
@@ -91,7 +91,6 @@
QUICPacketProtectionKeyInfo::set_encryption_key_available(QUICKeyPhase phase)
this->_is_server_key_available[index] = true;
} else {
this->_is_client_key_available[index] = true;
- ;
}
}
diff --git a/iocore/net/quic/test/test_QUICKeyGenerator.cc
b/iocore/net/quic/test/test_QUICKeyGenerator.cc
index dc152a2..e24d3db 100644
--- a/iocore/net/quic/test/test_QUICKeyGenerator.cc
+++ b/iocore/net/quic/test/test_QUICKeyGenerator.cc
@@ -46,7 +46,6 @@ TEST_CASE("draft-17 Test Vectors", "[quic]")
uint8_t expected_client_key[] = {
0x86, 0xd1, 0x83, 0x04, 0x80, 0xb4, 0x0f, 0x86, 0xcf, 0x9d, 0x68, 0xdc,
0xad, 0xf3, 0x5d, 0xfe,
-
};
uint8_t expected_client_iv[] = {
0x12, 0xf3, 0x93, 0x8a, 0xca, 0x34, 0xaa, 0x02, 0x54, 0x31, 0x63, 0xd4,
diff --git a/iocore/net/quic/test/test_QUICLossDetector.cc
b/iocore/net/quic/test/test_QUICLossDetector.cc
index 096c7f4..c0c2b29 100644
--- a/iocore/net/quic/test/test_QUICLossDetector.cc
+++ b/iocore/net/quic/test/test_QUICLossDetector.cc
@@ -31,6 +31,8 @@
TEST_CASE("QUICLossDetector_Loss", "[quic]")
{
MockQUICPacketProtectionKeyInfo pp_key_info;
+ pp_key_info.set_encryption_key_available(QUICKeyPhase::PHASE_0);
+
QUICPacketFactory pf(pp_key_info);
QUICRTTMeasure rtt_measure;
@@ -96,6 +98,7 @@ TEST_CASE("QUICLossDetector_Loss", "[quic]")
payload = ats_unique_malloc(payload_len);
QUICPacketUPtr packet1 = pf.create_protected_packet(connection_id,
detector.largest_acked_packet_number(), std::move(payload),
payload_len, true,
false);
+ REQUIRE(packet1 != nullptr);
payload = ats_unique_malloc(payload_len);
QUICPacketUPtr packet2 = pf.create_protected_packet(connection_id,
detector.largest_acked_packet_number(), std::move(payload),
payload_len, true,
false);