Skip to main content

Memory

Struct Memory 

Source
pub struct Memory<'a, M: RawMutex, PHY> { /* private fields */ }

Implementations§

Source§

impl<'a, M, PHY> Memory<'a, M, PHY>
where PHY: I2c, M: RawMutex,

Source

pub async fn serial_number(&self) -> Result<Serial, Error>

Source

pub async fn pubkey(&mut self, key_id: Slot) -> Result<PublicKey, Error>

Source

pub async fn gen_pubkey(&mut self, key_id: Slot) -> Result<PublicKey, Error>

Derive the public key of a private-key slot via GenKey.

A private-key slot is secret and cannot be read back with Self::pubkey (the device rejects the Read with an execution error); its public key is recomputed from the stored private key instead.

Source

pub async fn write_pubkey( &mut self, key_id: Slot, pubkey: &[u8], ) -> Result<(), Error>

Source

pub async fn write_aes_key( &mut self, key_id: Slot, aes_key: &[u8], ) -> Result<(), Error>

Source

pub async fn is_slot_locked(&mut self, slot: Slot) -> Result<bool, Error>

Source

pub async fn is_locked(&mut self, zone: Zone) -> Result<bool, Error>

Source

pub async fn lock_slot(&mut self, key_id: Slot) -> Result<(), Error>

Source

pub async fn lock(&mut self, zone: Zone) -> Result<(), Error>

Source

pub async fn lock_crc(&mut self, zone: Zone, crc: u16) -> Result<(), Error>

Source

pub async fn chip_options(&mut self) -> Result<u16, Error>

Source

pub async fn permission(&mut self, slot: Slot) -> Result<u16, Error>

Source

pub async fn key_type(&mut self, slot: Slot) -> Result<u16, Error>

Source

pub async unsafe fn read_config( &mut self, size: Size, block: u8, offset: u8, ) -> Result<Vec<u8, { _ }>, Error>

§Safety

Caller must ensure the config zone parameters (size, block, offset) are valid for the target device and do not cause out-of-bounds reads.

Source

pub async fn write_config( &mut self, size: Size, block: u8, offset: u8, data: &[u8], ) -> Result<(), Error>

Source

pub async fn read_compressed_cert( &mut self, slot: Slot, ) -> Result<CompressedCertificate, Error>

Source

pub async fn write_compressed_cert( &mut self, slot: Slot, cert: &CompressedCertificate, ) -> Result<(), Error>

Source

pub async fn read_data08_block(&mut self, block: u8) -> Result<Block, Error>

Read a single 32-byte block from the Data08 slot.

Source

pub async fn write_data08_block( &mut self, block: u8, data: &Block, ) -> Result<(), Error>

Write a single 32-byte block to the Data08 slot.

Source

pub async fn read_certificate( &mut self, def: &CertificateDefinition<'_>, output: &mut [u8], ) -> Result<usize, Error>

Source

pub async fn write_certificate( &mut self, def: &CertificateDefinition<'_>, der_cert: &[u8], ) -> Result<(), Error>

Compress a DER certificate and write it to the ATECC.

If the serial source is Stored, writes the serial number to the addressed Data08 block first, then the compressed cert to the cert slot.

That order matters: the two writes are separate ATECC transactions, and the cert slot is what decides whether a certificate is present at all. read_certificate fails on a zeroed cert slot (its encoded date has no valid month or day) but silently splices in whatever the serial block holds. Writing the cert slot last makes it the commit point, so an interrupted write leaves the slot unreadable and the caller retries. The reverse order leaves a certificate that reconstructs cleanly against a stale serial, which no read can detect.

Source

pub async fn erase_certificate( &mut self, def: &CertificateDefinition<'_>, ) -> Result<(), Error>

Erase a certificate from the ATECC (zero the cert slot and stored serial).

Zeroes the cert slot first — the mirror of write_certificate’s order, and correct for the same reason: it invalidates the commit point up front, so a half-done erase still reads as “no certificate” rather than as a live one.

Source§

impl<'a, M, PHY> Memory<'a, M, PHY>
where PHY: I2c, M: RawMutex,

Source

pub fn serial_number_blocking(&mut self) -> Result<Serial, Error>

Source

pub fn pubkey_blocking(&mut self, key_id: Slot) -> Result<PublicKey, Error>

Source

pub fn gen_pubkey_blocking(&mut self, key_id: Slot) -> Result<PublicKey, Error>

Blocking counterpart to Self::gen_pubkey.

Source

pub fn write_pubkey_blocking( &mut self, key_id: Slot, pubkey: &[u8], ) -> Result<(), Error>

Source

pub fn write_aes_key_blocking( &mut self, key_id: Slot, aes_key: &[u8], ) -> Result<(), Error>

Source

pub fn is_slot_locked_blocking(&mut self, slot: Slot) -> Result<bool, Error>

Source

pub fn is_locked_blocking(&mut self, zone: Zone) -> Result<bool, Error>

Source

pub fn lock_slot_blocking(&mut self, key_id: Slot) -> Result<(), Error>

Source

pub fn lock_blocking(&mut self, zone: Zone) -> Result<(), Error>

Source

pub fn lock_crc_blocking(&mut self, zone: Zone, crc: u16) -> Result<(), Error>

Source

pub fn chip_options_blocking(&mut self) -> Result<u16, Error>

Source

pub fn permission_blocking(&mut self, slot: Slot) -> Result<u16, Error>

Source

pub fn key_type_blocking(&mut self, slot: Slot) -> Result<u16, Error>

Source

pub fn write_config_blocking( &mut self, size: Size, block: u8, offset: u8, data: &[u8], ) -> Result<(), Error>

Source

pub fn read_compressed_cert_blocking( &mut self, slot: Slot, ) -> Result<CompressedCertificate, Error>

Source

pub fn write_compressed_cert_blocking( &mut self, slot: Slot, cert: &CompressedCertificate, ) -> Result<(), Error>

Source

pub fn read_data08_block_blocking(&mut self, block: u8) -> Result<Block, Error>

Read a single 32-byte block from the Data08 slot (blocking).

Source

pub fn write_data08_block_blocking( &mut self, block: u8, data: &Block, ) -> Result<(), Error>

Write a single 32-byte block to the Data08 slot (blocking).

Source

pub fn read_certificate_blocking( &mut self, def: &CertificateDefinition<'_>, output: &mut [u8], ) -> Result<usize, Error>

Source

pub fn write_certificate_blocking( &mut self, def: &CertificateDefinition<'_>, der_cert: &[u8], ) -> Result<(), Error>

Blocking write_certificate; same write order.

Source

pub fn erase_certificate_blocking( &mut self, def: &CertificateDefinition<'_>, ) -> Result<(), Error>

Auto Trait Implementations§

§

impl<'a, M, PHY> !RefUnwindSafe for Memory<'a, M, PHY>

§

impl<'a, M, PHY> !UnwindSafe for Memory<'a, M, PHY>

§

impl<'a, M, PHY> Forget for Memory<'a, M, PHY>

§

impl<'a, M, PHY> Freeze for Memory<'a, M, PHY>
where &'a AtCaClient<M, PHY>: Freeze,

§

impl<'a, M, PHY> Move for Memory<'a, M, PHY>

§

impl<'a, M, PHY> Send for Memory<'a, M, PHY>
where &'a AtCaClient<M, PHY>: Send,

§

impl<'a, M, PHY> Sync for Memory<'a, M, PHY>
where &'a AtCaClient<M, PHY>: Sync,

§

impl<'a, M, PHY> Unpin for Memory<'a, M, PHY>
where &'a AtCaClient<M, PHY>: Unpin,

§

impl<'a, M, PHY> UnsafeUnpin for Memory<'a, M, PHY>
where &'a AtCaClient<M, PHY>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.