mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
chachapoly: Use a function instead of an extern variable
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -161,4 +161,6 @@ struct ssh_cipher_struct {
|
||||
void (*cleanup)(struct ssh_cipher_struct *cipher);
|
||||
};
|
||||
|
||||
const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void);
|
||||
|
||||
#endif /* _CRYPTO_H_ */
|
||||
|
||||
@@ -205,3 +205,8 @@ const struct ssh_cipher_struct chacha20poly1305_cipher = {
|
||||
.aead_decrypt = chacha20_poly1305_aead_decrypt,
|
||||
.cleanup = chacha20_cleanup
|
||||
};
|
||||
|
||||
const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void)
|
||||
{
|
||||
return &chacha20poly1305_cipher;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
|
||||
#include "libssh/crypto.h"
|
||||
|
||||
extern const struct ssh_cipher_struct chacha20poly1305_cipher;
|
||||
struct ssh_mac_ctx_struct {
|
||||
enum ssh_mac_e mac_type;
|
||||
union {
|
||||
@@ -764,7 +763,7 @@ void libcrypto_init(void)
|
||||
cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
|
||||
if (cmp == 0) {
|
||||
memcpy(&ssh_ciphertab[i],
|
||||
&chacha20poly1305_cipher,
|
||||
ssh_get_chacha20poly1305_cipher(),
|
||||
sizeof(struct ssh_cipher_struct));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
#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;
|
||||
@@ -544,7 +542,7 @@ void libgcrypt_init(void)
|
||||
cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
|
||||
if (cmp == 0) {
|
||||
memcpy(&ssh_ciphertab[i],
|
||||
&chacha20poly1305_cipher,
|
||||
ssh_get_chacha20poly1305_cipher(),
|
||||
sizeof(struct ssh_cipher_struct));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#ifdef HAVE_LIBMBEDCRYPTO
|
||||
#include <mbedtls/md.h>
|
||||
|
||||
extern const struct ssh_cipher_struct chacha20poly1305_cipher;
|
||||
|
||||
struct ssh_mac_ctx_struct {
|
||||
enum ssh_mac_e mac_type;
|
||||
mbedtls_md_context_t ctx;
|
||||
@@ -964,7 +962,7 @@ void ssh_mbedtls_init(void)
|
||||
cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
|
||||
if (cmp == 0) {
|
||||
memcpy(&ssh_ciphertab[i],
|
||||
&chacha20poly1305_cipher,
|
||||
ssh_get_chacha20poly1305_cipher(),
|
||||
sizeof(struct ssh_cipher_struct));
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user