aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2015-02-01 22:42:07 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2015-06-05 18:51:38 +0200
commitfefdee10d00261b7ab8b0bde5065cf93d494821f (patch)
treeec3f0dcfd1e06263db40ff6233987926c6ec6356
parent4c936387c6047fb73f971345587db4976b19f7f3 (diff)
downloadlibssh-fefdee10d00261b7ab8b0bde5065cf93d494821f.tar.gz
libssh-fefdee10d00261b7ab8b0bde5065cf93d494821f.tar.xz
libssh-fefdee10d00261b7ab8b0bde5065cf93d494821f.zip
libgcrypt: make it compatible with chacha20
-rw-r--r--include/libssh/libgcrypt.h1
-rw-r--r--src/dh.c1
-rw-r--r--src/libgcrypt.c15
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_ */
diff --git a/src/dh.c b/src/dh.c
index f3ebcff3..1b25197b 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -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;