2021-01-12 08:27:12 +01:00
|
|
|
/*
|
|
|
|
* Copyright The Mbed TLS Contributors
|
2023-11-02 20:47:20 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2021-01-12 08:27:12 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-03-05 06:09:37 +01:00
|
|
|
* \file mps_error.h
|
2021-01-12 08:27:12 +01:00
|
|
|
*
|
|
|
|
* \brief Error codes used by MPS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MBEDTLS_MPS_ERROR_H
|
|
|
|
#define MBEDTLS_MPS_ERROR_H
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: The error code allocation needs to be revisited:
|
|
|
|
*
|
|
|
|
* - Should we make (some of) the MPS Reader error codes public?
|
2021-01-28 10:02:18 +01:00
|
|
|
* If so, we need to adjust MBEDTLS_MPS_READER_MAKE_ERROR() to hit
|
2021-01-12 08:27:12 +01:00
|
|
|
* a gap in the Mbed TLS public error space.
|
|
|
|
* If not, we have to make sure we don't forward those errors
|
|
|
|
* at the level of the public API -- no risk at the moment as
|
|
|
|
* long as MPS is an experimental component not accessible from
|
|
|
|
* public API.
|
|
|
|
*/
|
|
|
|
|
2021-01-12 08:25:41 +01:00
|
|
|
/**
|
|
|
|
* \name SECTION: MPS general error codes
|
|
|
|
*
|
|
|
|
* \{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MBEDTLS_MPS_ERR_BASE
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_MPS_ERR_BASE (0)
|
2021-01-12 08:25:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MBEDTLS_MPS_MAKE_ERROR(code) \
|
2023-01-11 14:50:10 +01:00
|
|
|
(-(MBEDTLS_MPS_ERR_BASE | (code)))
|
2021-01-12 08:25:41 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_OPERATION_UNEXPECTED MBEDTLS_MPS_MAKE_ERROR(0x1)
|
|
|
|
#define MBEDTLS_ERR_MPS_INTERNAL_ERROR MBEDTLS_MPS_MAKE_ERROR(0x2)
|
2021-01-12 08:25:41 +01:00
|
|
|
|
|
|
|
/* \} name SECTION: MPS general error codes */
|
|
|
|
|
2021-01-12 08:27:12 +01:00
|
|
|
/**
|
|
|
|
* \name SECTION: MPS Reader error codes
|
|
|
|
*
|
|
|
|
* \{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MBEDTLS_MPS_READER_ERR_BASE
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_MPS_READER_ERR_BASE (1 << 8)
|
2021-01-12 08:27:12 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MBEDTLS_MPS_READER_MAKE_ERROR(code) \
|
2023-01-11 14:50:10 +01:00
|
|
|
(-(MBEDTLS_MPS_READER_ERR_BASE | (code)))
|
2021-01-12 08:27:12 +01:00
|
|
|
|
|
|
|
/*! An attempt to reclaim the data buffer from a reader failed because
|
|
|
|
* the user hasn't yet read and committed all of it. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_DATA_LEFT MBEDTLS_MPS_READER_MAKE_ERROR(0x1)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
|
|
|
/*! An invalid argument was passed to the reader. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_INVALID_ARG MBEDTLS_MPS_READER_MAKE_ERROR(0x2)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
2021-01-28 10:45:47 +01:00
|
|
|
/*! An attempt to move a reader to consuming mode through mbedtls_mps_reader_feed()
|
2021-01-12 08:27:12 +01:00
|
|
|
* after pausing failed because the provided data is not sufficient to serve the
|
2021-02-22 16:15:44 +01:00
|
|
|
* read requests that led to the pausing. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_NEED_MORE MBEDTLS_MPS_READER_MAKE_ERROR(0x3)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
2021-02-22 16:15:44 +01:00
|
|
|
/*! A get request failed because not enough data is available in the reader. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_OUT_OF_DATA MBEDTLS_MPS_READER_MAKE_ERROR(0x4)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
2021-02-22 16:15:44 +01:00
|
|
|
/*!< A get request after pausing and reactivating the reader failed because
|
2021-01-12 08:27:12 +01:00
|
|
|
* the request is not in line with the request made prior to pausing. The user
|
|
|
|
* must not change it's 'strategy' after pausing and reactivating a reader. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_INCONSISTENT_REQUESTS MBEDTLS_MPS_READER_MAKE_ERROR(0x5)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
2021-02-22 16:15:44 +01:00
|
|
|
/*! An attempt to reclaim the data buffer from a reader failed because the reader
|
2021-01-12 08:27:12 +01:00
|
|
|
* has no accumulator it can use to backup the data that hasn't been processed. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_NEED_ACCUMULATOR MBEDTLS_MPS_READER_MAKE_ERROR(0x6)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
2021-02-22 16:15:44 +01:00
|
|
|
/*! An attempt to reclaim the data buffer from a reader failed because the
|
2021-01-12 08:27:12 +01:00
|
|
|
* accumulator passed to the reader is not large enough to hold both the
|
|
|
|
* data that hasn't been processed and the excess of the last read-request. */
|
2023-01-11 14:50:10 +01:00
|
|
|
#define MBEDTLS_ERR_MPS_READER_ACCUMULATOR_TOO_SMALL MBEDTLS_MPS_READER_MAKE_ERROR(0x7)
|
2021-01-12 08:27:12 +01:00
|
|
|
|
|
|
|
/* \} name SECTION: MPS Reader error codes */
|
|
|
|
|
|
|
|
#endif /* MBEDTLS_MPS_ERROR_H */
|