pub struct HydeContext { /* private fields */ }Expand description
Main entry point for Hyde operations.
Implementations§
Source§impl HydeContext
impl HydeContext
Sourcepub fn with_backend(backend: Box<dyn TeeBackend>) -> Result<Self>
pub fn with_backend(backend: Box<dyn TeeBackend>) -> Result<Self>
Create a HydeContext with a specific backend.
Defaults to SecurityLevel::Paranoid (no caching).
Sourcepub fn with_backend_and_security(
backend: Box<dyn TeeBackend>,
security_level: SecurityLevel,
) -> Result<Self>
pub fn with_backend_and_security( backend: Box<dyn TeeBackend>, security_level: SecurityLevel, ) -> Result<Self>
Create a HydeContext with a specific backend and security level.
Sourcepub fn protect(&mut self, data: &[u8]) -> Result<ProtectedData>
pub fn protect(&mut self, data: &[u8]) -> Result<ProtectedData>
Protect data by generating a Data Key, encrypting, and wrapping.
The returned ProtectedData can be serialized and stored anywhere.
Sourcepub fn unprotect(&mut self, protected: &ProtectedData) -> Result<Vec<u8>>
pub fn unprotect(&mut self, protected: &ProtectedData) -> Result<Vec<u8>>
Decrypt protected data using the context’s configured security level.
Sourcepub fn unprotect_with(
&mut self,
protected: &ProtectedData,
level: SecurityLevel,
) -> Result<Vec<u8>>
pub fn unprotect_with( &mut self, protected: &ProtectedData, level: SecurityLevel, ) -> Result<Vec<u8>>
Decrypt protected data with a specific security level override.
Useful for one-off escalation to Paranoid on sensitive operations.
Sourcepub fn flush_cache(&mut self)
pub fn flush_cache(&mut self)
Drop all cached keys and plaintext from memory (triggers zeroize).
Sourcepub fn set_security_level(&mut self, level: SecurityLevel)
pub fn set_security_level(&mut self, level: SecurityLevel)
Change the security level. Flushes the cache.
Sourcepub fn security_level(&self) -> SecurityLevel
pub fn security_level(&self) -> SecurityLevel
Returns the current security level.
Sourcepub fn backup(
&self,
protected: &ProtectedData,
strategy: &dyn RecoveryStrategy,
secret: Option<&[u8]>,
) -> Result<BackupBundle>
pub fn backup( &self, protected: &ProtectedData, strategy: &dyn RecoveryStrategy, secret: Option<&[u8]>, ) -> Result<BackupBundle>
Backup protected data using a chosen recovery strategy.
Sourcepub fn restore(
&self,
bundle: &BackupBundle,
ciphertext: &[u8],
strategy: &dyn RecoveryStrategy,
secret: &[u8],
) -> Result<ProtectedData>
pub fn restore( &self, bundle: &BackupBundle, ciphertext: &[u8], strategy: &dyn RecoveryStrategy, secret: &[u8], ) -> Result<ProtectedData>
Restore protected data from a backup using the matching recovery strategy.