Adapt the _ALT style to our new standard
- in .h files: only put the context declaration inside the #ifdef _ALT
(this was changed in 2.9.0, ie after the original PR)
- in .c file: only leave selftest out of _ALT: even though some function are
trivial to build from other parts, alt implementors might want to go another
way about them (for efficiency or other reasons)
diff --git a/include/mbedtls/chacha20.h b/include/mbedtls/chacha20.h
index ccce122..a2856a7 100644
--- a/include/mbedtls/chacha20.h
+++ b/include/mbedtls/chacha20.h
@@ -31,13 +31,13 @@
#include MBEDTLS_CONFIG_FILE
#endif
-#if !defined(MBEDTLS_CHACHA20_ALT)
-
#include <stdint.h>
#include <stddef.h>
#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x003B /**< Invalid input parameter(s). */
+#if !defined(MBEDTLS_CHACHA20_ALT)
+
typedef struct
{
uint32_t initial_state[16]; /*! Holds the initial state (before round operations) */
@@ -47,6 +47,10 @@
}
mbedtls_chacha20_context;
+#else /* MBEDTLS_CHACHA20_ALT */
+#include "chacha20_alt.h"
+#endif /* MBEDTLS_CHACHA20_ALT */
+
/**
* \brief Initialize ChaCha20 context
*
@@ -149,10 +153,6 @@
const unsigned char *input,
unsigned char *output );
-#else /* MBEDTLS_CHACHA20_ALT */
-#include "chacha20_alt.h"
-#endif /* MBEDTLS_CHACHA20_ALT */
-
/**
* \brief Encrypt or decrypt a message using ChaCha20.
*