aboutsummaryrefslogtreecommitdiff
path: root/src/libgcrypt.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2018-02-28 10:24:55 -0600
committerAndreas Schneider <asn@cryptomilk.org>2018-06-28 09:06:30 +0200
commit238202d38032762c2fec641a90712eaf0ff7bfae (patch)
treec4e5ee8d287eb7a5bb43c66a1a79e8643791e115 /src/libgcrypt.c
parent8a735d5eb7e7033d7bcda6de6df622a84d264bf1 (diff)
downloadlibssh-238202d38032762c2fec641a90712eaf0ff7bfae.tar.gz
libssh-238202d38032762c2fec641a90712eaf0ff7bfae.tar.xz
libssh-238202d38032762c2fec641a90712eaf0ff7bfae.zip
libgcrypt: make it compatible with chacha20
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/libgcrypt.c')
-rw-r--r--src/libgcrypt.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libgcrypt.c b/src/libgcrypt.c
index d9dd5be6..b695b6bb 100644
--- a/src/libgcrypt.c
+++ b/src/libgcrypt.c
@@ -35,6 +35,8 @@
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
+extern const struct ssh_cipher_struct chacha20poly1305_cipher;
+
struct ssh_mac_ctx_struct {
enum ssh_mac_e mac_type;
gcry_md_hd_t ctx;
@@ -638,6 +640,9 @@ static struct ssh_cipher_struct ssh_ciphertab[] = {
.decrypt = des1_1_decrypt
},
{
+ .name = "chacha20-poly1305@openssh.com"
+ },
+ {
.name = NULL,
.blocksize = 0,
.keylen = 0,
@@ -650,6 +655,22 @@ static struct ssh_cipher_struct ssh_ciphertab[] = {
}
};
+void libgcrypt_init(void)
+{
+ size_t i;
+
+ for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
+ int cmp;
+ cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
+ if (cmp == 0) {
+ memcpy(&ssh_ciphertab[i],
+ &chacha20poly1305_cipher,
+ sizeof(struct ssh_cipher_struct));
+ break;
+ }
+ }
+}
+
struct ssh_cipher_struct *ssh_get_ciphertab(void)
{
return ssh_ciphertab;