Skip to main content

SoftKeyStore

Struct SoftKeyStore 

Source
pub struct SoftKeyStore<const N: usize> { /* private fields */ }
Available on crate feature rustcrypto only.
Expand description

Private keys held in memory, zeroised when removed or dropped.

What a node without a secure element gets. It is not a weaker protocol — the keys are as strong — but the material is readable by anything that can read the process’s memory, which is the difference a secure element buys.

Implementations§

Source§

impl<const N: usize> SoftKeyStore<N>

Source

pub fn new() -> Self

An empty store.

Source

pub fn len(&self) -> usize

How many keys are held.

Source

pub fn is_empty(&self) -> bool

Whether the store holds no keys.

Source

pub fn purpose(&self, handle: KeyHandle) -> Result<KeyPurpose>

What a handle’s key is for.

Trait Implementations§

Source§

impl<const N: usize> Debug for SoftKeyStore<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for SoftKeyStore<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> KeyStore for SoftKeyStore<N>

Source§

fn generate( &mut self, purpose: KeyPurpose, random: &[u8; 32], ) -> Result<(KeyHandle, PublicKey)>

Generates a key pair from 32 octets of randomness, returning its handle and public key. Read more
Source§

fn import( &mut self, purpose: KeyPurpose, secret: &[u8; 32], ) -> Result<KeyHandle>

Imports an existing private key. A store backed by hardware may refuse.
Source§

fn public_key(&self, handle: KeyHandle) -> Result<PublicKey>

The public key for a handle.
Source§

fn sign(&self, handle: KeyHandle, message: &[u8]) -> Result<Signature>

Signs message — ECDSA over SHA-256 (§3.5.3.1).
Source§

fn ecdh( &self, handle: KeyHandle, peer: &PublicKey, ) -> Result<Secret<GROUP_SIZE_BYTES>>

Computes the ECDH shared secret with peer (§3.5.4). Read more
Source§

fn remove(&mut self, handle: KeyHandle) -> Result<()>

Destroys a key. Removing a fabric destroys its operational key, and that has to actually happen rather than merely be forgotten about.

Auto Trait Implementations§

§

impl<const N: usize> Forget for SoftKeyStore<N>

§

impl<const N: usize> Freeze for SoftKeyStore<N>
where [Option<Slot>; N]: Freeze,

§

impl<const N: usize> Move for SoftKeyStore<N>

§

impl<const N: usize> RefUnwindSafe for SoftKeyStore<N>
where [Option<Slot>; N]: RefUnwindSafe,

§

impl<const N: usize> Send for SoftKeyStore<N>
where [Option<Slot>; N]: Send,

§

impl<const N: usize> Sync for SoftKeyStore<N>
where [Option<Slot>; N]: Sync,

§

impl<const N: usize> Unpin for SoftKeyStore<N>
where [Option<Slot>; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for SoftKeyStore<N>
where [Option<Slot>; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for SoftKeyStore<N>
where [Option<Slot>; N]: UnwindSafe,

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.