1 /* 2 * Copyright (c) 2001-2022, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef MBEDTLS_CHACHA20_ALT_H 8 #define MBEDTLS_CHACHA20_ALT_H 9 10 #include "mbedtls/build_info.h" 11 12 #include <stddef.h> 13 #include <stdint.h> 14 15 16 #ifdef __cplusplus 17 extern "C" 18 { 19 #endif 20 21 /************************ Defines ******************************/ 22 23 /*! The size of the ChaCha user-context in words. */ 24 #define MBEDTLS_CHACHA_USER_CTX_SIZE_IN_WORDS 17 25 /*! The size of the ChaCha block in Bytes. */ 26 #define MBEDTLS_CHACHA_BLOCK_SIZE_BYTES 64 27 /*! The size of the ChaCha block in Bytes. As defined in rfc7539 */ 28 #define MBEDTLS_CHACHA_NONCE_SIZE_BYTES 12 29 /*! The size of the ChaCha key in Bytes. */ 30 #define MBEDTLS_CHACHA_KEY_SIZE_BYTES 32 31 /*! Internal type to identify 12 byte nonce */ 32 #define MBEDTLS_CHACHA_NONCE_SIZE_12BYTE_TYPE 1 33 34 /*! The definition of the 12-Byte array of the nonce buffer. */ 35 typedef uint8_t mbedtls_chacha_nonce[MBEDTLS_CHACHA_NONCE_SIZE_BYTES]; 36 37 /*! The definition of the key buffer of the ChaCha engine. */ 38 typedef uint8_t mbedtls_chacha_key[MBEDTLS_CHACHA_KEY_SIZE_BYTES]; 39 40 #if defined(MBEDTLS_CHACHA20_ALT) 41 42 typedef struct 43 { 44 uint32_t buf[MBEDTLS_CHACHA_USER_CTX_SIZE_IN_WORDS]; 45 } 46 mbedtls_chacha20_context; 47 48 #endif 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 59 #endif /* chacha20_alt.h */ 60