Skip to main content

ShaDriver

Struct ShaDriver 

Source
pub struct ShaDriver<'a, H: DigestDataHash<'a, DIGEST_LEN>, const DIGEST_LEN: usize> { /* private fields */ }

Implementations§

Source§

impl<'a, H: DigestDataHash<'a, DIGEST_LEN> + Sha256, const DIGEST_LEN: usize> ShaDriver<'a, H, DIGEST_LEN>

Source

pub fn new( sha: &'a H, data_buffer: &'static mut [u8], dest_buffer: &'static mut [u8; DIGEST_LEN], grant: Grant<App, UpcallCount<{ upcall::COUNT }>, AllowRoCount<{ ro_allow::COUNT }>, AllowRwCount<{ rw_allow::COUNT }>>, ) -> ShaDriver<'a, H, DIGEST_LEN>

Trait Implementations§

Source§

impl<'a, H: DigestDataHash<'a, DIGEST_LEN> + Sha256, const DIGEST_LEN: usize> ClientData<DIGEST_LEN> for ShaDriver<'a, H, DIGEST_LEN>

Source§

fn add_data_done( &self, _result: Result<(), ErrorCode>, _data: SubSlice<'static, u8>, )

Called when the data has been added to the digest. Read more
Source§

fn add_mut_data_done( &self, _result: Result<(), ErrorCode>, data: SubSliceMut<'static, u8>, )

Called when the data has been added to the digest. Read more
Source§

impl<'a, H: DigestDataHash<'a, DIGEST_LEN> + Sha256, const DIGEST_LEN: usize> ClientHash<DIGEST_LEN> for ShaDriver<'a, H, DIGEST_LEN>

Source§

fn hash_done( &self, result: Result<(), ErrorCode>, digest: &'static mut [u8; DIGEST_LEN], )

Called when a digest is computed. Read more
Source§

impl<'a, H: DigestDataHash<'a, DIGEST_LEN> + Sha256, const DIGEST_LEN: usize> SyscallDriver for ShaDriver<'a, H, DIGEST_LEN>

Source§

fn command( &self, command_num: usize, data1: usize, _data2: usize, processid: ProcessId, ) -> CommandReturn

Setup and run a SHA hash.

We expect userspace to setup buffers for the data, and either the generated hash or a hash to compare with. These buffers must be allocated and specified to the kernel with allow calls.

We expect userspace not to change the value while running. If userspace changes the value we have no guarantee of what is passed to the hardware. This isn’t a security issue, it will just provide the requesting app with invalid data.

The driver will take care of clearing data from the underlying implementation by calling the clear_data() function when the hash_complete() callback is called or if an error is encountered.

§command_num
  • 0: driver check
  • 1: set_algorithm
  • 2: hash
Source§

fn allocate_grant(&self, processid: ProcessId) -> Result<(), Error>

Request to allocate a capsule’s grant for a specific process. Read more
Source§

fn allow_userspace_readable( &self, app: ProcessId, which: usize, slice: ReadWriteProcessBuffer, ) -> Result<ReadWriteProcessBuffer, (ReadWriteProcessBuffer, ErrorCode)>

System call for a process to pass a buffer (a UserspaceReadableProcessBuffer) to the kernel that the kernel can either read or write. The kernel calls this method only after it checks that the entire buffer is within memory the process can both read and write. Read more

Auto Trait Implementations§

§

impl<'a, H, const DIGEST_LEN: usize> !Freeze for ShaDriver<'a, H, DIGEST_LEN>

§

impl<'a, H, const DIGEST_LEN: usize> !RefUnwindSafe for ShaDriver<'a, H, DIGEST_LEN>

§

impl<'a, H, const DIGEST_LEN: usize> !Send for ShaDriver<'a, H, DIGEST_LEN>

§

impl<'a, H, const DIGEST_LEN: usize> !Sync for ShaDriver<'a, H, DIGEST_LEN>

§

impl<'a, H, const DIGEST_LEN: usize> Unpin for ShaDriver<'a, H, DIGEST_LEN>

§

impl<'a, H, const DIGEST_LEN: usize> UnsafeUnpin for ShaDriver<'a, H, DIGEST_LEN>

§

impl<'a, H, const DIGEST_LEN: usize> !UnwindSafe for ShaDriver<'a, H, DIGEST_LEN>

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

impl<T, const DIGEST_LEN: usize> ClientDataHash<DIGEST_LEN> for T
where T: ClientData<DIGEST_LEN> + ClientHash<DIGEST_LEN>,