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