spacedls 0.4.0

no_std CCSDS 355.0-B-2 (SDLS) Space Data Link Security implementation
Documentation
use super::{AuthEncSpec, AuthSpec, EncSpec};
use core::fmt::{Debug, Formatter};
use hybrid_array::Array;

/// Runtime parameters for an encryption operation: key material and IV.
pub struct EncParams<E: EncSpec> {
    pub key: Array<u8, E::KeySize>,
    pub iv: Array<u8, E::IvSize>,
}

impl<E: EncSpec> Debug for EncParams<E> {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_struct("EncParams").field("key", &"***").field("iv", &self.iv).finish()
    }
}

/// Runtime parameters for an authentication operation: key material.
pub struct AuthParams<A: AuthSpec> {
    pub key: Array<u8, A::KeySize>,
}

impl<A: AuthSpec> Debug for AuthParams<A> {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_struct("AuthParams").field("key", &"***").finish()
    }
}

/// Runtime parameters for an AEAD operation: key material and IV.
pub struct AuthEncParams<AE: AuthEncSpec> {
    pub key: Array<u8, AE::KeySize>,
    pub iv: Array<u8, AE::IvSize>,
}

impl<AE: AuthEncSpec> Debug for AuthEncParams<AE> {
    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
        f.debug_struct("AuthEncParams").field("key", &"***").field("iv", &self.iv).finish()
    }
}

pub trait WithKeySize: super::sealed::Sealed {
    type KeySize;
}

impl<E: EncSpec> super::sealed::Sealed for EncParams<E> {}
impl<E: EncSpec> WithKeySize for EncParams<E> {
    type KeySize = E::KeySize;
}

impl<A: AuthSpec> super::sealed::Sealed for AuthParams<A> {}
impl<A: AuthSpec> WithKeySize for AuthParams<A> {
    type KeySize = A::KeySize;
}

impl<AE: AuthEncSpec> super::sealed::Sealed for AuthEncParams<AE> {}
impl<AE: AuthEncSpec> WithKeySize for AuthEncParams<AE> {
    type KeySize = AE::KeySize;
}