Merge remote-tracking branch 'psa/pr/57' into feature-psa
This commit is contained in:
commit
e584ccb6fd
1 changed files with 242 additions and 207 deletions
|
@ -45,14 +45,34 @@ extern "C" {
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(PSA_SUCCESS)
|
||||||
|
/* If PSA_SUCCESS is defined, assume that PSA crypto is being used
|
||||||
|
* together with PSA IPC, which also defines the identifier
|
||||||
|
* PSA_SUCCESS. We must not define PSA_SUCCESS ourselves in that case;
|
||||||
|
* the other error code names don't clash. Also define psa_status_t as
|
||||||
|
* an alias for the type used by PSA IPC. This is a temporary hack
|
||||||
|
* until we unify error reporting in PSA IPC and PSA crypo.
|
||||||
|
*
|
||||||
|
* Note that psa_defs.h must be included before this header!
|
||||||
|
*/
|
||||||
|
typedef psa_error_t psa_status_t;
|
||||||
|
|
||||||
|
#else /* defined(PSA_SUCCESS) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Function return status.
|
* \brief Function return status.
|
||||||
*
|
*
|
||||||
* Zero indicates success, anything else indicates an error.
|
* This is either #PSA_SUCCESS (which is zero), indicating success,
|
||||||
|
* or a nonzero value indicating that an error occurred. Errors are
|
||||||
|
* encoded as one of the \c PSA_ERROR_xxx values defined here.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef int32_t psa_status_t;
|
||||||
|
|
||||||
/** The action was completed successfully. */
|
/** The action was completed successfully. */
|
||||||
PSA_SUCCESS = 0,
|
#define PSA_SUCCESS ((psa_status_t)0)
|
||||||
|
|
||||||
|
#endif /* !defined(PSA_SUCCESS) */
|
||||||
|
|
||||||
/** The requested operation or a parameter is not supported
|
/** The requested operation or a parameter is not supported
|
||||||
* by this implementation.
|
* by this implementation.
|
||||||
*
|
*
|
||||||
|
@ -60,7 +80,8 @@ typedef enum {
|
||||||
* parameter such as a key type, algorithm, etc. is not recognized.
|
* parameter such as a key type, algorithm, etc. is not recognized.
|
||||||
* If a combination of parameters is recognized and identified as
|
* If a combination of parameters is recognized and identified as
|
||||||
* not valid, return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
* not valid, return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
||||||
PSA_ERROR_NOT_SUPPORTED,
|
#define PSA_ERROR_NOT_SUPPORTED ((psa_status_t)1)
|
||||||
|
|
||||||
/** The requested action is denied by a policy.
|
/** The requested action is denied by a policy.
|
||||||
*
|
*
|
||||||
* Implementations should return this error code when the parameters
|
* Implementations should return this error code when the parameters
|
||||||
|
@ -72,7 +93,8 @@ typedef enum {
|
||||||
* not valid or not supported, it is unspecified whether the function
|
* not valid or not supported, it is unspecified whether the function
|
||||||
* returns #PSA_ERROR_NOT_PERMITTED, #PSA_ERROR_NOT_SUPPORTED or
|
* returns #PSA_ERROR_NOT_PERMITTED, #PSA_ERROR_NOT_SUPPORTED or
|
||||||
* #PSA_ERROR_INVALID_ARGUMENT. */
|
* #PSA_ERROR_INVALID_ARGUMENT. */
|
||||||
PSA_ERROR_NOT_PERMITTED,
|
#define PSA_ERROR_NOT_PERMITTED ((psa_status_t)2)
|
||||||
|
|
||||||
/** An output buffer is too small.
|
/** An output buffer is too small.
|
||||||
*
|
*
|
||||||
* Applications can call the `PSA_xxx_SIZE` macro listed in the function
|
* Applications can call the `PSA_xxx_SIZE` macro listed in the function
|
||||||
|
@ -83,21 +105,24 @@ typedef enum {
|
||||||
* buffer would succeed. However implementations may return this
|
* buffer would succeed. However implementations may return this
|
||||||
* error if a function has invalid or unsupported parameters in addition
|
* error if a function has invalid or unsupported parameters in addition
|
||||||
* to the parameters that determine the necessary output buffer size. */
|
* to the parameters that determine the necessary output buffer size. */
|
||||||
PSA_ERROR_BUFFER_TOO_SMALL,
|
#define PSA_ERROR_BUFFER_TOO_SMALL ((psa_status_t)3)
|
||||||
|
|
||||||
/** A slot is occupied, but must be empty to carry out the
|
/** A slot is occupied, but must be empty to carry out the
|
||||||
* requested action.
|
* requested action.
|
||||||
*
|
*
|
||||||
* If the slot number is invalid (i.e. the requested action could
|
* If the slot number is invalid (i.e. the requested action could
|
||||||
* not be performed even after erasing the slot's content),
|
* not be performed even after erasing the slot's content),
|
||||||
* implementations shall return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
* implementations shall return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
||||||
PSA_ERROR_OCCUPIED_SLOT,
|
#define PSA_ERROR_OCCUPIED_SLOT ((psa_status_t)4)
|
||||||
|
|
||||||
/** A slot is empty, but must be occupied to carry out the
|
/** A slot is empty, but must be occupied to carry out the
|
||||||
* requested action.
|
* requested action.
|
||||||
*
|
*
|
||||||
* If the slot number is invalid (i.e. the requested action could
|
* If the slot number is invalid (i.e. the requested action could
|
||||||
* not be performed even after creating appropriate content in the slot),
|
* not be performed even after creating appropriate content in the slot),
|
||||||
* implementations shall return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
* implementations shall return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
||||||
PSA_ERROR_EMPTY_SLOT,
|
#define PSA_ERROR_EMPTY_SLOT ((psa_status_t)5)
|
||||||
|
|
||||||
/** The requested action cannot be performed in the current state.
|
/** The requested action cannot be performed in the current state.
|
||||||
*
|
*
|
||||||
* Multipart operations return this error when one of the
|
* Multipart operations return this error when one of the
|
||||||
|
@ -108,7 +133,8 @@ typedef enum {
|
||||||
* that a key slot is occupied when it needs to be free or vice versa,
|
* that a key slot is occupied when it needs to be free or vice versa,
|
||||||
* but shall return #PSA_ERROR_OCCUPIED_SLOT or #PSA_ERROR_EMPTY_SLOT
|
* but shall return #PSA_ERROR_OCCUPIED_SLOT or #PSA_ERROR_EMPTY_SLOT
|
||||||
* as applicable. */
|
* as applicable. */
|
||||||
PSA_ERROR_BAD_STATE,
|
#define PSA_ERROR_BAD_STATE ((psa_status_t)6)
|
||||||
|
|
||||||
/** The parameters passed to the function are invalid.
|
/** The parameters passed to the function are invalid.
|
||||||
*
|
*
|
||||||
* Implementations may return this error any time a parameter or
|
* Implementations may return this error any time a parameter or
|
||||||
|
@ -118,12 +144,14 @@ typedef enum {
|
||||||
* that a key slot is occupied when it needs to be free or vice versa,
|
* that a key slot is occupied when it needs to be free or vice versa,
|
||||||
* but shall return #PSA_ERROR_OCCUPIED_SLOT or #PSA_ERROR_EMPTY_SLOT
|
* but shall return #PSA_ERROR_OCCUPIED_SLOT or #PSA_ERROR_EMPTY_SLOT
|
||||||
* as applicable. */
|
* as applicable. */
|
||||||
PSA_ERROR_INVALID_ARGUMENT,
|
#define PSA_ERROR_INVALID_ARGUMENT ((psa_status_t)7)
|
||||||
|
|
||||||
/** There is not enough runtime memory.
|
/** There is not enough runtime memory.
|
||||||
*
|
*
|
||||||
* If the action is carried out across multiple security realms, this
|
* If the action is carried out across multiple security realms, this
|
||||||
* error can refer to available memory in any of the security realms. */
|
* error can refer to available memory in any of the security realms. */
|
||||||
PSA_ERROR_INSUFFICIENT_MEMORY,
|
#define PSA_ERROR_INSUFFICIENT_MEMORY ((psa_status_t)8)
|
||||||
|
|
||||||
/** There is not enough persistent storage.
|
/** There is not enough persistent storage.
|
||||||
*
|
*
|
||||||
* Functions that modify the key storage return this error code if
|
* Functions that modify the key storage return this error code if
|
||||||
|
@ -131,7 +159,8 @@ typedef enum {
|
||||||
* many functions that do not otherwise access storage may return this
|
* many functions that do not otherwise access storage may return this
|
||||||
* error code if the implementation requires a mandatory log entry for
|
* error code if the implementation requires a mandatory log entry for
|
||||||
* the requested action and the log storage space is full. */
|
* the requested action and the log storage space is full. */
|
||||||
PSA_ERROR_INSUFFICIENT_STORAGE,
|
#define PSA_ERROR_INSUFFICIENT_STORAGE ((psa_status_t)9)
|
||||||
|
|
||||||
/** There was a communication failure inside the implementation.
|
/** There was a communication failure inside the implementation.
|
||||||
*
|
*
|
||||||
* This can indicate a communication failure between the application
|
* This can indicate a communication failure between the application
|
||||||
|
@ -147,7 +176,8 @@ typedef enum {
|
||||||
* cryptoprocessor but there was a breakdown of communication before
|
* cryptoprocessor but there was a breakdown of communication before
|
||||||
* the cryptoprocessor could report the status to the application.
|
* the cryptoprocessor could report the status to the application.
|
||||||
*/
|
*/
|
||||||
PSA_ERROR_COMMUNICATION_FAILURE,
|
#define PSA_ERROR_COMMUNICATION_FAILURE ((psa_status_t)10)
|
||||||
|
|
||||||
/** There was a storage failure that may have led to data loss.
|
/** There was a storage failure that may have led to data loss.
|
||||||
*
|
*
|
||||||
* This error indicates that some persistent storage is corrupted.
|
* This error indicates that some persistent storage is corrupted.
|
||||||
|
@ -171,12 +201,14 @@ typedef enum {
|
||||||
* permanent storage corruption. However application writers should
|
* permanent storage corruption. However application writers should
|
||||||
* keep in mind that transient errors while reading the storage may be
|
* keep in mind that transient errors while reading the storage may be
|
||||||
* reported using this error code. */
|
* reported using this error code. */
|
||||||
PSA_ERROR_STORAGE_FAILURE,
|
#define PSA_ERROR_STORAGE_FAILURE ((psa_status_t)11)
|
||||||
|
|
||||||
/** A hardware failure was detected.
|
/** A hardware failure was detected.
|
||||||
*
|
*
|
||||||
* A hardware failure may be transient or permanent depending on the
|
* A hardware failure may be transient or permanent depending on the
|
||||||
* cause. */
|
* cause. */
|
||||||
PSA_ERROR_HARDWARE_FAILURE,
|
#define PSA_ERROR_HARDWARE_FAILURE ((psa_status_t)12)
|
||||||
|
|
||||||
/** A tampering attempt was detected.
|
/** A tampering attempt was detected.
|
||||||
*
|
*
|
||||||
* If an application receives this error code, there is no guarantee
|
* If an application receives this error code, there is no guarantee
|
||||||
|
@ -206,7 +238,8 @@ typedef enum {
|
||||||
* This error indicates an attack against the application. Implementations
|
* This error indicates an attack against the application. Implementations
|
||||||
* shall not return this error code as a consequence of the behavior of
|
* shall not return this error code as a consequence of the behavior of
|
||||||
* the application itself. */
|
* the application itself. */
|
||||||
PSA_ERROR_TAMPERING_DETECTED,
|
#define PSA_ERROR_TAMPERING_DETECTED ((psa_status_t)13)
|
||||||
|
|
||||||
/** There is not enough entropy to generate random data needed
|
/** There is not enough entropy to generate random data needed
|
||||||
* for the requested action.
|
* for the requested action.
|
||||||
*
|
*
|
||||||
|
@ -224,7 +257,8 @@ typedef enum {
|
||||||
* secure pseudorandom generator (PRNG). However implementations may return
|
* secure pseudorandom generator (PRNG). However implementations may return
|
||||||
* this error at any time if a policy requires the PRNG to be reseeded
|
* this error at any time if a policy requires the PRNG to be reseeded
|
||||||
* during normal operation. */
|
* during normal operation. */
|
||||||
PSA_ERROR_INSUFFICIENT_ENTROPY,
|
#define PSA_ERROR_INSUFFICIENT_ENTROPY ((psa_status_t)14)
|
||||||
|
|
||||||
/** The signature, MAC or hash is incorrect.
|
/** The signature, MAC or hash is incorrect.
|
||||||
*
|
*
|
||||||
* Verification functions return this error if the verification
|
* Verification functions return this error if the verification
|
||||||
|
@ -233,7 +267,8 @@ typedef enum {
|
||||||
*
|
*
|
||||||
* If the value to verify has an invalid size, implementations may return
|
* If the value to verify has an invalid size, implementations may return
|
||||||
* either #PSA_ERROR_INVALID_ARGUMENT or #PSA_ERROR_INVALID_SIGNATURE. */
|
* either #PSA_ERROR_INVALID_ARGUMENT or #PSA_ERROR_INVALID_SIGNATURE. */
|
||||||
PSA_ERROR_INVALID_SIGNATURE,
|
#define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)15)
|
||||||
|
|
||||||
/** The decrypted padding is incorrect.
|
/** The decrypted padding is incorrect.
|
||||||
*
|
*
|
||||||
* \warning In some protocols, when decrypting data, it is essential that
|
* \warning In some protocols, when decrypting data, it is essential that
|
||||||
|
@ -248,14 +283,14 @@ typedef enum {
|
||||||
* as close as possible to indistinguishable to an external observer.
|
* as close as possible to indistinguishable to an external observer.
|
||||||
* In particular, the timing of a decryption operation should not
|
* In particular, the timing of a decryption operation should not
|
||||||
* depend on the validity of the padding. */
|
* depend on the validity of the padding. */
|
||||||
PSA_ERROR_INVALID_PADDING,
|
#define PSA_ERROR_INVALID_PADDING ((psa_status_t)16)
|
||||||
|
|
||||||
/** An error occurred that does not correspond to any defined
|
/** An error occurred that does not correspond to any defined
|
||||||
* failure cause.
|
* failure cause.
|
||||||
*
|
*
|
||||||
* Implementations may use this error code if none of the other standard
|
* Implementations may use this error code if none of the other standard
|
||||||
* error codes are applicable. */
|
* error codes are applicable. */
|
||||||
PSA_ERROR_UNKNOWN_ERROR,
|
#define PSA_ERROR_UNKNOWN_ERROR ((psa_status_t)17)
|
||||||
} psa_status_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Library initialization.
|
* \brief Library initialization.
|
||||||
|
|
Loading…
Reference in a new issue