diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2015-02-01 22:42:07 +0100 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2015-06-05 18:51:38 +0200 |
commit | fefdee10d00261b7ab8b0bde5065cf93d494821f (patch) | |
tree | ec3f0dcfd1e06263db40ff6233987926c6ec6356 | |
parent | 4c936387c6047fb73f971345587db4976b19f7f3 (diff) | |
download | libssh-fefdee10d00261b7ab8b0bde5065cf93d494821f.tar.gz libssh-fefdee10d00261b7ab8b0bde5065cf93d494821f.tar.xz libssh-fefdee10d00261b7ab8b0bde5065cf93d494821f.zip |
libgcrypt: make it compatible with chacha20
-rw-r--r-- | include/libssh/libgcrypt.h | 1 | ||||
-rw-r--r-- | src/dh.c | 1 | ||||
-rw-r--r-- | src/libgcrypt.c | 15 |
3 files changed, 17 insertions, 0 deletions
diff --git a/include/libssh/libgcrypt.h b/include/libssh/libgcrypt.h index 8e52a681..45a7344a 100644 --- a/include/libssh/libgcrypt.h +++ b/include/libssh/libgcrypt.h @@ -73,6 +73,7 @@ char *my_gcry_bn2dec(bignum bn); #endif /* HAVE_LIBGCRYPT */ +void libgcrypt_init(void); struct ssh_cipher_struct *ssh_get_ciphertab(void); #endif /* LIBGCRYPT_H_ */ @@ -179,6 +179,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 24d4a3c5..20495772 100644 --- a/src/libgcrypt.c +++ b/src/libgcrypt.c @@ -31,6 +31,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; @@ -581,6 +583,9 @@ static struct ssh_cipher_struct ssh_ciphertab[] = { .decrypt = des1_1_decrypt }, { + .name = "chacha20-poly1305@openssh.com" + }, + { .name = NULL, .blocksize = 0, .keylen = 0, @@ -593,6 +598,16 @@ static struct ssh_cipher_struct ssh_ciphertab[] = { } }; +void libgcrypt_init(void){ + int i; + for (i=0; ssh_ciphertab[i].name != NULL; ++i){ + if(strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com") == 0){ + memcpy(&ssh_ciphertab[i], &chacha20poly1305_cipher, sizeof(struct ssh_cipher_struct)); + break; + } + } +} + struct ssh_cipher_struct *ssh_get_ciphertab(void) { return ssh_ciphertab; |