Key

Struct Key 

Source
pub struct Key<V: HasKey<K>, K: KeyType>(/* private fields */);
Expand description

Generic key type.

Implementations§

Source§

impl<V: SealingVersion<Public>> Key<V, Secret>

Source

pub fn random() -> Result<Self, PasetoError>

Generate a random secret key

Source

pub fn public_key(&self) -> PublicKey<V>

Derive the associated public key

Source§

impl<V: SealingVersion<Local>> Key<V, Local>

Source

pub fn random() -> Result<Self, PasetoError>

Generate a random local key

Source§

impl<V: IdVersion + HasKey<K>, K: KeyType> Key<V, K>

Source

pub fn id(&self) -> KeyId<V, K>

Generate the ID of this key

Source§

impl<V: PieWrapVersion + HasKey<K>, K: SealingKey> Key<V, K>

Source

pub fn wrap_pie( self, with: &LocalKey<V>, ) -> Result<PieWrappedKey<V, K>, PasetoError>

Source§

impl<V: PkeSealingVersion> Key<V, Local>

Source

pub fn seal(self, with: &Key<V, PkePublic>) -> Result<SealedKey<V>, PasetoError>

Encrypt the key such that it can only be decrypted by the resspective secret key.

Source§

impl<V: HasKey<K>, K: KeyType> Key<V, K>

Source

pub fn expose_key(&self) -> KeyText<V, K>

Expose the key data such that it can be serialized.

Be advised that serializing key data can be dangerous. Make sure they are saved on secure disks or sent on secure connections only.

Source§

impl<V: PwWrapVersion + HasKey<K>, K: SealingKey> Key<V, K>

Source

pub fn password_wrap( self, pass: &[u8], ) -> Result<PasswordWrappedKey<V, K>, PasetoError>

Encrypt the key using the password.

Source

pub fn password_wrap_with_params( self, pass: &[u8], params: &V::Params, ) -> Result<PasswordWrappedKey<V, K>, PasetoError>

Encrypt the key using the password, configured with the specified parameters.

Trait Implementations§

Source§

impl<V: HasKey<K>, K: KeyType> Clone for Key<V, K>
where <V as HasKey<K>>::Key: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: HasKey<K>, K: KeyType> FromStr for Key<V, K>

Source§

type Err = PasetoError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<V: HasKey<K>, K: KeyType> TryFrom<KeyText<V, K>> for Key<V, K>

Source§

type Error = PasetoError

The type returned in the event of a conversion error.
Source§

fn try_from(value: KeyText<V, K>) -> Result<Key<V, K>, PasetoError>

Performs the conversion.

Auto Trait Implementations§

§

impl<V, K> Freeze for Key<V, K>
where <V as HasKey<K>>::Key: Freeze,

§

impl<V, K> RefUnwindSafe for Key<V, K>
where <V as HasKey<K>>::Key: RefUnwindSafe,

§

impl<V, K> Send for Key<V, K>
where <V as HasKey<K>>::Key: Send,

§

impl<V, K> Sync for Key<V, K>
where <V as HasKey<K>>::Key: Sync,

§

impl<V, K> Unpin for Key<V, K>
where <V as HasKey<K>>::Key: Unpin,

§

impl<V, K> UnwindSafe for Key<V, K>
where <V as HasKey<K>>::Key: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.