pub struct ExportedKey {
pub format_version: u32,
pub exported_at: SystemTime,
pub wrapping_algorithm: Algorithm,
pub salt: Vec<u8>,
pub argon2_params: ExportArgon2Params,
pub encrypted_key: Vec<u8>,
pub metadata: KeyMetadata,
pub comment: Option<String>,
}Expand description
A cryptographic key exported in a secure, portable format
The key material is encrypted using a password-derived key (Argon2id). The format is versioned to support future compatibility.
Fields§
§format_version: u32Format version for compatibility
exported_at: SystemTimeWhen the key was exported
wrapping_algorithm: AlgorithmAlgorithm used to wrap/encrypt the key
salt: Vec<u8>Salt used for password derivation (32 bytes)
argon2_params: ExportArgon2ParamsArgon2 parameters used for derivation
encrypted_key: Vec<u8>Encrypted key material (nonce + ciphertext + tag)
metadata: KeyMetadataKey metadata (stored in plaintext for validation)
comment: Option<String>Optional comment/description
Implementations§
Source§impl ExportedKey
impl ExportedKey
Sourcepub fn new(
key: &SecretKey,
metadata: KeyMetadata,
password: &[u8],
wrapping_algorithm: Algorithm,
) -> Result<Self>
pub fn new( key: &SecretKey, metadata: KeyMetadata, password: &[u8], wrapping_algorithm: Algorithm, ) -> Result<Self>
Create a new exported key structure
Sourcepub fn decrypt(&self, password: &[u8]) -> Result<SecretKey>
pub fn decrypt(&self, password: &[u8]) -> Result<SecretKey>
Decrypt and extract the key material
Sourcepub fn with_comment<S: Into<String>>(self, comment: S) -> Self
pub fn with_comment<S: Into<String>>(self, comment: S) -> Self
Add a comment to the exported key
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for ExportedKey
impl Clone for ExportedKey
Source§fn clone(&self) -> ExportedKey
fn clone(&self) -> ExportedKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExportedKey
impl Debug for ExportedKey
Source§impl<'de> Deserialize<'de> for ExportedKey
impl<'de> Deserialize<'de> for ExportedKey
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ExportedKey
impl RefUnwindSafe for ExportedKey
impl Send for ExportedKey
impl Sync for ExportedKey
impl Unpin for ExportedKey
impl UnwindSafe for ExportedKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more