[noise] Negotiating transport message size (was: Re: NoiseSocket revision 1)
trevp at trevp.net
Sat Aug 5 00:34:08 PDT 2017
On Fri, Aug 4, 2017 at 9:37 PM, Rhys Weatherley
<rhys.weatherley at gmail.com> wrote:
> On Sat, Aug 5, 2017 at 4:10 AM, Igor Solovyov <igor.solovyov at gmail.com>
>> Agree. In such case some kind of clear error signaling is desirable.
>> One endpoint could be configured to use 16-bit length, another one to use
>> 32-bit by mistake.
> How about this for an encoding:
> 1. If the message is <= 65535 bytes in size, use a two-byte length.
> 2. If the message is > 65535 bytes in size, then send a two-byte length with
> the value zero followed by the actual four-byte length. Length field is 6
> bytes in size in total. For large messages, the extra overhead probably
> doesn't matter.
> Since a zero-length packet is normally invalid, a 16-bit only implementation
> will abort the connection if it sees the zero.
If we decide Noise and NoiseSocket should allow large messages via
endpoint configuration (instead of explicit negotiation), then I agree
that unambiguous length encoding seems helpful for detecting
Your proposal would work, but we could consider other things too (e.g.
protobuf varints, or a type field).
If we decide on explicit negotiation in NoiseSocket, then I think we
don't need this, and it's simpler to just use uint16 or uint32 length
More information about the Noise