citadel_sdk::prelude

Trait Ratchet

pub trait Ratchet:
    Debug
    + Serialize
    + for<'a> Deserialize<'a>
    + Clone
    + Send
    + Sync
    + 'static {
    type Constructor: EndpointRatchetConstructor<Self> + Serialize + for<'a> Deserialize<'a>;

Show 18 methods // Required methods fn get_default_security_level(&self) -> SecurityLevel; fn get_message_pqc_and_entropy_bank_at_layer( &self, idx: Option<usize>, ) -> Result<(&PostQuantumContainer, &EntropyBank), CryptError>; fn get_scramble_pqc_and_entropy_bank( &self, ) -> (&PostQuantumContainer, &EntropyBank); fn get_next_constructor_opts(&self) -> Vec<ConstructorOpts>; fn message_ratchet_count(&self) -> usize; // Provided methods fn get_cid(&self) -> u64 { ... } fn version(&self) -> u32 { ... } fn has_verified_packets(&self) -> bool { ... } fn reset_ara(&self) { ... } fn protect_message_packet<T>( &self, security_level: Option<SecurityLevel>, header_len_bytes: usize, packet: &mut T, ) -> Result<(), CryptError> where T: EzBuffer { ... } fn validate_message_packet<H, T>( &self, security_level: Option<SecurityLevel>, header: H, packet: &mut T, ) -> Result<(), CryptError> where H: AsRef<[u8]>, T: EzBuffer { ... } fn next_alice_constructor(&self) -> Option<Self::Constructor> { ... } fn local_encrypt<'a, T>( &self, contents: T, security_level: SecurityLevel, ) -> Result<Vec<u8>, CryptError> where T: Into<Cow<'a, [u8]>> { ... } fn local_decrypt<'a, T>( &self, contents: T, security_level: SecurityLevel, ) -> Result<Vec<u8>, CryptError> where T: Into<Cow<'a, [u8]>> { ... } fn verify_level( &self, security_level: Option<SecurityLevel>, ) -> Result<usize, CryptError> { ... } fn validate_message_packet_in_place_split<H>( &self, security_level: Option<SecurityLevel>, header: H, packet: &mut BytesMut, ) -> Result<(), CryptError> where H: AsRef<[u8]> { ... } fn decrypt<T>(&self, contents: T) -> Result<Vec<u8>, CryptError> where T: AsRef<[u8]> { ... } fn encrypt<T>(&self, contents: T) -> Result<Vec<u8>, CryptError> where T: AsRef<[u8]> { ... }
}
Expand description

For allowing registration inside the toolset

Required Associated Types§

type Constructor: EndpointRatchetConstructor<Self> + Serialize + for<'a> Deserialize<'a>

Required Methods§

fn get_default_security_level(&self) -> SecurityLevel

Returns the default security level

fn get_message_pqc_and_entropy_bank_at_layer( &self, idx: Option<usize>, ) -> Result<(&PostQuantumContainer, &EntropyBank), CryptError>

Returns the message PQC and entropy_bank for the specified index

fn get_scramble_pqc_and_entropy_bank( &self, ) -> (&PostQuantumContainer, &EntropyBank)

Returns the scramble entropy_bank

fn get_next_constructor_opts(&self) -> Vec<ConstructorOpts>

Returns the next constructor options

fn message_ratchet_count(&self) -> usize

Provided Methods§

fn get_cid(&self) -> u64

Returns the client ID

fn version(&self) -> u32

Returns the version

fn has_verified_packets(&self) -> bool

Determines if any of the ratchets have verified packets

fn reset_ara(&self)

Resets the anti-replay attack counters

fn protect_message_packet<T>( &self, security_level: Option<SecurityLevel>, header_len_bytes: usize, packet: &mut T, ) -> Result<(), CryptError>
where T: EzBuffer,

Protects a message packet using the entire ratchet’s security features

fn validate_message_packet<H, T>( &self, security_level: Option<SecurityLevel>, header: H, packet: &mut T, ) -> Result<(), CryptError>
where H: AsRef<[u8]>, T: EzBuffer,

Validates a message packet using the entire ratchet’s security features

fn next_alice_constructor(&self) -> Option<Self::Constructor>

Returns the next Alice constructor

fn local_encrypt<'a, T>( &self, contents: T, security_level: SecurityLevel, ) -> Result<Vec<u8>, CryptError>
where T: Into<Cow<'a, [u8]>>,

Encrypts using a local key that is not shared with anyone. Relevant for RE-VFS

fn local_decrypt<'a, T>( &self, contents: T, security_level: SecurityLevel, ) -> Result<Vec<u8>, CryptError>
where T: Into<Cow<'a, [u8]>>,

Decrypts using a local key that is not shared with anyone. Relevant for RE-VFS

fn verify_level( &self, security_level: Option<SecurityLevel>, ) -> Result<usize, CryptError>

Verifies the target security level, returning the corresponding idx

fn validate_message_packet_in_place_split<H>( &self, security_level: Option<SecurityLevel>, header: H, packet: &mut BytesMut, ) -> Result<(), CryptError>
where H: AsRef<[u8]>,

Validates in-place when the header + payload have already been split

fn decrypt<T>(&self, contents: T) -> Result<Vec<u8>, CryptError>
where T: AsRef<[u8]>,

decrypts using a custom nonce configuration

fn encrypt<T>(&self, contents: T) -> Result<Vec<u8>, CryptError>
where T: AsRef<[u8]>,

Encrypts the data into a Vec

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl Ratchet for MonoRatchet

§

type Constructor = MonoRatchetConstructor

§

impl Ratchet for StackedRatchet

§

type Constructor = StackedRatchetConstructor