Add some error codes and merge others
- need HW failure codes too
- re-use relevant poly codes for chachapoly to save on limited space
Values were chosen to leave 3 free slots at the end of the NET odd range.
diff --git a/include/mbedtls/chacha20.h b/include/mbedtls/chacha20.h
index 7a8cd53..c33aef3 100644
--- a/include/mbedtls/chacha20.h
+++ b/include/mbedtls/chacha20.h
@@ -42,8 +42,9 @@
#include <stdint.h>
#include <stddef.h>
-#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0053 /**< Invalid input parameter(s). */
-#define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0055 /**< Feature not available. For example, s part of the API is not implemented. */
+#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051 /**< Invalid input parameter(s). */
+#define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0053 /**< Feature not available. For example, s part of the API is not implemented. */
+#define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED -0x0055 /**< Chacha20 hardware accelerator failed. */
#ifdef __cplusplus
extern "C" {
diff --git a/include/mbedtls/chachapoly.h b/include/mbedtls/chachapoly.h
index a55a3ee..ae786e0 100644
--- a/include/mbedtls/chachapoly.h
+++ b/include/mbedtls/chachapoly.h
@@ -39,11 +39,11 @@
#include MBEDTLS_CONFIG_FILE
#endif
-#define MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA -0x0054 /**< Invalid input parameter(s). */
-#define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0056 /**< The requested operation is not permitted in the current state. */
-#define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0058 /**< Authenticated decryption failed: data was not authentic. */
-#define MBEDTLS_ERR_CHACHAPOLY_FEATURE_UNAVAILABLE -0x005A /**< Feature not available. For example, s part of the API is not implemented. */
+/* for shared error codes */
+#include "poly1305.h"
+#define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054 /**< The requested operation is not permitted in the current state. */
+#define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056 /**< Authenticated decryption failed: data was not authentic. */
#ifdef __cplusplus
extern "C" {
@@ -59,7 +59,6 @@
#if !defined(MBEDTLS_CHACHAPOLY_ALT)
#include "chacha20.h"
-#include "poly1305.h"
typedef struct
{
@@ -117,7 +116,7 @@
* \param key The 256-bit (32 bytes) key.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if \p ctx or \p key are NULL.
*/
int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx,
@@ -141,7 +140,7 @@
* #MBEDTLS_CHACHAPOLY_DECRYPT.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if \p ctx or \p mac are NULL.
*/
int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx,
@@ -177,7 +176,7 @@
* This pointer can be NULL if aad_len == 0.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if \p ctx or \p aad are NULL.
* \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE
* if the operations has not been started or has been
@@ -210,7 +209,7 @@
* This pointer can be NULL if len == 0.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if \p ctx, \p input, or \p output are NULL.
* \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE
* if the operation has not been started or has been
@@ -229,7 +228,7 @@
* \param mac The buffer to where the 128-bit (16 bytes) MAC is written.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if \p ctx or \p mac are NULL.
* \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE
* if the operation has not been started or has been
@@ -265,7 +264,7 @@
* \param tag The buffer to where the computed 128-bit (16 bytes) MAC is written.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if one or more of the required parameters are NULL.
*/
int mbedtls_chachapoly_crypt_and_tag( mbedtls_chachapoly_context *ctx,
@@ -298,7 +297,7 @@
* This pointer can be NULL if ilen == 0.
*
* \return \c 0 on success.
- * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_INPUT_DATA
+ * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
* if one or more of the required parameters are NULL.
* \return #MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED
* if the data was not authentic.
diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h
index 21fa9fc..12f045a 100644
--- a/include/mbedtls/error.h
+++ b/include/mbedtls/error.h
@@ -62,7 +62,7 @@
* DES 2 0x0032-0x0032 0x0033-0x0033
* CTR_DBRG 4 0x0034-0x003A
* ENTROPY 3 0x003C-0x0040 0x003D-0x003F
- * NET 11 0x0042-0x0052 0x0043-0x0045
+ * NET 13 0x0042-0x0052 0x0043-0x0049
* ASN1 7 0x0060-0x006C
* CMAC 1 0x007A-0x007A
* PBKDF2 1 0x007C-0x007C
@@ -76,9 +76,9 @@
* SHA1 1 0x0035-0x0035
* SHA256 1 0x0037-0x0037
* SHA512 1 0x0039-0x0039
- * CHACHA20 2 0x0053-0x0055
- * POLY1305 2 0x0057-0x0059
- * CHACHAPOLY 4 0x0054-0x005A
+ * CHACHA20 3 0x0051-0x0055
+ * POLY1305 3 0x0057-0x005B
+ * CHACHAPOLY 2 0x0054-0x0056
*
* High-level module nr (3 bits - 0x0...-0x7...)
* Name ID Nr of Errors
diff --git a/include/mbedtls/poly1305.h b/include/mbedtls/poly1305.h
index 021a3a0..babbc15 100644
--- a/include/mbedtls/poly1305.h
+++ b/include/mbedtls/poly1305.h
@@ -44,6 +44,7 @@
#define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057 /**< Invalid input parameter(s). */
#define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059 /**< Feature not available. For example, s part of the API is not implemented. */
+#define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B /**< Poly1305 hardware accelerator failed. */
#ifdef __cplusplus
extern "C" {