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/aead_chacha20_poly1305.h b/include/mbedtls/aead_chacha20_poly1305.h
index 6c8e420..6f7ab6f 100644
--- a/include/mbedtls/aead_chacha20_poly1305.h
+++ b/include/mbedtls/aead_chacha20_poly1305.h
@@ -29,11 +29,6 @@
#include MBEDTLS_CONFIG_FILE
#endif
-#if !defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
-
-#include "chacha20.h"
-#include "poly1305.h"
-
#define MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA -0x00047 /**< Invalid input parameter(s). */
#define MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE -0x00049 /**< The requested operation is not permitted in the current state */
@@ -44,6 +39,11 @@
}
mbedtls_aead_chacha20_poly1305_mode_t;
+#if !defined(MBEDTLS_AEAD_CHACHA20_POLY1305_ALT)
+
+#include "chacha20.h"
+#include "poly1305.h"
+
typedef struct
{
mbedtls_chacha20_context chacha20_ctx; /** ChaCha20 context */
@@ -55,6 +55,10 @@
}
mbedtls_aead_chacha20_poly1305_context;
+#else /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
+#include "aead_chacha20_poly1305_alt.h"
+#endif /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
+
/**
* \brief Initialize ChaCha20-Poly1305 context
*
@@ -183,10 +187,6 @@
int mbedtls_aead_chacha20_poly1305_finish( mbedtls_aead_chacha20_poly1305_context *ctx,
unsigned char mac[16] );
-#else /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
-#include "aead_chacha20_poly1305_alt.h"
-#endif /* !MBEDTLS_AEAD_CHACHA20_POLY1305_ALT */
-
/**
* \brief Encrypt or decrypt data, and produce a MAC with ChaCha20-Poly1305.
*