Here is a patch to support chacha20-poly1...@openssh.com in libssh. First commit changes some cipher structures needed to prepare the field. Then I tried to the least possible changes in sending and receiving packet functions to support authenticated encryption mode. Some files from openssh have been added for chacha20 and poly1305 algorithms. And finally, added chachapoly structures and methods. This can be disabled with WITH_CHACHAPOLY compilation condition.
Signed-off-by: Meng Tan <m...@wallix.com> Meng Tan (4): chachapoly: refactor cipher structs, add no hmac possibility chachapoly: handle packet encryption with authenticated encryption mode chachapoly: add external files chachapoly: add chachapoly structures with compilation conditions (chacha20-poly1...@openssh.com support) CMakeLists.txt | 2 +- DefineOptions.cmake | 1 + config.h.cmake | 3 + include/libssh/buffer.h | 47 +++++++++ include/libssh/chacha.h | 35 +++++++ include/libssh/chachapoly.h | 41 ++++++++ include/libssh/crypto.h | 25 ++++- include/libssh/poly1305.h | 22 ++++ include/libssh/wrapper.h | 5 + src/CMakeLists.txt | 9 ++ src/external/chacha.c | 219 +++++++++++++++++++++++++++++++++++++++ src/external/chachapoly.c | 134 ++++++++++++++++++++++++ src/external/poly1305.c | 158 ++++++++++++++++++++++++++++ src/kex.c | 14 ++- src/libcrypto.c | 147 ++++++++++++++++++++++---- src/libgcrypt.c | 145 ++++++++++++++++++++++---- src/packet.c | 81 ++++++++++----- src/packet_crypt.c | 69 ++++++++++-- src/pki_container_openssh.c | 6 +- src/wrapper.c | 16 ++- tests/unittests/torture_crypto.c | 8 +- 21 files changed, 1089 insertions(+), 98 deletions(-) create mode 100644 include/libssh/chacha.h create mode 100644 include/libssh/chachapoly.h create mode 100644 include/libssh/poly1305.h create mode 100644 src/external/chacha.c create mode 100644 src/external/chachapoly.c create mode 100644 src/external/poly1305.c -- 2.1.4