summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-05-03 14:37:10 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-05-03 15:48:48 +0200
commit7402da31a54fd1b64bbb2bcdb076bba1c1d1faa2 (patch)
tree9340e2d4ea491a9e51c728838c252aed59ab13e3 /openpgp
parent44b3e0fd800cb2ec2a3791083cf07b22f86751d8 (diff)
openpgp: Account for every octet in the size calculation.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/serialize/mod.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/openpgp/src/serialize/mod.rs b/openpgp/src/serialize/mod.rs
index ad787f2e..767d2713 100644
--- a/openpgp/src/serialize/mod.rs
+++ b/openpgp/src/serialize/mod.rs
@@ -1318,12 +1318,15 @@ impl Key4 {
(tag == Tag::SecretKey || tag == Tag::SecretSubkey)
&& self.secret().is_some();
- 1 + 4 + 1
+ 1 // Version.
+ + 4 // Creation time.
+ + 1 // PK algo.
+ self.mpis().serialized_len()
+ if have_secret_key {
1 + match self.secret().as_ref().unwrap() {
&SecretKey::Unencrypted { ref mpis } =>
- mpis.serialized_len() + 2,
+ mpis.serialized_len()
+ + 2, // Two octet checksum.
&SecretKey::Encrypted {
ref s2k,
ref ciphertext,