mirror of
https://github.com/bolucat/Archive.git
synced 2025-10-16 13:11:02 +08:00
Update On Sat Nov 2 19:33:11 CET 2024
This commit is contained in:
@@ -7,7 +7,7 @@ use log::warn;
|
||||
|
||||
use crate::{
|
||||
config::{ReplayAttackPolicy, ServerType},
|
||||
crypto::{v1::random_iv_or_salt, CipherKind},
|
||||
crypto::CipherKind,
|
||||
dns_resolver::DnsResolver,
|
||||
security::replay::ReplayProtector,
|
||||
};
|
||||
@@ -50,6 +50,7 @@ impl Context {
|
||||
/// Check if nonce exist or not
|
||||
///
|
||||
/// If not, set into the current bloom filter
|
||||
#[cfg(any(feature = "stream-cipher", feature = "aead-cipher", feature = "aead-cipher-2022"))]
|
||||
#[inline(always)]
|
||||
fn check_nonce_and_set(&self, method: CipherKind, nonce: &[u8]) -> bool {
|
||||
match self.replay_policy {
|
||||
@@ -64,7 +65,10 @@ impl Context {
|
||||
return;
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "stream-cipher", feature = "aead-cipher", feature = "aead-cipher-2022"))]
|
||||
loop {
|
||||
use crate::crypto::utils::random_iv_or_salt;
|
||||
|
||||
random_iv_or_salt(nonce);
|
||||
|
||||
// Salt already exists, generate a new one.
|
||||
@@ -74,6 +78,12 @@ impl Context {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "stream-cipher", feature = "aead-cipher", feature = "aead-cipher-2022")))]
|
||||
if !nonce.is_empty() {
|
||||
let _ = unique;
|
||||
panic!("{method} don't know how to generate nonce");
|
||||
}
|
||||
}
|
||||
|
||||
/// Check nonce replay
|
||||
|
Reference in New Issue
Block a user