[noise] Negotiating transport message size (was: Re: NoiseSocket revision 1)

Rhys Weatherley rhys.weatherley at gmail.com
Fri Aug 4 14:37:39 PDT 2017


On Sat, Aug 5, 2017 at 4:10 AM, Igor Solovyov <igor.solovyov at gmail.com>
wrote:

>
>
> On Fri, Aug 4, 2017 at 7:53 PM, Trevor Perrin <trevp at trevp.net> wrote:
>
>> We've tried to avoid negotiation to keep runtime behavior simple.  So
>> even if we support larger transport messages, it's an open question
>> whether we should negotiate this versus just having endpoints
>> configured for it.
>>
>
> 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.
> After one tried to connect to other some clear error code would be nice to
> have.
> I didn't study current Noise spec scrupulously, so may be it's already
> there.
>

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.  An
implementation that is 32-bit aware will switch sizes dynamically.  No
possibility of misconfiguration.

Then it's just a matter of negotiating the maximum size > 65535 to indicate
"I am aware of how to decode 32-bit lengths".

Cheers,

Rhys.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://moderncrypto.org/mail-archive/noise/attachments/20170805/d49cc7fd/attachment.html>


More information about the Noise mailing list