Trait kernel::hil::public_key_crypto::keys::PubPrivKeyGenerate
source · pub trait PubPrivKeyGenerate<'a>: PubPrivKey {
// Required methods
fn set_client(&'a self, client: &'a dyn PubPrivKeyGenerateClient<'a>);
fn generate(
&'a self,
trng: &'a dyn Entropy32<'_>,
public_key_buffer: &'static mut [u8],
private_key_buffer: &'static mut [u8],
) -> Result<(), (ErrorCode, &'static mut [u8], &'static mut [u8])>;
}
Expand description
An internal representation of generating asymetric Public/Private key pairs.
This trait is useful for managing keys internally in Tock.
Required Methods§
sourcefn set_client(&'a self, client: &'a dyn PubPrivKeyGenerateClient<'a>)
fn set_client(&'a self, client: &'a dyn PubPrivKeyGenerateClient<'a>)
Set the client. This client will be called when the generate()
function is complete. If using an existing key this doesn’t need to be
used.
sourcefn generate(
&'a self,
trng: &'a dyn Entropy32<'_>,
public_key_buffer: &'static mut [u8],
private_key_buffer: &'static mut [u8],
) -> Result<(), (ErrorCode, &'static mut [u8], &'static mut [u8])>
fn generate( &'a self, trng: &'a dyn Entropy32<'_>, public_key_buffer: &'static mut [u8], private_key_buffer: &'static mut [u8], ) -> Result<(), (ErrorCode, &'static mut [u8], &'static mut [u8])>
This generates a new private/public key pair. The length will be
hard coded by the implementation, for example RSA 2048 will create a
2048 bit key.
This will call the generation_complete()
on completion. They keys
cannot be used and will return None
until the upcall has been called.
The keys generated by generate()
will depend on the implementation.
The original key buffers can be retrieve usind the pub_key()
and
priv_key()
functions.
The possible ErrorCodes are:
- BUSY
: A key is already imported or in the process of being
generated.
- OFF
: The underlying trng
is powered down.
- SIZE
: An invalid buffer size was supplied.