Struct Aes128Gcm

Source
pub struct Aes128Gcm<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> { /* private fields */ }

Implementations§

Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> Aes128Gcm<'a, A>

Source

pub fn new(aes: &'a A, crypt_buf: &'static mut [u8]) -> Aes128Gcm<'a, A>

Trait Implementations§

Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> AES128<'a> for Aes128Gcm<'a, A>

Source§

fn enable(&self)

Enable the AES hardware. Must be called before any other methods
Source§

fn disable(&self)

Disable the AES hardware
Source§

fn set_client(&'a self, client: &'a dyn Client<'a>)

Set the client instance which will receive crypt_done() callbacks
Source§

fn set_key(&self, key: &[u8]) -> Result<(), ErrorCode>

Set the encryption key. Returns INVAL if length is not AES128_KEY_SIZE
Source§

fn set_iv(&self, iv: &[u8]) -> Result<(), ErrorCode>

Set the IV (or initial counter). Returns INVAL if length is not AES128_BLOCK_SIZE
Source§

fn start_message(&self)

Begin a new message (with the configured IV) when crypt() is next called. Multiple calls to crypt() may be made between calls to start_message(), allowing the encryption context to extend over non-contiguous extents of data. Read more
Source§

fn crypt( &self, source: Option<&'static mut [u8]>, dest: &'static mut [u8], start_index: usize, stop_index: usize, ) -> Option<(Result<(), ErrorCode>, Option<&'static mut [u8]>, &'static mut [u8])>

Request an encryption/decryption Read more
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> AES128CBC for Aes128Gcm<'a, A>

Source§

fn set_mode_aes128cbc(&self, encrypting: bool) -> Result<(), ErrorCode>

Call before AES128::crypt() to perform AES128CBC
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> AES128CCM<'a> for Aes128Gcm<'a, A>

Source§

fn set_client(&'a self, client: &'a dyn CCMClient)

Set the client instance which will receive crypt_done() callbacks
Source§

fn set_key(&self, key: &[u8]) -> Result<(), ErrorCode>

Set the key to be used for CCM encryption
Source§

fn set_nonce(&self, nonce: &[u8]) -> Result<(), ErrorCode>

Set the nonce (length NONCE_LENGTH) to be used for CCM encryption
Source§

fn crypt( &self, buf: &'static mut [u8], a_off: usize, m_off: usize, m_len: usize, mic_len: usize, confidential: bool, encrypting: bool, ) -> Result<(), (ErrorCode, &'static mut [u8])>

Try to begin the encryption/decryption process
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> AES128Ctr for Aes128Gcm<'a, A>

Source§

fn set_mode_aes128ctr(&self, encrypting: bool) -> Result<(), ErrorCode>

Call before AES128::crypt() to perform AES128Ctr
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> AES128ECB for Aes128Gcm<'a, A>

Source§

fn set_mode_aes128ecb(&self, encrypting: bool) -> Result<(), ErrorCode>

Call before AES128::crypt() to perform AES128ECB
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> AES128GCM<'a> for Aes128Gcm<'a, A>

Source§

fn set_client(&self, client: &'a dyn GCMClient)

Set the client instance which will receive crypt_done() callbacks
Source§

fn set_key(&self, key: &[u8]) -> Result<(), ErrorCode>

Set the key to be used for GCM encryption Returns INVAL if length is not AES128_KEY_SIZE
Source§

fn set_iv(&self, nonce: &[u8]) -> Result<(), ErrorCode>

Set the IV to be used for GCM encryption. The IV should be less or equal to 12 bytes (96 bits) as recommened in NIST-800-38D. Returns INVAL if length is greater then 12 bytes
Source§

fn crypt( &self, buf: &'static mut [u8], aad_offset: usize, message_offset: usize, message_len: usize, encrypting: bool, ) -> Result<(), (ErrorCode, &'static mut [u8])>

Try to begin the encryption/decryption process The possible ErrorCodes are: - BUSY: An operation is already in progress - SIZE: The offset and lengths don’t fit inside the buffer
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> CCMClient for Aes128Gcm<'a, A>

Source§

fn crypt_done( &self, buf: &'static mut [u8], res: Result<(), ErrorCode>, tag_is_valid: bool, )

res is Ok(()) if the encryption/decryption process succeeded. This does not mean that the message has been verified in the case of decryption. If we are encrypting: tag_is_valid is true iff res is Ok(()). If we are decrypting: tag_is_valid is true iff res is Ok(()) and the message authentication tag is valid.
Source§

impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB + AES128CCM<'a>> Client<'a> for Aes128Gcm<'a, A>

Source§

fn crypt_done(&self, _: Option<&'static mut [u8]>, crypt_buf: &'static mut [u8])

Auto Trait Implementations§

§

impl<'a, A> !Freeze for Aes128Gcm<'a, A>

§

impl<'a, A> !RefUnwindSafe for Aes128Gcm<'a, A>

§

impl<'a, A> !Send for Aes128Gcm<'a, A>

§

impl<'a, A> !Sync for Aes128Gcm<'a, A>

§

impl<'a, A> Unpin for Aes128Gcm<'a, A>

§

impl<'a, A> !UnwindSafe for Aes128Gcm<'a, A>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.