Struct capsules_extra::atecc508a::Atecc508a

source ·
pub struct Atecc508a<'a> { /* private fields */ }

Implementations§

source§

impl<'a> Atecc508a<'a>

source

pub fn new( i2c: &'a dyn I2CDevice, buffer: &'static mut [u8], entropy_buffer: &'static mut [u8; 32], digest_buffer: &'static mut [u8; 64], wakeup_device: fn(), ) -> Self

source

pub fn read_config_zone(&self) -> Result<(), ErrorCode>

Read information from the configuration zone and print it This will work while the device is either locked or unlocked

source

pub fn setup_tock_config(&self) -> Result<(), ErrorCode>

Setup the device keys and config

This will only work on an unlocked device and will lock the device!

The slots will be configured as below

 Slot 0: 0x2083
     - ReadKey: External signatures of arbitrary messages are enabled
                Internal signatures of messages generated by GenDig or GenKey are enabled
     - IsSecret: The contents of this slot are secret
     - WriteConfig: PubInvalid

     Key Config: 0x33
        - Private: The key slot contains an ECC private key
        - PubInfo: The public version of this key can always be generated
        - KeyType: P256 NIST ECC key
        - Lockable: Slot can be individually locked using the Lock command

 Slot 1: 0x2083
     - ReadKey: External signatures of arbitrary messages are enabled
                Internal signatures of messages generated by GenDig or GenKey are enabled
     - IsSecret: The contents of this slot are secret
     - WriteConfig: PubInvalid

     Key Config: 0x33
        - Private: The key slot contains an ECC private key
        - PubInfo: The public version of this key can always be generated
        - KeyType: P256 NIST ECC key
        - Lockable: Slot can be individually locked using the Lock command

 Slot 2:
     - ReadKey: Then this slot can be the source for the CheckMac/Copy operation
     - WriteConfig: Always
source

pub fn lock_zone_config(&self) -> Result<(), ErrorCode>

Lock the zone config

source

pub fn create_key_pair(&self, slot: u16) -> Result<(), ErrorCode>

Create a key pair in the slot

source

pub fn get_public_key( &'a self, _slot: u16, ) -> Result<&'a OptionalCell<[u8; 64]>, ErrorCode>

Retrieve the public key from the slot.

This can be called only after create_key_pair() has completed

source

pub fn set_public_key( &'a self, public_key: Option<&'static mut [u8; 64]>, ) -> Option<&'static mut [u8; 64]>

Set the public key to use for the verify command, if using an external key.

This will return the previous key if one was stored. Pass in None to retrieve the key without providing a new one.

source

pub fn lock_data_and_otp(&self) -> Result<(), ErrorCode>

Lock the data and OTP

source

pub fn lock_slot0(&self) -> Result<(), ErrorCode>

Lock the slot0 config

source

pub fn device_locked(&self) -> bool

Check is the device configuration is locked

Trait Implementations§

source§

impl<'a> DigestData<'a, 32> for Atecc508a<'a>

source§

fn set_data_client(&'a self, _client: &'a dyn ClientData<32>)

Set the client instance which will handle the add_data_done and add_mut_data_done callbacks.
source§

fn add_data( &self, data: SubSlice<'static, u8>, ) -> Result<(), (ErrorCode, SubSlice<'static, u8>)>

Add data to the input of the hash function/digest. Ok indicates all of the active bytes in data will be added. There is no guarantee the data has been added to the digest until the add_data_done() callback is called. On error the cause of the error is returned along with the SubSlice unchanged (it has the same range of active bytes as the call). Valid ErrorCode values are: Read more
source§

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

Add data to the input of the hash function/digest. Ok indicates all of the active bytes in data will be added. There is no guarantee the data has been added to the digest until the add_mut_data_done() callback is called. On error the cause of the error is returned along with the SubSlice unchanged (it has the same range of active bytes as the call). Valid ErrorCode values are: Read more
source§

fn clear_data(&self)

Clear the keys and any other internal state. Any pending operations terminate and issue a callback with an ErrorCode::CANCEL. This call does not clear buffers passed through add_mut_data, those are up to the client clear.
source§

impl<'a> DigestDataHash<'a, 32> for Atecc508a<'a>

source§

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

Set the client instance which will receive hash_done() and add_data_done() callbacks.
source§

impl<'a> DigestHash<'a, 32> for Atecc508a<'a>

source§

fn set_hash_client(&'a self, _client: &'a dyn ClientHash<32>)

Set the client instance which will receive the hash_done() callback.
source§

fn run( &'a self, digest: &'static mut [u8; 32], ) -> Result<(), (ErrorCode, &'static mut [u8; 32])>

Compute a digest of all of the data added with add_data and add_data_mut, storing the computed value in digest. The computed value is returned in a hash_done callback. On error the return value will contain a return code and the slice passed in digest. Valid ErrorCode values are: Read more
source§

impl<'a> Entropy32<'a> for Atecc508a<'a>

source§

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

Set the client to receive entropy_available callbacks.
source§

fn get(&self) -> Result<(), ErrorCode>

Initiate the acquisition of entropy. Read more
source§

fn cancel(&self) -> Result<(), ErrorCode>

Cancel acquisition of entropy. Read more
source§

impl<'a> I2CClient for Atecc508a<'a>

source§

fn command_complete(&self, buffer: &'static mut [u8], status: Result<(), Error>)

Called when an I2C command completed. The error denotes whether the command completed successfully or if an error occured.
source§

impl<'a> SignatureVerify<'a, 32, 64> for Atecc508a<'a>

source§

fn verify( &self, hash: &'static mut [u8; 32], signature: &'static mut [u8; 64], ) -> Result<(), (ErrorCode, &'static mut [u8; 32], &'static mut [u8; 64])>

Check the signature against the external public key loaded via set_public_key().

Verifying that a message was signed by the device is not support yet.

source§

fn set_verify_client(&self, client: &'a dyn ClientVerify<32, 64>)

Set the client instance which will receive the verification_done() callback.

Auto Trait Implementations§

§

impl<'a> !Freeze for Atecc508a<'a>

§

impl<'a> !RefUnwindSafe for Atecc508a<'a>

§

impl<'a> !Send for Atecc508a<'a>

§

impl<'a> !Sync for Atecc508a<'a>

§

impl<'a> Unpin for Atecc508a<'a>

§

impl<'a> !UnwindSafe for Atecc508a<'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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.