diff --git a/chacha20poly1305/chacha20poly1305.c b/chacha20poly1305/chacha20poly1305.c index 70662a03d..d75ddd162 100644 --- a/chacha20poly1305/chacha20poly1305.c +++ b/chacha20poly1305/chacha20poly1305.c @@ -3,6 +3,7 @@ // than performance. #include "chacha20poly1305.h" +#include "ecrypt-portable.h" void hchacha20(ECRYPT_ctx *x,u8 *c); diff --git a/chacha20poly1305/chacha_merged.c b/chacha20poly1305/chacha_merged.c index f2845846c..95779f3d6 100644 --- a/chacha20poly1305/chacha_merged.c +++ b/chacha20poly1305/chacha_merged.c @@ -5,6 +5,7 @@ Public domain. */ #include "ecrypt-sync.h" +#include "ecrypt-portable.h" #define ROTATE(v,c) (ROTL32(v,c)) #define XOR(v,w) ((v) ^ (w)) diff --git a/chacha20poly1305/ecrypt-portable.h b/chacha20poly1305/ecrypt-portable.h index 438a464a7..da1a79f2a 100644 --- a/chacha20poly1305/ecrypt-portable.h +++ b/chacha20poly1305/ecrypt-portable.h @@ -21,45 +21,10 @@ #define ECRYPT_PORTABLE #include "ecrypt-config.h" +#include "ecrypt-types.h" /* ------------------------------------------------------------------------- */ -/* - * The following types are defined (if available): - * - * u8: unsigned integer type, at least 8 bits - * u16: unsigned integer type, at least 16 bits - * u32: unsigned integer type, at least 32 bits - * u64: unsigned integer type, at least 64 bits - * - * s8, s16, s32, s64 -> signed counterparts of u8, u16, u32, u64 - * - * The selection of minimum-width integer types is taken care of by - * 'ecrypt-config.h'. Note: to enable 64-bit types on 32-bit - * compilers, it might be necessary to switch from ISO C90 mode to ISO - * C99 mode (e.g., gcc -std=c99). - */ - -#ifdef I8T -typedef signed I8T s8; -typedef unsigned I8T u8; -#endif - -#ifdef I16T -typedef signed I16T s16; -typedef unsigned I16T u16; -#endif - -#ifdef I32T -typedef signed I32T s32; -typedef unsigned I32T u32; -#endif - -#ifdef I64T -typedef signed I64T s64; -typedef unsigned I64T u64; -#endif - /* * The following macros are used to obtain exact-width results. */ diff --git a/chacha20poly1305/ecrypt-sync.h b/chacha20poly1305/ecrypt-sync.h index 5f363d4c8..7b8467361 100644 --- a/chacha20poly1305/ecrypt-sync.h +++ b/chacha20poly1305/ecrypt-sync.h @@ -12,7 +12,7 @@ #ifndef ECRYPT_SYNC #define ECRYPT_SYNC -#include "ecrypt-portable.h" +#include "ecrypt-types.h" /* ------------------------------------------------------------------------- */ diff --git a/chacha20poly1305/ecrypt-types.h b/chacha20poly1305/ecrypt-types.h new file mode 100644 index 000000000..e608e220a --- /dev/null +++ b/chacha20poly1305/ecrypt-types.h @@ -0,0 +1,53 @@ +/* ecrypt-types.h */ + +/* + * *** Please do not edit this file. *** + * + * The default macros can be overridden for specific architectures by + * editing 'ecrypt-machine.h'. + */ + +#ifndef ECRYPT_TYPES +#define ECRYPT_TYPES + +#include "ecrypt-config.h" + +/* ------------------------------------------------------------------------- */ + +/* + * The following types are defined (if available): + * + * u8: unsigned integer type, at least 8 bits + * u16: unsigned integer type, at least 16 bits + * u32: unsigned integer type, at least 32 bits + * u64: unsigned integer type, at least 64 bits + * + * s8, s16, s32, s64 -> signed counterparts of u8, u16, u32, u64 + * + * The selection of minimum-width integer types is taken care of by + * 'ecrypt-config.h'. Note: to enable 64-bit types on 32-bit + * compilers, it might be necessary to switch from ISO C90 mode to ISO + * C99 mode (e.g., gcc -std=c99). + */ + +#ifdef I8T +typedef signed I8T s8; +typedef unsigned I8T u8; +#endif + +#ifdef I16T +typedef signed I16T s16; +typedef unsigned I16T u16; +#endif + +#ifdef I32T +typedef signed I32T s32; +typedef unsigned I32T u32; +#endif + +#ifdef I64T +typedef signed I64T s64; +typedef unsigned I64T u64; +#endif + +#endif diff --git a/chacha20poly1305/rfc7539.c b/chacha20poly1305/rfc7539.c index 8aa3b8f0a..7958e6437 100644 --- a/chacha20poly1305/rfc7539.c +++ b/chacha20poly1305/rfc7539.c @@ -3,6 +3,7 @@ #include #include "rfc7539.h" +#include "ecrypt-portable.h" // Initialize the ChaCha20 + Poly1305 context for encryption or decryption // using a 32 byte key and 12 byte nonce as in the RFC 7539 style.