1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00
Werner Koch ebb0fcf6e0
gpg: Fix corner cases in AEAD encryption.
* g10/cipher-aead.c (write_final_chunk): Do not bump up the chunk
index if the previous chunk was empty.
* g10/decrypt-data.c (aead_underflow): Likewise.  Also handle a other
corner cases.  Add more debug output.
--

GnuPG-bug-id: 3774

This fixes the reported case when the encrypted data is a multiple of
the chunk size.  Then the chunk index for the final chunk was wrongly
incremented by 2.  The actual fix makes use of the fact that the
current dfx->CHUNKLEN is 0 in this case.  There is also some other
reorganizing to help with debugging.  The thing seems to work now but
the code is not very clean - should be reworked.  Creating test files
can be done with this script:

--8<---------------cut here---------------start------------->8---
csize=6
for len in 0 55 56 57; do
   awk </dev/null -v i=$len 'BEGIN{while(i){i--;printf"~"}}' \
     | gpg --no-options -v --rfc4880bis --batch --passphrase "abc" \
           --s2k-count 1025 --s2k-digest-algo sha256 -z0 \
           --force-aead --aead-algo eax --cipher aes -a \
           --chunk-size $csize -c >symenc-aead-eax-c$csize-$len.asc
done
--8<---------------cut here---------------end--------------->8---

A LEN of 56 triggered the bug which can be seen by looking at the
"authdata:" line in the --debug=crypt,filter output.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-02-27 13:53:52 +01:00
..
2017-03-07 20:25:54 +09:00
2017-03-07 20:25:54 +09:00
2018-01-21 16:30:53 +01:00
2017-11-22 20:54:47 +01:00
2017-03-07 20:25:54 +09:00
2015-02-04 09:15:34 +01:00
2017-09-27 09:42:13 +02:00
2015-02-04 09:15:34 +01:00
2017-03-07 20:25:54 +09:00
2017-09-13 09:18:15 +02:00
2017-03-07 20:25:54 +09:00
2018-01-22 16:50:21 +01:00
2018-02-22 16:19:56 +01:00
2017-03-07 20:25:54 +09:00
2017-03-07 20:25:54 +09:00
2018-01-23 19:08:16 +01:00
2018-01-23 19:08:16 +01:00
2017-03-07 20:25:54 +09:00
2018-01-22 16:50:21 +01:00
2017-03-07 20:25:54 +09:00
2017-03-07 20:25:54 +09:00
2017-03-07 20:25:54 +09:00
2017-01-23 19:16:55 +01:00
2017-02-21 13:11:46 -05:00
2017-03-07 20:32:09 +09:00
2017-03-07 20:25:54 +09:00
2017-04-28 10:06:33 +09:00
2018-01-23 12:07:57 +01:00
2016-03-08 14:08:49 +01:00
2017-04-28 10:06:33 +09:00
2017-03-31 20:07:20 +02:00
2017-03-07 20:25:54 +09:00
2016-12-06 12:16:56 +01:00
2017-12-04 19:26:49 +09:00
2017-04-28 10:06:33 +09:00