This adds ChaCha20 and Poly1305 and the openSSH form of the AEAD.
The implementations of ChaCha20 are from DJB himself and directly taken (unchanged as much as possible) from the openSSH source code: https://github.com/openssh/openssh-portable/blob/master/chacha.c
Poly1305 is written by Andrew Moon is also directly taken (unchanged as much as possible) from the openSSH source code: https://github.com/openssh/openssh-portable/blob/master/poly1305.c
The code for the ChaCha20/Poly1305@openssh AEAD is taken from https://github.com/openssh/openssh-portable/blob/master/cipher-chachapoly.c with minimal changes.
More details on the AEAD construction: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.chacha20poly1305 https://gist.github.com/jonasschnelli/c530ea8421b8d0e80c51486325587c52
Test vectors are taken from the RFC draft: https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7
Taking existing implementations should reduce risks of screwing up at the implementation level.
OUT OF SCOPE:
- AVX,SSE acceleration (possible, see libsodium a.s.o.)
- To Bitcoin Core adjusted C++ implementations
- Combining with the existing ChaCha20 RNG (can all be done later, after verification of the correctness)
This is a subset of #14032 and a pre-requirement for BIP151.