pub struct Memory<'a, M: RawMutex, PHY> { /* private fields */ }Implementations§
Source§impl<'a, M, PHY> Memory<'a, M, PHY>
impl<'a, M, PHY> Memory<'a, M, PHY>
pub async fn serial_number(&self) -> Result<Serial, Error>
pub async fn pubkey(&mut self, key_id: Slot) -> Result<PublicKey, Error>
Sourcepub async fn gen_pubkey(&mut self, key_id: Slot) -> Result<PublicKey, Error>
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.
pub async fn write_pubkey( &mut self, key_id: Slot, pubkey: &[u8], ) -> Result<(), Error>
pub async fn write_aes_key( &mut self, key_id: Slot, aes_key: &[u8], ) -> Result<(), Error>
pub async fn is_slot_locked(&mut self, slot: Slot) -> Result<bool, Error>
pub async fn is_locked(&mut self, zone: Zone) -> Result<bool, Error>
pub async fn lock_slot(&mut self, key_id: Slot) -> Result<(), Error>
pub async fn lock(&mut self, zone: Zone) -> Result<(), Error>
pub async fn lock_crc(&mut self, zone: Zone, crc: u16) -> Result<(), Error>
pub async fn chip_options(&mut self) -> Result<u16, Error>
pub async fn permission(&mut self, slot: Slot) -> Result<u16, Error>
pub async fn key_type(&mut self, slot: Slot) -> Result<u16, Error>
Sourcepub async unsafe fn read_config(
&mut self,
size: Size,
block: u8,
offset: u8,
) -> Result<Vec<u8, { _ }>, Error>
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.
pub async fn write_config( &mut self, size: Size, block: u8, offset: u8, data: &[u8], ) -> Result<(), Error>
pub async fn read_compressed_cert( &mut self, slot: Slot, ) -> Result<CompressedCertificate, Error>
pub async fn write_compressed_cert( &mut self, slot: Slot, cert: &CompressedCertificate, ) -> Result<(), Error>
Sourcepub async fn read_data08_block(&mut self, block: u8) -> Result<Block, Error>
pub async fn read_data08_block(&mut self, block: u8) -> Result<Block, Error>
Read a single 32-byte block from the Data08 slot.
Sourcepub async fn write_data08_block(
&mut self,
block: u8,
data: &Block,
) -> Result<(), Error>
pub async fn write_data08_block( &mut self, block: u8, data: &Block, ) -> Result<(), Error>
Write a single 32-byte block to the Data08 slot.
pub async fn read_certificate( &mut self, def: &CertificateDefinition<'_>, output: &mut [u8], ) -> Result<usize, Error>
Sourcepub async fn write_certificate(
&mut self,
def: &CertificateDefinition<'_>,
der_cert: &[u8],
) -> Result<(), Error>
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.
Sourcepub async fn erase_certificate(
&mut self,
def: &CertificateDefinition<'_>,
) -> Result<(), Error>
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>
impl<'a, M, PHY> Memory<'a, M, PHY>
pub fn serial_number_blocking(&mut self) -> Result<Serial, Error>
pub fn pubkey_blocking(&mut self, key_id: Slot) -> Result<PublicKey, Error>
Sourcepub fn gen_pubkey_blocking(&mut self, key_id: Slot) -> Result<PublicKey, Error>
pub fn gen_pubkey_blocking(&mut self, key_id: Slot) -> Result<PublicKey, Error>
Blocking counterpart to Self::gen_pubkey.
pub fn write_pubkey_blocking( &mut self, key_id: Slot, pubkey: &[u8], ) -> Result<(), Error>
pub fn write_aes_key_blocking( &mut self, key_id: Slot, aes_key: &[u8], ) -> Result<(), Error>
pub fn is_slot_locked_blocking(&mut self, slot: Slot) -> Result<bool, Error>
pub fn is_locked_blocking(&mut self, zone: Zone) -> Result<bool, Error>
pub fn lock_slot_blocking(&mut self, key_id: Slot) -> Result<(), Error>
pub fn lock_blocking(&mut self, zone: Zone) -> Result<(), Error>
pub fn lock_crc_blocking(&mut self, zone: Zone, crc: u16) -> Result<(), Error>
pub fn chip_options_blocking(&mut self) -> Result<u16, Error>
pub fn permission_blocking(&mut self, slot: Slot) -> Result<u16, Error>
pub fn key_type_blocking(&mut self, slot: Slot) -> Result<u16, Error>
pub fn write_config_blocking( &mut self, size: Size, block: u8, offset: u8, data: &[u8], ) -> Result<(), Error>
pub fn read_compressed_cert_blocking( &mut self, slot: Slot, ) -> Result<CompressedCertificate, Error>
pub fn write_compressed_cert_blocking( &mut self, slot: Slot, cert: &CompressedCertificate, ) -> Result<(), Error>
Sourcepub fn read_data08_block_blocking(&mut self, block: u8) -> Result<Block, Error>
pub fn read_data08_block_blocking(&mut self, block: u8) -> Result<Block, Error>
Read a single 32-byte block from the Data08 slot (blocking).
Sourcepub fn write_data08_block_blocking(
&mut self,
block: u8,
data: &Block,
) -> Result<(), Error>
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).
pub fn read_certificate_blocking( &mut self, def: &CertificateDefinition<'_>, output: &mut [u8], ) -> Result<usize, Error>
Sourcepub fn write_certificate_blocking(
&mut self,
def: &CertificateDefinition<'_>,
der_cert: &[u8],
) -> Result<(), Error>
pub fn write_certificate_blocking( &mut self, def: &CertificateDefinition<'_>, der_cert: &[u8], ) -> Result<(), Error>
Blocking write_certificate; same write order.