mirror of
https://github.com/zerotier/zssp.git
synced 2026-05-22 16:28:40 -07:00
slightly improved API safety
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1692,7 +1692,7 @@ pub(crate) fn send_payload<C: CryptoLayer>(
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user