Commit 3129ac3
committed
Update
`ChaChaPolyWriteAdapter` is used to wrap `Writeable` objects in an
AEAD before serializing them. This is great, except that we
sometimes call `<T as ChaChaPolyWriteAdapter>::encode` which first
calls `Writeable::serialized_length` to calculate the length to
pre-allocate in a `Vec` before doing the actual write.
Because `ChaChaPolyWriteAdapter` did not override
`Writeable::serialized_length`, this led to doing the full
cryptographic AEAD encryption and MAC twice, once to calculate the
length and once to actually write the data.
Instead, here, we override
`<ChaChaPolyWriteAdapter as Writeable::serialized_length` to simply
calculate the length we need.ChaChaPolyWriteAdapter to bypass crypto when calc'ing len1 parent 5f14409 commit 3129ac3
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| |||
0 commit comments