diff --git a/performance/src/crypto/aes.rs b/performance/src/crypto/aes.rs index 7fc91fe..804f614 100644 --- a/performance/src/crypto/aes.rs +++ b/performance/src/crypto/aes.rs @@ -120,6 +120,15 @@ pub trait HighThroughputAesGcmPool: Send + Sync { /// Be sure to perform your own benchmark. #[must_use] fn finish_dec<'a>(&'a self, dec: Self::DecContext<'a>, tag: &[u8; AES_GCM_TAG_SIZE]) -> bool; + + /// Cancel encryption with `enc` without creating an authentication tag. + /// This is near identical in behavior to `finish_enc`, and is implemented by `finish_enc` + /// by default. + /// It is somewhat more secure to replace this default implementation with a version that does + /// not produce a valid authentication tag on an invalid payload. + fn cancel_enc<'a>(&'a self, enc: Self::EncContext<'a>) { + self.finish_enc(enc); + } } /// A trait for implementing AES-GCM-256 to handle the more varied, but much lower throughput diff --git a/performance/src/zeta.rs b/performance/src/zeta.rs index 1d42bc4..95e6315 100644 --- a/performance/src/zeta.rs +++ b/performance/src/zeta.rs @@ -1692,7 +1692,7 @@ pub(crate) fn send_payload( if !send.send_frag(&mut mtu_sized_buffer[..HEADER_SIZE + fragment_len]) { // We need to give the cipher back to the pool instead of dropping it, // so it can do memory cleanup. - cipher_pool.finish_enc(cipher); + cipher_pool.cancel_enc(cipher); return Ok(false); } i = j;