pub struct SecureTask {
pub task: TrackedTask,
pub encrypted_state: Option<String>,
pub encryption_nonce: Option<String>,
pub state_chain: Vec<TaskStateTransition>,
pub resume_token: Option<String>,
pub seen_nonces: Vec<String>,
pub max_nonces: usize,
}Expand description
A secure task with encryption and integrity protection.
Extends TrackedTask with:
- Encrypted state data (
ChaCha20-Poly1305) - Hash chain for tamper detection
- Resume token for authenticated task resumption
- Replay protection via nonces
Fields§
§task: TrackedTaskThe underlying tracked task.
encrypted_state: Option<String>Encrypted task state/result data (base64-encoded ciphertext). Only present when task has state to protect.
encryption_nonce: Option<String>Nonce used for encryption (base64-encoded, 12 bytes for ChaCha20-Poly1305).
state_chain: Vec<TaskStateTransition>Hash chain of state transitions for tamper detection.
resume_token: Option<String>HMAC-SHA256 resume token (hex-encoded) for authenticated resumption. Generated on task creation, verified on resume requests.
seen_nonces: Vec<String>Nonces seen for replay protection (hex-encoded). Prevents replaying old task resume/cancel requests.
max_nonces: usizeMaximum number of nonces to track (FIFO eviction).
Capped at MAX_NONCES_CAP (10,000) to prevent memory exhaustion.
Implementations§
Source§impl SecureTask
impl SecureTask
Sourcepub fn new(task: TrackedTask) -> Self
pub fn new(task: TrackedTask) -> Self
Create a new secure task from a tracked task.
Sourcepub fn is_nonce_seen(&self, nonce: &str) -> bool
pub fn is_nonce_seen(&self, nonce: &str) -> bool
Check if a nonce has been seen (replay detection).
Sourcepub fn record_nonce(&mut self, nonce: String)
pub fn record_nonce(&mut self, nonce: String)
Record a nonce as seen.
Enforces MAX_NONCES_CAP regardless of max_nonces field value.
SECURITY (FIND-R60-007): Truncates nonce to MAX_ENTRY_LEN bytes at
runtime to match the validate() bound and prevent memory exhaustion
from attacker-controlled nonce values.
Sourcepub fn latest_hash(&self) -> Option<&str>
pub fn latest_hash(&self) -> Option<&str>
Get the latest hash in the state chain.
Sourcepub fn current_sequence(&self) -> u64
pub fn current_sequence(&self) -> u64
Get the current sequence number.