summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-10-11 23:30:44 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-10-11 23:30:44 +0200
commit6ceb62046e591436b6dd78286096ee901a15dacc (patch)
treeb47ac722203cb270afce57735aee4867e677fdb8 /openpgp/src/crypto
parentf8fc8961e2da62a97bd8328f752cf39717958759 (diff)
openpgp: Always write the final AEAD tag.
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r--openpgp/src/crypto/aead.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs
index 03c02da2..dcc5843a 100644
--- a/openpgp/src/crypto/aead.rs
+++ b/openpgp/src/crypto/aead.rs
@@ -790,15 +790,16 @@ impl<W: io::Write> Encryptor<W> {
unsafe { self.scratch.set_len(self.digest_size) }
aead.digest(&mut self.scratch[..self.digest_size]);
inner.write_all(&self.scratch[..self.digest_size])?;
-
- // Write final digest.
- let mut aead = self.make_aead()?;
- self.hash_associated_data(&mut aead, true);
- let mut nada = [0; 0];
- aead.encrypt(&mut nada, b"");
- aead.digest(&mut self.scratch[..self.digest_size]);
- inner.write_all(&self.scratch[..self.digest_size])?;
}
+
+ // Write final digest.
+ let mut aead = self.make_aead()?;
+ self.hash_associated_data(&mut aead, true);
+ let mut nada = [0; 0];
+ aead.encrypt(&mut nada, b"");
+ aead.digest(&mut self.scratch[..self.digest_size]);
+ inner.write_all(&self.scratch[..self.digest_size])?;
+
Ok(inner)
} else {
Err(io::Error::new(io::ErrorKind::BrokenPipe,