Skip to content
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

Splitting large payload into multiple messages #104

Open
delbonis opened this issue Feb 5, 2021 · 1 comment
Open

Splitting large payload into multiple messages #104

delbonis opened this issue Feb 5, 2021 · 1 comment

Comments

@delbonis
Copy link

delbonis commented Feb 5, 2021

I have a use-case where I need to split up a payload into a series of Noise messages, but it's not clear to me what the most efficient chunk size should be.

The TransportState type (and related types) doesn't provide a way to know the maximum size of a payload for a single message. It just says that if the final message would be larger than the 65535-byte maximum that it returns an Err.

Looking at the code I know the tag is 16 bytes (so it works out to be 65519 bytes I guess), but that's not exposed to me through the API in a convenient way.

I'm envisioning an interface where you can supply a large &[u8] and have the encryption call return the number of bytes consumed from the slice, so on subsequent calls we can move forwards the beginning of the slice and continue.

@mcginty
Copy link
Owner

mcginty commented Feb 9, 2021

Hey @delbonis! Yeah, the maximum payload size for transport messages should really be exposed in the API, good point.

True that it'd be nice to have a convenience method for large payloads. I was thinking snow might benefit from having some convenience APIs that return Vec<u8>s anyway, so a method that takes a large payload chunk and returns a Vec<Vec<u8>> could be on the table too.

In the mean time, if you haven't checked out slice::chunks(), it makes this type of thing a lot cleaner even without a convenience method :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants