mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-06 10:27:22 +09: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:
@@ -26,9 +26,8 @@
|
||||
#include "libssh/chacha.h"
|
||||
#include "libssh/poly1305.h"
|
||||
#include "libssh/misc.h"
|
||||
#include "libssh/chacha20-poly1305-common.h"
|
||||
|
||||
/* size of the keys k1 and k2 as defined in specs */
|
||||
#define CHACHA20_KEYLEN 32
|
||||
struct chacha20_poly1305_keysched {
|
||||
/* key used for encrypting the length field*/
|
||||
struct chacha_ctx k1;
|
||||
@@ -36,13 +35,6 @@ struct chacha20_poly1305_keysched {
|
||||
struct chacha_ctx k2;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct ssh_packet_header {
|
||||
uint32_t length;
|
||||
uint8_t payload[];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
static const uint8_t zero_block_counter[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
static const uint8_t payload_block_counter[8] = {1, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user