diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-05-03 14:37:10 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-05-03 15:48:48 +0200 |
commit | 7402da31a54fd1b64bbb2bcdb076bba1c1d1faa2 (patch) | |
tree | 9340e2d4ea491a9e51c728838c252aed59ab13e3 /openpgp/src | |
parent | 44b3e0fd800cb2ec2a3791083cf07b22f86751d8 (diff) |
openpgp: Account for every octet in the size calculation.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/serialize/mod.rs | 7 |
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, |