However we try to do things right from the start – this library is KISS, tested against various test vectors and uses constant time implementations only.
All implementations pass all reference test vectors and are assumed to produce correct results even in corner cases. We also use API test vectors (to test input validation) and failure test vectors to test our MAC verification.
Constant Time Implementations
All implementations are designed to be invulnerable against timing side-channel attacks by performing all secret-dependent computations in constant time:
- ChaCha20 already does this by design
- Poly1305 is based on the public domain Poly1305-Donna implementation (32 bit version) with some ideas from BearSSL (note that this implementation may not be constant time on some older/low end ARM CPUs)
- The AEAD construction is also constant time by design (provided that both underlying algorithms are constant time)
crypto_api_chachapoly does not perform any attempts to erase sensitive contents from memory.
However all sensitive contents are stored in heap-allocated memory, so if you're using an erasing
memory-allocator like MAProper they will be erased nontheless.
Using an erasing memory allocator is a good idea anyway, because Rust makes it pretty hard to keep track on how the memory is managed under the hood – the memory allocator on the other hand sees everything that happens on the heap and can take care of it accordingly.
Because this code implements the
crypto_api, it depends
crypto_api-crate. Otherwise, it's dependency less.