pub enum SecurityLevel {
Paranoid,
Standard {
ttl: Duration,
},
Performance {
ttl: Duration,
},
}Expand description
Controls the trade-off between security and performance when accessing TEE-protected data.
| Level | Cached | Attack surface | Speed |
|---|---|---|---|
Paranoid | Nothing | Minimal | Slow (TPM every call) |
Standard | Data Key only | 32-byte key in memory | Fast (AES-GCM only) |
Performance | Data Key + plaintext | Full plaintext in memory | Fastest |
Variants§
Paranoid
Every unprotect() call hits the TEE (TPM unseal + AES decrypt).
No plaintext or data key is ever cached in memory.
Slowest, but smallest attack surface.
Standard
The unwrapped data key is cached in mlock’d, zeroize-on-drop memory
for a configurable TTL. The plaintext itself is never cached.
Each unprotect() still performs AES-GCM decryption, but avoids
the expensive TPM unseal round-trip for repeated accesses.
Performance
Both the unwrapped data key AND the decrypted plaintext are cached in mlock’d, zeroize-on-drop memory for the TTL period. Fastest for repeated reads of the same data, but the plaintext lives in process memory until the TTL expires or the cache is flushed.
Implementations§
Source§impl SecurityLevel
impl SecurityLevel
Sourcepub fn performance() -> Self
pub fn performance() -> Self
Performance level with a default TTL of 10 seconds.
Sourcepub fn ttl(&self) -> Option<Duration>
pub fn ttl(&self) -> Option<Duration>
Returns the TTL if caching is enabled, or None for Paranoid.
Sourcepub fn caches_plaintext(&self) -> bool
pub fn caches_plaintext(&self) -> bool
Returns true if plaintext caching is enabled (Performance level).
Sourcepub fn caches_data_key(&self) -> bool
pub fn caches_data_key(&self) -> bool
Returns true if data key caching is enabled (Standard or Performance).
Trait Implementations§
Source§impl Clone for SecurityLevel
impl Clone for SecurityLevel
Source§fn clone(&self) -> SecurityLevel
fn clone(&self) -> SecurityLevel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more