pub struct TransientKeyContextBuilder { /* private fields */ }
Expand description

Build a new TransientKeyContext.

§Default values

  • TCTI: Device TCTI
  • Hierarchy: Owner hierarchy
  • Root key size: 2048 bits
  • Root key authentication size: 32 bytes
  • Hierarchy authentication value: Empty array of bytes
  • Session encryption cipher: 256 bit AES in CFB mode
  • Session hash algorithm: SHA256

Implementations§

source§

impl TransientKeyContextBuilder

source

pub fn new() -> Self

Create a new builder.

source

pub fn with_tcti(self, tcti_name_conf: TctiNameConf) -> Self

Define the TCTI name configuration to be used by the client.

source

pub fn with_hierarchy_auth(self, hierarchy: Hierarchy, auth: Vec<u8>) -> Self

Set the auth values for any hierarchies that will be used

source

pub fn with_root_hierarchy(self, hierarchy: Hierarchy) -> Self

Define which hierarchy will be used for the keys being managed.

source

pub fn with_root_key_size(self, root_key_size: u16) -> Self

Choose length in bits of primary key that will serve as parent to all user keys.

source

pub fn with_root_key_auth_size(self, root_key_auth_size: usize) -> Self

Choose authentication value length (in bytes) for primary key.

source

pub fn with_default_context_cipher( self, default_context_cipher: SymmetricDefinitionObject ) -> Self

Define the cipher to be used within this context as a default.

Currently this default is used for:

  • securing command parameters using session-based encryption
  • encrypting all user keys using the primary key
source

pub fn with_session_hash_alg(self, session_hash_alg: HashingAlgorithm) -> Self

Define the cipher to be used by sessions for hashing commands.

source

pub fn build(self) -> Result<TransientKeyContext>

Bootstrap the TransientKeyContext.

The root key is created as a primary key in the provided hierarchy and thus authentication is needed for said hierarchy. The authentication value for the key is generated locally in the machine, with a configurable length, and never exposed outside the context.

§Warning

It is the responsibility of the client to ensure that the context can be initialized safely, threading-wise by choosing the correct TCTI. See the Warning notice of the Context structure for more information.

§Constraints
  • root_key_size must be 1024, 2048, 3072 or 4096
  • root_key_auth_size must be at most 32
§Errors
  • errors are returned if any method calls return an error: Context::start_auth_session Context::create_primary, Context::flush_context, Context::set_handle_auth or if an internal error occurs when getting random numbers from the local machine
  • if the root key authentication size is given greater than 32 or if the root key size is not 1024, 2048, 3072 or 4096, a InvalidParam wrapper error is returned

Trait Implementations§

source§

impl Debug for TransientKeyContextBuilder

source§

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

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

impl Default for TransientKeyContextBuilder

source§

fn default() -> Self

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

Auto Trait Implementations§

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> Free for T

source§

unsafe fn free(ptr_ref: NonNull<T>)

Drops the content pointed by this pointer and frees it. 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.