mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-05-31 16:21:13 +03:00
libgcrypt: make it compatible with chacha20
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
parent
8a735d5eb7
commit
238202d380
@ -88,6 +88,7 @@ ssh_string ssh_sexp_extract_mpi(const gcry_sexp_t sexp,
|
|||||||
|
|
||||||
#endif /* HAVE_LIBGCRYPT */
|
#endif /* HAVE_LIBGCRYPT */
|
||||||
|
|
||||||
|
void libgcrypt_init(void);
|
||||||
struct ssh_cipher_struct *ssh_get_ciphertab(void);
|
struct ssh_cipher_struct *ssh_get_ciphertab(void);
|
||||||
|
|
||||||
#endif /* LIBGCRYPT_H_ */
|
#endif /* LIBGCRYPT_H_ */
|
||||||
|
1
src/dh.c
1
src/dh.c
@ -190,6 +190,7 @@ int ssh_crypto_init(void) {
|
|||||||
p_group1 = NULL;
|
p_group1 = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
libgcrypt_init();
|
||||||
|
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
p_group1 = bignum_new();
|
p_group1 = bignum_new();
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
|
|
||||||
|
extern const struct ssh_cipher_struct chacha20poly1305_cipher;
|
||||||
|
|
||||||
struct ssh_mac_ctx_struct {
|
struct ssh_mac_ctx_struct {
|
||||||
enum ssh_mac_e mac_type;
|
enum ssh_mac_e mac_type;
|
||||||
gcry_md_hd_t ctx;
|
gcry_md_hd_t ctx;
|
||||||
@ -637,6 +639,9 @@ static struct ssh_cipher_struct ssh_ciphertab[] = {
|
|||||||
.encrypt = des1_1_encrypt,
|
.encrypt = des1_1_encrypt,
|
||||||
.decrypt = des1_1_decrypt
|
.decrypt = des1_1_decrypt
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "chacha20-poly1305@openssh.com"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
.blocksize = 0,
|
.blocksize = 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)
|
struct ssh_cipher_struct *ssh_get_ciphertab(void)
|
||||||
{
|
{
|
||||||
return ssh_ciphertab;
|
return ssh_ciphertab;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user