Commit 8ee02eb
committed
Correct
`ChaCha[Dual]PolyReadAdapter` currently read the encrypted object
using `Readable` through the ChaCha stream (including the Poly1305
HMAC), but then consume any remaining bytes directly. This results
in any extra bytes not consumed by the desired type's `Readable`
being ignored and not included in the HMAC check.
This is likely not the desired behavior - if we get some data which
has extra slack at the end we ignore, it should still be
authenticated as the sender likely thinks that data has meaning and
included it in their HMAC check.
Luckily, I believe this is currently dead code -
`ChaCha[Dual]PolyReadAdapter` are only used for TLV stream reads
which consume the full underlying stream. However, if either is
used for non-TLV-streams in the future, this may be important.
Here we simply push any extra bytes read through the
ChaCha20Poly1305 reader, ensuring extra data is included in the
HMAC check.ChaCha[Dual]PolyReadAdapter extra stream contents logic1 parent 3129ac3 commit 8ee02eb
1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
| |||
203 | 206 | | |
204 | 207 | | |
205 | 208 | | |
206 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
| |||
0 commit comments