EncKey

Struct EncKey 

Source
#[repr(C)]
pub struct EncKey { pub pkalg: [u8; 2], pub kdfalg: [u8; 2], pub kdfrounds: u32, pub salt: [u8; 16], pub checksum: [u8; 8], pub keynum: [u8; 8], pub seckey: Zeroizing<[u8; 64]>, }
Expand description

Encrypted secret key structure.

Stores the encrypted secret key along with KDF parameters and checksums.

Fields§

§pkalg: [u8; 2]

Public key algorithm (must be “Ed”).

§kdfalg: [u8; 2]

KDF algorithm (must be “BK”).

§kdfrounds: u32

Number of KDF rounds.

§salt: [u8; 16]

Salt for KDF.

§checksum: [u8; 8]

Checksum of the decrypted key.

§keynum: [u8; 8]

Key ID (KeyNum).

§seckey: Zeroizing<[u8; 64]>

Encrypted secret key data.

Implementations§

Source§

impl EncKey

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Parse EncKey from raw bytes.

§Errors

Returns Error::InvalidKeyLength if byte length is incorrect. Returns Error::UnsupportedPkAlgo if algorithm is not Ed. Returns Error::UnsupportedKdfAlgo if algorithm is not BK.

Source

pub fn to_bytes(&self) -> Zeroizing<Vec<u8>>

Serialize EncKey to raw bytes.

Trait Implementations§

Source§

impl Debug for EncKey

Source§

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

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

impl Drop for EncKey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Zeroize for EncKey

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl Freeze for EncKey

§

impl RefUnwindSafe for EncKey

§

impl Send for EncKey

§

impl Sync for EncKey

§

impl Unpin for EncKey

§

impl UnwindSafe for EncKey

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 = 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.