CryptoEngine

Struct CryptoEngine 

Source
pub struct CryptoEngine<A: AesProvider, S: Sha256Provider> { /* private fields */ }
Expand description

UMSH protocol crypto engine.

Implementations§

Source§

impl<A: AesProvider, S: Sha256Provider> CryptoEngine<A, S>

Source

pub fn new(aes: A, sha: S) -> Self

Create a new engine from algorithm providers.

Source

pub fn derive_pairwise_keys(&self, shared_secret: &SharedSecret) -> PairwiseKeys

Derive stable pairwise encryption and MIC keys from a shared secret.

Source

pub fn derive_channel_id(&self, channel_key: &ChannelKey) -> ChannelId

Derive the channel identifier from a raw channel key.

Source

pub fn derive_channel_keys( &self, channel_key: &ChannelKey, ) -> DerivedChannelKeys

Derive multicast transport keys and the channel identifier.

Source

pub fn derive_blind_keys( &self, pairwise: &PairwiseKeys, channel: &DerivedChannelKeys, ) -> PairwiseKeys

Combine pairwise and channel keys for blind-unicast payload protection.

Source

pub fn derive_named_channel_key(&self, name: &str) -> ChannelKey

Derive a channel key from a human-readable channel name.

Source

pub fn seal_packet( &self, packet: &mut UnsealedPacket<'_>, keys: &PairwiseKeys, ) -> Result<usize, CryptoError>

Seal a unicast or multicast packet in place.

Source

pub fn seal_blind_packet( &self, packet: &mut UnsealedPacket<'_>, blind_keys: &PairwiseKeys, channel_keys: &DerivedChannelKeys, ) -> Result<usize, CryptoError>

Seal a blind-unicast packet, including its hidden address block.

Source

pub fn open_packet( &self, buf: &mut [u8], header: &PacketHeader, keys: &PairwiseKeys, ) -> Result<Range<usize>, CryptoError>

Verify and, if needed, decrypt a received secure packet in place.

Source

pub fn decrypt_blind_addr( &self, buf: &mut [u8], header: &PacketHeader, channel_keys: &DerivedChannelKeys, ) -> Result<(NodeHint, SourceAddrRef), CryptoError>

Decrypt the blinded destination/source address block of a blind unicast.

Source

pub fn compute_ack_tag(&self, full_cmac: &[u8; 16], k_enc: &[u8; 16]) -> [u8; 8]

Compute the 8-byte transport ACK tag from a full CMAC and k_enc.

Source

pub fn cmac_state(&self, key: &[u8; 16]) -> CmacState<A::Cipher>

Create a reusable incremental CMAC state.

Source

pub fn aes_cmac(&self, key: &[u8; 16], data: &[&[u8]]) -> [u8; 16]

Convenience wrapper for AES-CMAC over concatenated slices.

Source

pub fn aes_ctr(&self, key: &[u8; 16], iv: &[u8; 16], data: &mut [u8])

Apply AES-CTR using iv as the initial counter block.

Source

pub fn build_ctr_iv(&self, mic: &[u8], sec_info_bytes: &[u8]) -> [u8; 16]

Construct the CTR IV from MIC bytes and SECINFO bytes.

Source

pub fn hkdf(&self, ikm: &[u8], salt: &[u8], info: &[u8], okm: &mut [u8])

Run HKDF-SHA256 and write the output into okm.

Auto Trait Implementations§

§

impl<A, S> Freeze for CryptoEngine<A, S>
where A: Freeze, S: Freeze,

§

impl<A, S> RefUnwindSafe for CryptoEngine<A, S>

§

impl<A, S> Send for CryptoEngine<A, S>
where A: Send, S: Send,

§

impl<A, S> Sync for CryptoEngine<A, S>
where A: Sync, S: Sync,

§

impl<A, S> Unpin for CryptoEngine<A, S>
where A: Unpin, S: Unpin,

§

impl<A, S> UnwindSafe for CryptoEngine<A, S>
where A: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.