Let's say I have x bytes of data that needs to be encrypted with Stream Ciphers such as AES256-CTR, ChaCha20, Salsa20, XChaCha20, XSalsa20.

I would like to ask, since these ciphers typically requires MAC to ensure their integrity. Will current Poly1305 that comes along with ChaCha20,XChaCha20,Salsa20,XSalsa20 & GCM that bundles with AES256-CTR in libsodium library considered to be able to store them for a long time?

If Poly1305 MAC and GCM was not suit to be used for long time storage, what kind of hashing algorithm along with methods or MAC algorithm I can use?

  • $\begingroup$ The libsodium documentation says Poly1305 is recommended for online protocols/many small messages because of its output size. Furthermore, hash-based MACs like HMAC, KMAC, BLAKE2b/BLAKE3, etc are more robust in that they're collision resistant, which makes them committing. This protects against attacks where the adversary can control inputs to the AEAD like the key, nonce, and associated data. Almost all AEADs used in practice are not committing and vulnerable to this type of attack. $\endgroup$ Commented Dec 14, 2023 at 17:20

1 Answer 1


The MAC algorithm would not be the first thing I would worry about. There are many more issues such as key management, destruction of the original files etc. to worry about. Are these algorithms secure? Yes, we think so currently. Will they remain secure? I'd wager that it is likely. As with many algorithms we cannot prove that they are secure.

That said, nobody has ever been fired for using 256 bit keys and HMAC-SHA-256 with the extended output size of 256 bits. Unless they forgot to include the IV/nonce and other relevant data in the calculation of course.

Software implementations of AES / GMAC can be vulnerable against side channel attacks, see e.g. here but that's not of much consequence for data at rest.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.