1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-12 15:41:16 +03:00

chacha: Create common file to avoid code duplication

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2020-01-14 17:23:21 +01:00
parent e31e7b0406
commit 8670fb101b
6 changed files with 64 additions and 31 deletions

View File

@@ -33,18 +33,15 @@
#include "libssh/wrapper.h"
#include "libssh/string.h"
#include "libssh/misc.h"
#ifdef HAVE_GCRYPT_CHACHA_POLY
#include "libssh/chacha20-poly1305-common.h"
#endif
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
#ifdef HAVE_GCRYPT_CHACHA_POLY
#define CHACHA20_BLOCKSIZE 64
#define CHACHA20_KEYLEN 32
#define POLY1305_TAGLEN 16
#define POLY1305_KEYLEN 32
struct chacha20_poly1305_keysched {
bool initialized;
/* cipher handle used for encrypting the packets */
@@ -55,13 +52,6 @@ struct chacha20_poly1305_keysched {
gcry_mac_hd_t mac_hd;
};
#pragma pack(push, 1)
struct ssh_packet_header {
uint32_t length;
uint8_t payload[];
};
#pragma pack(pop)
static const uint8_t zero_block[CHACHA20_BLOCKSIZE] = {0};
#endif /* HAVE_GCRYPT_CHACHA_POLY */