Skip to content

Commit 778849c

Browse files
Merge pull request #21 from 10d9e/security/minor-hardening
Minor security hardening: nonce scrub
2 parents 93af916 + 15613e7 commit 778849c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<K: Kem, F: Kdf, A: SealingAead> Context<K, F, A> {
169169
if self.seq == u64::MAX {
170170
return Err(HpkeError::MessageLimitReached);
171171
}
172-
let nonce = self.compute_nonce();
172+
let nonce = Zeroizing::new(self.compute_nonce());
173173
let ct = A::seal(&self.cipher, &nonce[..A::NONCE_LEN], aad, pt)?;
174174
self.seq += 1; // checked above; cannot overflow
175175
Ok(ct)
@@ -185,7 +185,7 @@ impl<K: Kem, F: Kdf, A: SealingAead> Context<K, F, A> {
185185
if self.seq == u64::MAX {
186186
return Err(HpkeError::MessageLimitReached);
187187
}
188-
let nonce = self.compute_nonce();
188+
let nonce = Zeroizing::new(self.compute_nonce());
189189
let pt = A::open(&self.cipher, &nonce[..A::NONCE_LEN], aad, ct)?;
190190
self.seq += 1;
191191
Ok(pt)

0 commit comments

Comments
 (0)