|
40 | 40 | * @{
|
41 | 41 | */
|
42 | 42 |
|
43 |
| -#if !defined(PSA_SUCCESS) |
44 |
| -/* If PSA_SUCCESS is defined, assume that PSA crypto is being used |
45 |
| - * together with PSA IPC, which also defines the identifier |
46 |
| - * PSA_SUCCESS. We must not define PSA_SUCCESS ourselves in that case; |
47 |
| - * the other error code names don't clash. This is a temporary hack |
48 |
| - * until we unify error reporting in PSA IPC and PSA crypto. |
49 |
| - * |
50 |
| - * Note that psa_defs.h must be included before this header! |
| 43 | +/* PSA error codes */ |
| 44 | +/* List should comply with the ones defined in https://github.com/ARMmbed/PSA-IPC-doc/blob/master/allocated_errors.h |
51 | 45 | */
|
52 | 46 | /** The action was completed successfully. */
|
53 | 47 | #define PSA_SUCCESS ((psa_status_t)0)
|
54 |
| -#endif /* !defined(PSA_SUCCESS) */ |
55 | 48 |
|
56 | 49 | /** An error occurred that does not correspond to any defined
|
57 | 50 | * failure cause.
|
58 | 51 | *
|
59 | 52 | * Implementations may use this error code if none of the other standard
|
60 | 53 | * error codes are applicable. */
|
61 |
| -#define PSA_ERROR_UNKNOWN_ERROR ((psa_status_t)1) |
| 54 | +#define PSA_ERROR_GENERIC_ERROR ((psa_status_t)-132) |
62 | 55 |
|
63 | 56 | /** The requested operation or a parameter is not supported
|
64 | 57 | * by this implementation.
|
|
67 | 60 | * parameter such as a key type, algorithm, etc. is not recognized.
|
68 | 61 | * If a combination of parameters is recognized and identified as
|
69 | 62 | * not valid, return #PSA_ERROR_INVALID_ARGUMENT instead. */
|
70 |
| -#define PSA_ERROR_NOT_SUPPORTED ((psa_status_t)2) |
| 63 | +#define PSA_ERROR_NOT_SUPPORTED ((psa_status_t)-134) |
71 | 64 |
|
72 | 65 | /** The requested action is denied by a policy.
|
73 | 66 | *
|
|
80 | 73 | * not valid or not supported, it is unspecified whether the function
|
81 | 74 | * returns #PSA_ERROR_NOT_PERMITTED, #PSA_ERROR_NOT_SUPPORTED or
|
82 | 75 | * #PSA_ERROR_INVALID_ARGUMENT. */
|
83 |
| -#define PSA_ERROR_NOT_PERMITTED ((psa_status_t)3) |
| 76 | +#define PSA_ERROR_NOT_PERMITTED ((psa_status_t)-133) |
84 | 77 |
|
85 | 78 | /** An output buffer is too small.
|
86 | 79 | *
|
|
92 | 85 | * buffer would succeed. However implementations may return this
|
93 | 86 | * error if a function has invalid or unsupported parameters in addition
|
94 | 87 | * to the parameters that determine the necessary output buffer size. */
|
95 |
| -#define PSA_ERROR_BUFFER_TOO_SMALL ((psa_status_t)4) |
| 88 | +#define PSA_ERROR_BUFFER_TOO_SMALL ((psa_status_t)-138) |
96 | 89 |
|
97 | 90 | /** A slot is occupied, but must be empty to carry out the
|
98 | 91 | * requested action.
|
99 | 92 | *
|
100 | 93 | * If a handle is invalid, it does not designate an occupied slot.
|
101 | 94 | * The error for an invalid handle is #PSA_ERROR_INVALID_HANDLE.
|
102 | 95 | */
|
103 |
| -#define PSA_ERROR_OCCUPIED_SLOT ((psa_status_t)5) |
| 96 | +#define PSA_ERROR_OCCUPIED_SLOT ((psa_status_t)-153) |
104 | 97 |
|
105 | 98 | /** A slot is empty, but must be occupied to carry out the
|
106 | 99 | * requested action.
|
107 | 100 | *
|
108 | 101 | * If a handle is invalid, it does not designate an empty slot.
|
109 | 102 | * The error for an invalid handle is #PSA_ERROR_INVALID_HANDLE.
|
110 | 103 | */
|
111 |
| -#define PSA_ERROR_EMPTY_SLOT ((psa_status_t)6) |
| 104 | +#define PSA_ERROR_EMPTY_SLOT ((psa_status_t)-154) |
112 | 105 |
|
113 | 106 | /** The requested action cannot be performed in the current state.
|
114 | 107 | *
|
|
120 | 113 | * that a key slot is occupied when it needs to be free or vice versa,
|
121 | 114 | * but shall return #PSA_ERROR_OCCUPIED_SLOT or #PSA_ERROR_EMPTY_SLOT
|
122 | 115 | * as applicable. */
|
123 |
| -#define PSA_ERROR_BAD_STATE ((psa_status_t)7) |
| 116 | +#define PSA_ERROR_BAD_STATE ((psa_status_t)-137) |
124 | 117 |
|
125 | 118 | /** The parameters passed to the function are invalid.
|
126 | 119 | *
|
|
136 | 129 | * key handle is invalid, but shall return #PSA_ERROR_INVALID_HANDLE
|
137 | 130 | * instead.
|
138 | 131 | */
|
139 |
| -#define PSA_ERROR_INVALID_ARGUMENT ((psa_status_t)8) |
| 132 | +#define PSA_ERROR_INVALID_ARGUMENT ((psa_status_t)-135) |
140 | 133 |
|
141 | 134 | /** There is not enough runtime memory.
|
142 | 135 | *
|
143 | 136 | * If the action is carried out across multiple security realms, this
|
144 | 137 | * error can refer to available memory in any of the security realms. */
|
145 |
| -#define PSA_ERROR_INSUFFICIENT_MEMORY ((psa_status_t)9) |
| 138 | +#define PSA_ERROR_INSUFFICIENT_MEMORY ((psa_status_t)-141) |
146 | 139 |
|
147 | 140 | /** There is not enough persistent storage.
|
148 | 141 | *
|
|
151 | 144 | * many functions that do not otherwise access storage may return this
|
152 | 145 | * error code if the implementation requires a mandatory log entry for
|
153 | 146 | * the requested action and the log storage space is full. */
|
154 |
| -#define PSA_ERROR_INSUFFICIENT_STORAGE ((psa_status_t)10) |
| 147 | +#define PSA_ERROR_INSUFFICIENT_STORAGE ((psa_status_t)-142) |
155 | 148 |
|
156 | 149 | /** There was a communication failure inside the implementation.
|
157 | 150 | *
|
|
168 | 161 | * cryptoprocessor but there was a breakdown of communication before
|
169 | 162 | * the cryptoprocessor could report the status to the application.
|
170 | 163 | */
|
171 |
| -#define PSA_ERROR_COMMUNICATION_FAILURE ((psa_status_t)11) |
| 164 | +#define PSA_ERROR_COMMUNICATION_FAILURE ((psa_status_t)-145) |
172 | 165 |
|
173 | 166 | /** There was a storage failure that may have led to data loss.
|
174 | 167 | *
|
|
193 | 186 | * permanent storage corruption. However application writers should
|
194 | 187 | * keep in mind that transient errors while reading the storage may be
|
195 | 188 | * reported using this error code. */
|
196 |
| -#define PSA_ERROR_STORAGE_FAILURE ((psa_status_t)12) |
| 189 | +#define PSA_ERROR_STORAGE_FAILURE ((psa_status_t)-146) |
197 | 190 |
|
198 | 191 | /** A hardware failure was detected.
|
199 | 192 | *
|
200 | 193 | * A hardware failure may be transient or permanent depending on the
|
201 | 194 | * cause. */
|
202 |
| -#define PSA_ERROR_HARDWARE_FAILURE ((psa_status_t)13) |
| 195 | +#define PSA_ERROR_HARDWARE_FAILURE ((psa_status_t)-147) |
203 | 196 |
|
204 | 197 | /** A tampering attempt was detected.
|
205 | 198 | *
|
|
230 | 223 | * This error indicates an attack against the application. Implementations
|
231 | 224 | * shall not return this error code as a consequence of the behavior of
|
232 | 225 | * the application itself. */
|
233 |
| -#define PSA_ERROR_TAMPERING_DETECTED ((psa_status_t)14) |
| 226 | +#define PSA_ERROR_TAMPERING_DETECTED ((psa_status_t)-151) |
234 | 227 |
|
235 | 228 | /** There is not enough entropy to generate random data needed
|
236 | 229 | * for the requested action.
|
|
249 | 242 | * secure pseudorandom generator (PRNG). However implementations may return
|
250 | 243 | * this error at any time if a policy requires the PRNG to be reseeded
|
251 | 244 | * during normal operation. */
|
252 |
| -#define PSA_ERROR_INSUFFICIENT_ENTROPY ((psa_status_t)15) |
| 245 | +#define PSA_ERROR_INSUFFICIENT_ENTROPY ((psa_status_t)-148) |
253 | 246 |
|
254 | 247 | /** The signature, MAC or hash is incorrect.
|
255 | 248 | *
|
|
259 | 252 | *
|
260 | 253 | * If the value to verify has an invalid size, implementations may return
|
261 | 254 | * either #PSA_ERROR_INVALID_ARGUMENT or #PSA_ERROR_INVALID_SIGNATURE. */
|
262 |
| -#define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)16) |
| 255 | +#define PSA_ERROR_INVALID_SIGNATURE ((psa_status_t)-149) |
263 | 256 |
|
264 | 257 | /** The decrypted padding is incorrect.
|
265 | 258 | *
|
|
275 | 268 | * as close as possible to indistinguishable to an external observer.
|
276 | 269 | * In particular, the timing of a decryption operation should not
|
277 | 270 | * depend on the validity of the padding. */
|
278 |
| -#define PSA_ERROR_INVALID_PADDING ((psa_status_t)17) |
| 271 | +#define PSA_ERROR_INVALID_PADDING ((psa_status_t)-150) |
279 | 272 |
|
280 | 273 | /** The generator has insufficient capacity left.
|
281 | 274 | *
|
282 | 275 | * Once a function returns this error, attempts to read from the
|
283 | 276 | * generator will always return this error. */
|
284 |
| -#define PSA_ERROR_INSUFFICIENT_CAPACITY ((psa_status_t)18) |
| 277 | +#define PSA_ERROR_INSUFFICIENT_CAPACITY ((psa_status_t)-155) |
285 | 278 |
|
286 | 279 | /** The key handle is not valid.
|
287 | 280 | */
|
288 |
| -#define PSA_ERROR_INVALID_HANDLE ((psa_status_t)19) |
| 281 | +#define PSA_ERROR_INVALID_HANDLE ((psa_status_t)-136) |
289 | 282 |
|
290 | 283 | /**@}*/
|
291 | 284 |
|
|
0 commit comments