diff options
author | 2022-09-27 15:53:31 +0800 | |
---|---|---|
committer | 2022-09-29 14:53:34 +0100 | |
commit | f51a64e109a8c0055a3c7c5acf208f287a31b797 (patch) | |
tree | 01c74ac76542c08654cad03c31cf2490d43bdb4a | |
parent | 396ae13ac668f86cabda75ec861405787ed935cf (diff) | |
download | quiche-f51a64e109a8c0055a3c7c5acf208f287a31b797.tar.gz quiche-f51a64e109a8c0055a3c7c5acf208f287a31b797.tar.zst quiche-f51a64e109a8c0055a3c7c5acf208f287a31b797.zip |
packet: fix hard-coding constants
Previously, both MAX_PKT_NUM_LEN and SAMPLE_LEN are hard-coded at `encrypt_hdr` while it is not the case at `decrypt_hdr`. If any of the constant is changed in the future, one must carefully sync up the redundant hard-coded constant at `encrypt_hdr`. After the change, it is more consistent and the hard-coding is alleviated.
No functional code is changed.
-rw-r--r-- | quiche/src/packet.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/quiche/src/packet.rs b/quiche/src/packet.rs index 1d1a3f5a..3665f249 100644 --- a/quiche/src/packet.rs +++ b/quiche/src/packet.rs @@ -625,7 +625,8 @@ pub fn decrypt_pkt<'a>( pub fn encrypt_hdr( b: &mut octets::OctetsMut, pn_len: usize, payload: &[u8], aead: &crypto::Seal, ) -> Result<()> { - let sample = &payload[4 - pn_len..16 + (4 - pn_len)]; + let sample = &payload + [MAX_PKT_NUM_LEN - pn_len..SAMPLE_LEN + (MAX_PKT_NUM_LEN - pn_len)]; let mask = aead.new_mask(sample)?; |