diff options
Diffstat (limited to 'openpgp/src/serialize/cert.rs')
-rw-r--r-- | openpgp/src/serialize/cert.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs index fe25c19a..7fcb7f6d 100644 --- a/openpgp/src/serialize/cert.rs +++ b/openpgp/src/serialize/cert.rs @@ -579,8 +579,14 @@ impl<'a> MarshalInto for TSK<'a> { if self.emit_stubs && (tag == Tag::PublicKey || tag == Tag::PublicSubkey) { // Emit a GnuPG-style secret key stub. The stub - // extends the public key by 8 bytes. - let l = key.parts_as_public().net_len() + 8; + // extends the public key by 8 bytes (plus 4 secret + // length octets for v6). + let l = key.parts_as_public().net_len() + + match key.version() { + 4 => 8, + 6 => 12, + _ => 0, // Serialization will fail anyway. + }; return 1 // CTB + BodyLength::Full(l as u32).serialized_len() + l; |