mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 11:45:39 +01:00
Add internal header for MPS errors
This commit adds an internal header `library/mps/error.h` related to error codes in MPS. For now, those error codes can be considered internal and thus we don't have to avoid clashes with other Mbed TLS error codes. This is OK as long as it's true that MPS isn't public API, and its error codes are never forwarded to the return values of public API calls. The error code allocation of MPS will likely need revisiting over time. Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
75ac1f7b95
commit
447e8a5ecd
89
library/mps/error.h
Normal file
89
library/mps/error.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file error.h
|
||||
*
|
||||
* \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?
|
||||
* If so, we need to adjust MBEDTLS_READER_MAKE_ERROR() to hit
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MBEDTLS_MPS_ERR_BASE
|
||||
#define MBEDTLS_MPS_ERR_BASE ( 1 << 0 )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name SECTION: MPS Reader error codes
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
|
||||
#ifndef MBEDTLS_MPS_READER_ERR_BASE
|
||||
#define MBEDTLS_MPS_READER_ERR_BASE ( 1 << 7 )
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_MPS_READER_MAKE_ERROR(code) \
|
||||
( -( MBEDTLS_MPS_READER_ERR_BASE | (code) ) )
|
||||
|
||||
/*! An attempt to reclaim the data buffer from a reader failed because
|
||||
* the user hasn't yet read and committed all of it. */
|
||||
#define MBEDTLS_ERR_MPS_READER_DATA_LEFT MBEDTLS_MPS_READER_MAKE_ERROR( 0x1 )
|
||||
|
||||
/*! An invalid argument was passed to the reader. */
|
||||
#define MBEDTLS_ERR_MPS_READER_INVALID_ARG MBEDTLS_MPS_READER_MAKE_ERROR( 0x2 )
|
||||
|
||||
/*! An attempt to move a reader to consuming mode through mbedtls_reader_feed()
|
||||
* after pausing failed because the provided data is not sufficient to serve the
|
||||
* the read requests that lead to the pausing. */
|
||||
#define MBEDTLS_ERR_MPS_READER_NEED_MORE MBEDTLS_MPS_READER_MAKE_ERROR( 0x3 )
|
||||
|
||||
/*! A read request failed because not enough data is available in the reader. */
|
||||
#define MBEDTLS_ERR_MPS_READER_OUT_OF_DATA MBEDTLS_MPS_READER_MAKE_ERROR( 0x4 )
|
||||
|
||||
/*!< A read request after pausing and reactivating the reader failed because
|
||||
* 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. */
|
||||
#define MBEDTLS_ERR_MPS_READER_INCONSISTENT_REQUESTS MBEDTLS_MPS_READER_MAKE_ERROR( 0x5 )
|
||||
|
||||
/*! An attempt to reclaim the data buffer from a reader fails because the reader
|
||||
* has no accumulator it can use to backup the data that hasn't been processed. */
|
||||
#define MBEDTLS_ERR_MPS_READER_NEED_ACCUMULATOR MBEDTLS_MPS_READER_MAKE_ERROR( 0x6 )
|
||||
|
||||
/*! An attempt to reclaim the data buffer from a reader fails beacuse the
|
||||
* 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. */
|
||||
#define MBEDTLS_ERR_MPS_READER_ACCUMULATOR_TOO_SMALL MBEDTLS_MPS_READER_MAKE_ERROR( 0x7 )
|
||||
|
||||
/* \} name SECTION: MPS Reader error codes */
|
||||
|
||||
#endif /* MBEDTLS_MPS_ERROR_H */
|
Loading…
Reference in New Issue
Block a user