Skip to main content

Cal

Trait Cal 

Source
pub trait Cal {
    type DhProvider: DhProvider;
    type AeadProvider: AeadProvider;
    type HashProvider: HashProvider;
    type HmacProvider: HmacProvider;

    // Required methods
    fn dh(&mut self) -> &mut Self::DhProvider;
    fn aead(&mut self) -> &mut Self::AeadProvider;
    fn hash(&mut self) -> &mut Self::HashProvider;
    fn hmac(&mut self) -> &mut Self::HmacProvider;
}
Expand description

Cryptographic abstraction provider that encompasses all features abstracted by the embedded-cal.

To ease implementation and give better access to its aspects, this does not have a list of supertraits, but rather various associated types and acccessors to them.

These allow passing on full portions of the feature set between implementations. Common choices for the associated type and the corresponding accessor implementation are:

  • type XxxProvider = Self / self, when an object does provide that functionality.

  • type XxxProvider = Self::Base / self.base.xxx(), when an extender does not touch that functionality at all and merely forwards it to whatever is being extended.

  • type XxxProvider = embedded_cal::empty::EmptyCal / &mut self.empty, when a non-extender (typically a hardware module) does not implement something at all.

    Note that to keep the types reasonably simple, the accessors are fn(&mut Self) -> &mut Self::XxxProvider, which requires an existing (albeit zero-sized) EmptyCal, which is most easily provided by adding one as a field to the Self struct. (The alternative would be to go through AsMut indirections or use lifetime-generic associated types like type XxxProvider<'t> = &mut Self / = Empty, and that is not only unergonomic, it also hinders restraining them in where clauses).

Required Associated Types§

Source

type DhProvider: DhProvider

The non-supertrait responsible for key establishment.

Source

type AeadProvider: AeadProvider

Source

type HashProvider: HashProvider

Source

type HmacProvider: HmacProvider

Required Methods§

Source

fn dh(&mut self) -> &mut Self::DhProvider

Source

fn aead(&mut self) -> &mut Self::AeadProvider

Source

fn hash(&mut self) -> &mut Self::HashProvider

Source

fn hmac(&mut self) -> &mut Self::HmacProvider

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§