Trait kernel::hil::public_key_crypto::keys::PubKeyMut

source ·
pub trait PubKeyMut {
    // Required methods
    fn import_public_key(
        &self,
        public_key: &'static mut [u8],
    ) -> Result<(), (ErrorCode, &'static mut [u8])>;
    fn pub_key(&self) -> Result<&'static mut [u8], ErrorCode>;
    fn len(&self) -> usize;
}
Expand description

An internal representation of a asymetric Public key.

This trait is useful for managing keys internally in Tock.

PubKey is designed for fixed length keys. That is an implementation should support only a single key length, for example RSA 2048. Note that we don’t use const generics here though. That is because even within a single key length implementation, there can be different length inputs, for examples compressed or uncompressed keys.

Required Methods§

source

fn import_public_key( &self, public_key: &'static mut [u8], ) -> Result<(), (ErrorCode, &'static mut [u8])>

Import an existing public key.

The reference to the public_key is stored internally and can be retrieved with the pub_key() function. The public_key can be either a mutable static or an immutable static, depending on where the key is stored (flash or memory).

The possible ErrorCodes are: - BUSY: A key is already imported or in the process of being generated. - INVAL: An invalid key was supplied. - SIZE: An invalid key size was supplied.

source

fn pub_key(&self) -> Result<&'static mut [u8], ErrorCode>

Return the public key supplied by import_public_key() or generate().

On success the return value is Ok(()) with the buffer that was originally passed in to hold the key.

On failure the possible ErrorCodes are: - NODEVICE: The key does not exist

source

fn len(&self) -> usize

Report the length of the public key in bytes, as returned from pub_key(). A value of 0 indicates that the key does not exist.

Implementors§