rust-nex/prudpv0/src/crypto/mod.rs
Maple Nebel f1d16e40a1
Some checks failed
Build and Test / puyopuyo (push) Failing after 26s
Build and Test / splatoon-testfire (push) Failing after 27s
Build and Test / minecraft-wiiu (push) Failing after 2m34s
Build and Test / fast-racing-neo (push) Failing after 2m36s
Build and Test / mario-tennis (push) Failing after 2m38s
Build and Test / splatoon (push) Failing after 2m38s
Build and Test / wii-u-chat (push) Failing after 5m25s
Build and Test / friends (push) Successful in 6m34s
Build and Test / super-mario-maker (push) Failing after 6m43s
Build and Test / sonic-transformed (push) Failing after 6m58s
Build and Test / wii-sports-club (push) Failing after 7m9s
progress
2026-07-13 23:47:15 +02:00

39 lines
1 KiB
Rust

use cfg_if::cfg_if;
use rnex_prudp::types_flags::TypesFlags;
use rnex_util::PID;
mod common_crypto;
pub trait CryptoInstance: Send + 'static {
fn decrypt_incoming(&mut self, data: &mut [u8]);
fn encrypt_outgoing(&mut self, data: &mut [u8]);
fn generate_signature(&self, types_flags: TypesFlags, data: &[u8]) -> [u8; 4];
fn get_user_id(&self) -> PID;
}
pub trait Crypto: Send + Sync + 'static {
type Instance: CryptoInstance;
async fn new() -> Self;
fn calculate_checksum(&self, data: &[u8]) -> u8;
fn instantiate(
&self,
data: &[u8],
self_signat: [u8; 4],
remote_signat: [u8; 4],
) -> Option<(Self::Instance, Vec<u8>)>;
}
cfg_if! {
if #[cfg(feature = "friends")]{
pub mod friends_common;
pub mod friends_insecure;
pub use friends_insecure::*;
pub mod friends_secure;
pub use friends_secure::*;
} else {
pub mod secure;
pub use secure::*;
pub mod insecure;
pub use insecure::*;
}
}