libgcrypt: make it compatible with chacha20
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
8a735d5eb7
Коммит
238202d380
@ -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_ */
|
||||
|
1
src/dh.c
1
src/dh.c
@ -190,6 +190,7 @@ int ssh_crypto_init(void) {
|
||||
p_group1 = NULL;
|
||||
return -1;
|
||||
}
|
||||
libgcrypt_init();
|
||||
|
||||
#elif defined HAVE_LIBCRYPTO
|
||||
p_group1 = bignum_new();
|
||||
|
@ -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;
|
||||
@ -637,6 +639,9 @@ static struct ssh_cipher_struct ssh_ciphertab[] = {
|
||||
.encrypt = des1_1_encrypt,
|
||||
.decrypt = des1_1_decrypt
|
||||
},
|
||||
{
|
||||
.name = "chacha20-poly1305@openssh.com"
|
||||
},
|
||||
{
|
||||
.name = NULL,
|
||||
.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)
|
||||
{
|
||||
return ssh_ciphertab;
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user