pub struct FieldKey(/* private fields */);Expand description
A key for encrypting a specific field, derived from a tenant key.
Field keys are derived deterministically from the parent key and field name, enabling key hierarchy without storing additional key material.
§Security
- Each field gets a unique derived key
- Compromise of one field key doesn’t expose other fields
- Keys are derived using HKDF-like construction with SHA-256
Implementations§
Source§impl FieldKey
impl FieldKey
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> FieldKey
pub fn from_bytes(bytes: &[u8; 32]) -> FieldKey
Restores a field key from its byte representation.
Use this to restore a field key from secure storage.
Sourcepub fn derive(parent_key: &EncryptionKey, field_name: &str) -> FieldKey
pub fn derive(parent_key: &EncryptionKey, field_name: &str) -> FieldKey
Derives a field key from a parent key and field name.
The derivation is deterministic: the same parent key and field name always produce the same field key.
§Arguments
parent_key- The tenant’s encryption keyfield_name- The name of the field (e.g.,patient_ssn)
§Security
- Uses HKDF-like construction with SHA-256
- Field names should be consistent across the application
- Consider prefixing field names with schema version for rotation
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FieldKey
impl RefUnwindSafe for FieldKey
impl Send for FieldKey
impl Sync for FieldKey
impl Unpin for FieldKey
impl UnwindSafe for FieldKey
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