big changes

This commit is contained in:
2026-02-25 18:09:20 +07:00
parent bf7d50bcef
commit 2835108b7f
56 changed files with 1111 additions and 775 deletions
+40
View File
@@ -0,0 +1,40 @@
use aead::{rand_core::RngCore, OsRng};
pub struct SaltPair {
local_salt: [u8; 32],
remote_salt: [u8; 32],
is_initiator: bool,
}
impl SaltPair {
pub fn new(is_initiator: bool) -> Self {
let mut local_salt = [0u8; 32];
OsRng.fill_bytes(&mut local_salt);
Self {
local_salt,
remote_salt: [0; 32],
is_initiator,
}
}
pub fn get_local(&self) -> [u8; 32] {
self.local_salt
}
pub fn set_remote_salt(&mut self, salt: [u8; 32]) {
self.remote_salt = salt
}
pub fn get_total(&self) -> [u8; 64] {
let mut salt = [0u8; 64];
if self.is_initiator {
salt[..32].copy_from_slice(&self.local_salt);
salt[32..].copy_from_slice(&self.remote_salt);
salt
} else {
salt[..32].copy_from_slice(&self.remote_salt);
salt[32..].copy_from_slice(&self.local_salt);
salt
}
}
}