diff options
-rw-r--r-- | include/libssh/libgcrypt.h | 1 | ||||
-rw-r--r-- | src/dh.c | 1 | ||||
-rw-r--r-- | src/libgcrypt.c | 21 |
3 files changed, 23 insertions, 0 deletions
diff --git a/include/libssh/libgcrypt.h b/include/libssh/libgcrypt.h index ec353910..307920d3 100644 --- a/include/libssh/libgcrypt.h +++ b/include/libssh/libgcrypt.h @@ -88,6 +88,7 @@ ssh_string ssh_sexp_extract_mpi(const gcry_sexp_t sexp, #endif /* HAVE_LIBGCRYPT */ +void libgcrypt_init(void); struct ssh_cipher_struct *ssh_get_ciphertab(void); #endif /* LIBGCRYPT_H_ */ @@ -190,6 +190,7 @@ int ssh_crypto_init(void) { p_group1 = NULL; return -1; } + libgcrypt_init(); #elif defined HAVE_LIBCRYPTO p_group1 = bignum_new(); 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; |