-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging, shortcuts and other improvements #34
Logging, shortcuts and other improvements #34
Conversation
Thanks for all your work on this. I don't understand the change to The encryption, compression, and literal buffers were all sized so that bouncy castle wouldn't split up the encryption, compression, or literal packets with additional partial-packet headers for small files; and that for large files, it wouldn't insert a ton of partial-packet headers (just one every 64k). With this change, it looks like the literal packet will always be split up into a bunch of 512-byte partial packets for files of any size (unless the file name is really large, in which case it could be split into 1024-byte partial packets or larger). So my questions are:
|
The original code was doing return new byte[bestPacketSize(meta.getLength())]; This is obviously wrong - the literal buffer size for a 1MB file named "X" is the same size as the one for a 1KB file named "X". This is due to the fact that the I think this 100% aligned with the principle that you mentioned (and with which I agree wholeheartedly):
As far as
While it may provide extra optimization I don't think the cost in code complexity warrants it - at least not for the time being. |
Ah -- yes, that's the first thing that the The bouncy-castle code is hard to follow, but it's trying to encapsulate the logic from here: https://tools.ietf.org/html/rfc4880#section-5.9 It's straightforward until you get to the last bulleted item in section 5.9 (the literal data itself -- aka the plaintext). With the literal data, you either need to know its full exact length ahead of time, or you need to buffer the data, write a partial-packet header with the length of the partial data, write the partial data, buffer more data, write the next partial-packet header, write the partial data, and so on, until you get to the end of the data. The way this is output is described earlier in the spec, in section 4 -- with the partial-packet structure in particular described here: https://tools.ietf.org/html/rfc4880#section-4.2.2.4 The (wrapped) So that's why, even though it initially doesn't look like it's doing anything, the buffer for the literal-data generator is actually providing the internal buffering (and corresponding partial-packet sizing) for the entire original plaintext content. |
Good to know - I will revert the change and update this PR |
680eae2
to
50ce266
Compare
Done... |
FileMetadata