diff options
author | Jakub Jelen <jjelen@redhat.com> | 2020-01-14 17:23:21 +0100 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2020-01-23 09:48:11 +0100 |
commit | 8670fb101bcb2600ae1dac4b9a8f2c3f04aba078 (patch) | |
tree | c284b85e69d67937af60eadb86c975ae0e65dd47 /include/libssh | |
parent | e31e7b0406f4c2b85831bf7ad90d57d660646108 (diff) | |
download | libssh-8670fb101bcb2600ae1dac4b9a8f2c3f04aba078.tar.gz libssh-8670fb101bcb2600ae1dac4b9a8f2c3f04aba078.tar.xz libssh-8670fb101bcb2600ae1dac4b9a8f2c3f04aba078.zip |
chacha: Create common file to avoid code duplication
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/chacha.h | 1 | ||||
-rw-r--r-- | include/libssh/chacha20-poly1305-common.h | 54 | ||||
-rw-r--r-- | include/libssh/poly1305.h | 4 |
3 files changed, 55 insertions, 4 deletions
diff --git a/include/libssh/chacha.h b/include/libssh/chacha.h index bac78c67..867f532d 100644 --- a/include/libssh/chacha.h +++ b/include/libssh/chacha.h @@ -17,7 +17,6 @@ struct chacha_ctx { #define CHACHA_NONCELEN 8 #define CHACHA_CTRLEN 8 #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) -#define CHACHA_BLOCKLEN 64 void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits) #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE diff --git a/include/libssh/chacha20-poly1305-common.h b/include/libssh/chacha20-poly1305-common.h new file mode 100644 index 00000000..b2f0231b --- /dev/null +++ b/include/libssh/chacha20-poly1305-common.h @@ -0,0 +1,54 @@ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2020 Red Hat, Inc. + * + * Author: Jakub Jelen <jjelen@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * chacha20-poly1305.h file + * This file includes definitions needed for Chacha20-poly1305 AEAD cipher + * using different crypto backends. + */ + +#ifndef CHACHA20_POLY1305_H +#define CHACHA20_POLY1305_H + +#define CHACHA20_BLOCKSIZE 64 +#define CHACHA20_KEYLEN 32 + +#define POLY1305_TAGLEN 16 +/* size of the keys k1 and k2 as defined in specs */ +#define POLY1305_KEYLEN 32 + +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif +struct ssh_packet_header { + uint32_t length; + uint8_t payload[]; +} +#if defined(__GNUC__) +__attribute__ ((packed)) +#endif +#ifdef _MSC_VER +#pragma pack(pop) +#endif +; + +#endif /* CHACHA20_POLY1305_H */ diff --git a/include/libssh/poly1305.h b/include/libssh/poly1305.h index 9174bd17..513f1b99 100644 --- a/include/libssh/poly1305.h +++ b/include/libssh/poly1305.h @@ -5,9 +5,7 @@ #ifndef POLY1305_H #define POLY1305_H - -#define POLY1305_KEYLEN 32 -#define POLY1305_TAGLEN 16 +#include "libssh/chacha20-poly1305-common.h" void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen, const uint8_t key[POLY1305_KEYLEN]) |