Page MenuHome GnuPG

PLAINTEXT_LENGTH is sometimes incorrect
Closed, ResolvedPublic

Description

The symmetric passphrase for decrypting the payload of

is: 6460-5183-7821-0632-0177-4451-8821-9031-7887.

When i decrypt it symmetrically though, gpg reports a different size than what is actually emitted:

$ gpg --batch --status-fd=2 --pinentry-mode=loopback --decrypt --passphrase 6460-5183-7821-0632-0177-4451-8821-9031-7887 < package/tests/resources/autocrypt-setup-message-2.eml | wc
gpg: unknown armor header: Passphrase-Format: numeric9x4
gpg: unknown armor header: Passphrase-Begin: 64
gpg: AES256 encrypted session key
[GNUPG:] NEED_PASSPHRASE_SYM 9 3 8
gpg: encrypted with 1 passphrase
[GNUPG:] BEGIN_DECRYPTION
[GNUPG:] DECRYPTION_COMPLIANCE_MODE 23
[GNUPG:] DECRYPTION_INFO 2 9
[GNUPG:] PLAINTEXT 75 1529933984 msg.txt
[GNUPG:] PLAINTEXT_LENGTH 6793
[GNUPG:] DECRYPTION_OKAY
[GNUPG:] GOODMDC
[GNUPG:] END_DECRYPTION
    108     115    6685
$ 

note that 6685 != 6793.

(this file is from the enigmail test suite -- i dont know how it was generated).

this test was run on GnuPG 2.2.17-3.

Details

Version
2.2.17-3

Event Timeline

"PLAINTEXT 75 ..." means UTF-8 encoding (u) which is not not binary (b) or MIME ('m') and thus on Unix the line endings are converted from CR,LF to LF. On Windows you should see a different length. See plaintext.c#handle_plaintext()

DETAILS says:

*** PLAINTEXT_LENGTH <length>
    This indicates the length of the plaintext that is about to be
    written.  Note that if the plaintext packet has partial length
    encoding it is not possible to know the length ahead of time.  In
    that case, this status tag does not appear.

If this doesn't mean that the plaintext length will be the actual emitted length, then at the very least this comment in DETAILS needs to explain why. We can't expect developers trying to make sense of this to go searching through the GnuPG bugtracker for an explanation.

werner claimed this task.