mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-13 19:18:56 +00:00
chacha20poly1305: header polution reduction
- including chacah20poly1305.h polutes general namespace with macros defined in ecrypt-portable.h and ecrypt-machine.h which are needed only for .c files and should not leak to general namespace - I've extracted types definition from ecrypt-portable.h to ecrypt-types.h as types are needed for interface definition in ecypt-sync.h which is needed in chacha20poly1305.h
This commit is contained in:
parent
b9edb3b976
commit
bf1e1b13a6
@ -3,6 +3,7 @@
|
||||
// than performance.
|
||||
|
||||
#include "chacha20poly1305.h"
|
||||
#include "ecrypt-portable.h"
|
||||
|
||||
void hchacha20(ECRYPT_ctx *x,u8 *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))
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef ECRYPT_SYNC
|
||||
#define ECRYPT_SYNC
|
||||
|
||||
#include "ecrypt-portable.h"
|
||||
#include "ecrypt-types.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
53
chacha20poly1305/ecrypt-types.h
Normal file
53
chacha20poly1305/ecrypt-types.h
Normal file
@ -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
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#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.
|
||||
|
Loading…
Reference in New Issue
Block a user