I was advised to use crypto_secretbox_xsalsa20poly1305
due to its simplicity and because it's safe against timing attacks. I'm reading the secretbox tutorial, and there's a link to Validation and Verification regarding message length. In that, in the last paragraph, it says the following:
Tests are currently limited to 4096-byte messages. This is one of several reasons that callers should (1) split all data into packets sent through the network; (2) put a small global limit on packet length; and (3) separately encrypt and authenticate each packet.
Now I don't understand who's the "caller" here. Is it me in my application or the NaCl library? From requirement (1) it seems it's me. From requirement (3) it seems it's NaCl, because I don't have control on separating encryption and implementation, because both happen in one call of crypto_secretbox_xsalsa20poly1305
.
So I guess my question is: If I have a message whose length is longer than 4096 bytes, should I manually split it when using crypto_secretbox_xsalsa20poly1305
, encrypt and authenticate each, then combine them together in a certain way as my final cipher?
_easy
variants of these functions? I'm having really big trouble finding any conclusive documentation. – The Quantum Physicist Apr 23 '19 at 18:14_easy
variants is that you don't have to provide space for zero-padding in the buffers you pass in. That is: with the_easy
variants, you pass a pointer to a message and pointer to a ciphertext, period, not a pointer to a handful of zero bytes preceding a message, etc. – Squeamish Ossifrage Apr 23 '19 at 18:31