Struct RsaModularExponentiation

Source
pub struct RsaModularExponentiation<'a, 'd, T: RsaMode, Dm: DriverMode> { /* private fields */ }
Available on crate feature unstable only.
Expand description

Support for RSA peripheral’s modular exponentiation feature that could be used to find the (base ^ exponent) mod modulus.

Each operand is a little endian byte array of the same size

Implementations§

Source§

impl<T, const N: usize> RsaModularExponentiation<'_, '_, T, Async>
where T: RsaMode<InputType = [u32; N]> + RsaMode,

Source

pub async fn exponentiation( &mut self, base: &T::InputType, r: &T::InputType, outbuf: &mut T::InputType, )

Asynchronously performs an RSA modular exponentiation operation.

Source§

impl<'a, 'd, T, Dm: DriverMode, const N: usize> RsaModularExponentiation<'a, 'd, T, Dm>
where T: RsaMode<InputType = [u32; N]> + RsaMode,

Source

pub fn new( rsa: &'a mut Rsa<'d, Dm>, exponent: &T::InputType, modulus: &T::InputType, m_prime: u32, ) -> Self

Creates an instance of RsaModularExponentiation.

m_prime could be calculated using -(modular multiplicative inverse of modulus) mod 2^32.

For more information refer to 24.3.2 of https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf.

Source

pub fn start_exponentiation(&mut self, base: &T::InputType, r: &T::InputType)

Starts the modular exponentiation operation.

r can be calculated using 2 ^ ( bitlength * 2 ) mod modulus.

For more information refer to 24.3.2 of https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf.

Source

pub fn read_results(&mut self, outbuf: &mut T::InputType)

Reads the result to the given buffer.

This is a non blocking function that returns without an error if operation is completed successfully. start_exponentiation must be called before calling this function.

Auto Trait Implementations§

§

impl<'a, 'd, T, Dm> Freeze for RsaModularExponentiation<'a, 'd, T, Dm>

§

impl<'a, 'd, T, Dm> RefUnwindSafe for RsaModularExponentiation<'a, 'd, T, Dm>
where T: RefUnwindSafe, Dm: RefUnwindSafe,

§

impl<'a, 'd, T, Dm> Send for RsaModularExponentiation<'a, 'd, T, Dm>
where T: Send, Dm: Send,

§

impl<'a, 'd, T, Dm> Sync for RsaModularExponentiation<'a, 'd, T, Dm>
where T: Sync, Dm: Sync,

§

impl<'a, 'd, T, Dm> Unpin for RsaModularExponentiation<'a, 'd, T, Dm>
where T: Unpin,

§

impl<'a, 'd, T, Dm> !UnwindSafe for RsaModularExponentiation<'a, 'd, T, Dm>

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.

§

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.