blob: 466cbfef42796e091fbcc65fa89885280a4d081f [file] [log] [blame]
Antonio de Angelis8908f472018-08-31 15:44:25 +01001/*
Antonio de Angelis377a1552018-11-22 17:02:40 +00002 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Antonio de Angelis8908f472018-08-31 15:44:25 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Jamie Fox0e54ebc2019-04-09 14:21:04 +01008#include <stddef.h>
9#include <stdint.h>
Antonio de Angelis8908f472018-08-31 15:44:25 +010010
Summer Qin4b1d03b2019-07-02 14:56:08 +080011/* FixMe: Use PSA_ERROR_CONNECTION_REFUSED when performing parameter
Antonio de Angelis4743e672019-04-11 11:38:48 +010012 * integrity checks but this will have to be revised
13 * when the full set of error codes mandated by PSA FF
14 * is available.
15 */
Jamie Fox0e54ebc2019-04-09 14:21:04 +010016#include "tfm_mbedcrypto_include.h"
Antonio de Angelis4743e672019-04-11 11:38:48 +010017
Jamie Fox0e54ebc2019-04-09 14:21:04 +010018#include "tfm_crypto_api.h"
19#include "tfm_crypto_defs.h"
Antonio de Angelis8908f472018-08-31 15:44:25 +010020
21/*!
22 * \defgroup public_psa Public functions, PSA
23 *
24 */
25
26/*!@{*/
Antonio de Angelis25e2b2d2019-04-25 14:49:50 +010027psa_status_t tfm_crypto_cipher_generate_iv(psa_invec in_vec[],
28 size_t in_len,
29 psa_outvec out_vec[],
30 size_t out_len)
31{
32 psa_status_t status = PSA_SUCCESS;
33 psa_cipher_operation_t *operation = NULL;
34
35 if ((in_len != 1) || (out_len != 2)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +080036 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelis25e2b2d2019-04-25 14:49:50 +010037 }
38
39 if ((in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec)) ||
40 (out_vec[0].len != sizeof(uint32_t))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +080041 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelis25e2b2d2019-04-25 14:49:50 +010042 }
43
44 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
45 uint32_t handle = iov->op_handle;
46 uint32_t *handle_out = out_vec[0].base;
47 unsigned char *iv = out_vec[1].base;
48 size_t iv_size = out_vec[1].len;
49
50 /* Init the handle in the operation with the one passed from the iov */
51 *handle_out = iov->op_handle;
52
53 /* Look up the corresponding operation context */
54 status = tfm_crypto_operation_lookup(TFM_CRYPTO_CIPHER_OPERATION,
55 handle,
56 (void **)&operation);
57 if (status != PSA_SUCCESS) {
58 return status;
59 }
60
61 *handle_out = handle;
62
63 status = psa_cipher_generate_iv(operation, iv, iv_size, &out_vec[1].len);
64 if (status != PSA_SUCCESS) {
65 /* Release the operation context, ignore if the operation fails. */
66 (void)tfm_crypto_operation_release(handle_out);
67 return status;
68 }
69
70 return status;
71}
72
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000073psa_status_t tfm_crypto_cipher_set_iv(psa_invec in_vec[],
74 size_t in_len,
75 psa_outvec out_vec[],
76 size_t out_len)
Antonio de Angelis8908f472018-08-31 15:44:25 +010077{
Antonio de Angeliscf85ba22018-10-09 13:29:40 +010078 psa_status_t status = PSA_SUCCESS;
Jamie Fox0e54ebc2019-04-09 14:21:04 +010079 psa_cipher_operation_t *operation = NULL;
Antonio de Angelis8908f472018-08-31 15:44:25 +010080
Antonio de Angelis4743e672019-04-11 11:38:48 +010081 if ((in_len != 2) || (out_len != 1)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +080082 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelis8908f472018-08-31 15:44:25 +010083 }
84
Antonio de Angelis4743e672019-04-11 11:38:48 +010085 if ((in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec)) ||
Jamie Fox0e54ebc2019-04-09 14:21:04 +010086 (out_vec[0].len != sizeof(uint32_t))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +080087 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000088 }
Antonio de Angelis4743e672019-04-11 11:38:48 +010089 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +010090 uint32_t handle = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +010091 uint32_t *handle_out = out_vec[0].base;
92 const unsigned char *iv = in_vec[1].base;
93 size_t iv_length = in_vec[1].len;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000094
Antonio de Angelis4743e672019-04-11 11:38:48 +010095 /* Init the handle in the operation with the one passed from the iov */
Jamie Fox0e54ebc2019-04-09 14:21:04 +010096 *handle_out = iov->op_handle;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000097
Antonio de Angelis8908f472018-08-31 15:44:25 +010098 /* Look up the corresponding operation context */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +000099 status = tfm_crypto_operation_lookup(TFM_CRYPTO_CIPHER_OPERATION,
Antonio de Angelis4743e672019-04-11 11:38:48 +0100100 handle,
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100101 (void **)&operation);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000102 if (status != PSA_SUCCESS) {
103 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100104 }
105
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100106 status = psa_cipher_set_iv(operation, iv, iv_length);
Antonio de Angeliscf85ba22018-10-09 13:29:40 +0100107 if (status != PSA_SUCCESS) {
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100108 /* Release the operation context, ignore if the operation fails. */
109 (void)tfm_crypto_operation_release(handle_out);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000110 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100111 }
Antonio de Angeliscf85ba22018-10-09 13:29:40 +0100112
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000113 return status;
114}
Antonio de Angelis4743e672019-04-11 11:38:48 +0100115
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000116psa_status_t tfm_crypto_cipher_encrypt_setup(psa_invec in_vec[],
117 size_t in_len,
118 psa_outvec out_vec[],
119 size_t out_len)
120{
Antonio de Angelis4743e672019-04-11 11:38:48 +0100121 psa_status_t status = PSA_SUCCESS;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100122 psa_cipher_operation_t *operation = NULL;
123
Antonio de Angelis4743e672019-04-11 11:38:48 +0100124 if ((in_len != 1) || (out_len != 1)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800125 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000126 }
127
Antonio de Angelis4743e672019-04-11 11:38:48 +0100128 if ((out_vec[0].len != sizeof(uint32_t)) ||
129 (in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800130 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000131 }
Antonio de Angelis4743e672019-04-11 11:38:48 +0100132 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100133 uint32_t handle = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100134 uint32_t *handle_out = out_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100135 psa_key_handle_t key_handle = iov->key_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100136 psa_algorithm_t alg = iov->alg;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000137
Antonio de Angelis60a6fe62019-06-18 15:27:34 +0100138 status = tfm_crypto_check_handle_owner(key_handle, NULL);
139 if (status != PSA_SUCCESS) {
140 return status;
141 }
142
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100143 /* Allocate the operation context in the secure world */
144 status = tfm_crypto_operation_alloc(TFM_CRYPTO_CIPHER_OPERATION,
145 &handle,
146 (void **)&operation);
147 if (status != PSA_SUCCESS) {
148 return status;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100149 }
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100150
151 *handle_out = handle;
152
153 status = psa_cipher_encrypt_setup(operation, key_handle, alg);
154 if (status != PSA_SUCCESS) {
155 /* Release the operation context, ignore if the operation fails. */
156 (void)tfm_crypto_operation_release(handle_out);
157 return status;
158 }
159
Antonio de Angelis4743e672019-04-11 11:38:48 +0100160 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100161}
162
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000163psa_status_t tfm_crypto_cipher_decrypt_setup(psa_invec in_vec[],
164 size_t in_len,
165 psa_outvec out_vec[],
166 size_t out_len)
Antonio de Angelis8908f472018-08-31 15:44:25 +0100167{
Antonio de Angelis4743e672019-04-11 11:38:48 +0100168 psa_status_t status = PSA_SUCCESS;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100169 psa_cipher_operation_t *operation = NULL;
170
Antonio de Angelis4743e672019-04-11 11:38:48 +0100171 if ((in_len != 1) || (out_len != 1)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800172 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000173 }
174
Antonio de Angelis4743e672019-04-11 11:38:48 +0100175 if ((out_vec[0].len != sizeof(uint32_t)) ||
176 (in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800177 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000178 }
Antonio de Angelis4743e672019-04-11 11:38:48 +0100179 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100180 uint32_t handle = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100181 uint32_t *handle_out = out_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100182 psa_key_handle_t key_handle = iov->key_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100183 psa_algorithm_t alg = iov->alg;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000184
Antonio de Angelis60a6fe62019-06-18 15:27:34 +0100185 status = tfm_crypto_check_handle_owner(key_handle, NULL);
186 if (status != PSA_SUCCESS) {
187 return status;
188 }
189
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100190 /* Allocate the operation context in the secure world */
191 status = tfm_crypto_operation_alloc(TFM_CRYPTO_CIPHER_OPERATION,
192 &handle,
193 (void **)&operation);
194 if (status != PSA_SUCCESS) {
195 return status;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100196 }
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100197
198 *handle_out = handle;
199
200 status = psa_cipher_decrypt_setup(operation, key_handle, alg);
201 if (status != PSA_SUCCESS) {
202 /* Release the operation context, ignore if the operation fails. */
203 (void)tfm_crypto_operation_release(handle_out);
204 return status;
205 }
206
Antonio de Angelis4743e672019-04-11 11:38:48 +0100207 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100208}
209
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000210psa_status_t tfm_crypto_cipher_update(psa_invec in_vec[],
211 size_t in_len,
212 psa_outvec out_vec[],
213 size_t out_len)
Antonio de Angelis8908f472018-08-31 15:44:25 +0100214{
Antonio de Angeliscf85ba22018-10-09 13:29:40 +0100215 psa_status_t status = PSA_SUCCESS;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100216 psa_cipher_operation_t *operation = NULL;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100217
Antonio de Angelis4743e672019-04-11 11:38:48 +0100218 if ((in_len != 2) || (out_len != 2)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800219 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100220 }
221
Antonio de Angelis4743e672019-04-11 11:38:48 +0100222 if ((in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec)) ||
223 (out_vec[0].len != sizeof(uint32_t))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800224 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000225 }
Antonio de Angelis4743e672019-04-11 11:38:48 +0100226 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100227 uint32_t handle = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100228 uint32_t *handle_out = out_vec[0].base;
229 const uint8_t *input = in_vec[1].base;
230 size_t input_length = in_vec[1].len;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000231 unsigned char *output = out_vec[1].base;
232 size_t output_size = out_vec[1].len;
233
Antonio de Angelis4743e672019-04-11 11:38:48 +0100234 /* Init the handle in the operation with the one passed from the iov */
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100235 *handle_out = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100236
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000237 /* Initialise the output_length to zero */
238 out_vec[1].len = 0;
Jamie Fox82b87ca2018-12-11 16:41:11 +0000239
Antonio de Angelis8908f472018-08-31 15:44:25 +0100240 /* Look up the corresponding operation context */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000241 status = tfm_crypto_operation_lookup(TFM_CRYPTO_CIPHER_OPERATION,
Antonio de Angelis4743e672019-04-11 11:38:48 +0100242 handle,
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100243 (void **)&operation);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000244 if (status != PSA_SUCCESS) {
245 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100246 }
247
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100248 status = psa_cipher_update(operation, input, input_length,
249 output, output_size, &out_vec[1].len);
Antonio de Angeliscf85ba22018-10-09 13:29:40 +0100250 if (status != PSA_SUCCESS) {
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100251 /* Release the operation context, ignore if the operation fails. */
252 (void)tfm_crypto_operation_release(handle_out);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000253 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100254 }
255
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100256 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100257}
258
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000259psa_status_t tfm_crypto_cipher_finish(psa_invec in_vec[],
260 size_t in_len,
261 psa_outvec out_vec[],
262 size_t out_len)
Antonio de Angelis8908f472018-08-31 15:44:25 +0100263{
Antonio de Angeliscf85ba22018-10-09 13:29:40 +0100264 psa_status_t status = PSA_SUCCESS;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100265 psa_cipher_operation_t *operation = NULL;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100266
Antonio de Angelis4743e672019-04-11 11:38:48 +0100267 if ((in_len != 1) || (out_len != 2)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800268 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100269 }
270
Antonio de Angelis4743e672019-04-11 11:38:48 +0100271 if ((in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec)) ||
272 (out_vec[0].len != sizeof(uint32_t))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800273 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000274 }
Antonio de Angelis4743e672019-04-11 11:38:48 +0100275 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100276 uint32_t handle = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100277 uint32_t *handle_out = out_vec[0].base;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000278 unsigned char *output = out_vec[1].base;
279 size_t output_size = out_vec[1].len;
280
Antonio de Angelis4743e672019-04-11 11:38:48 +0100281 /* Init the handle in the operation with the one passed from the iov */
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100282 *handle_out = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100283
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000284 /* Initialise the output_length to zero */
285 out_vec[1].len = 0;
286
Antonio de Angelis8908f472018-08-31 15:44:25 +0100287 /* Look up the corresponding operation context */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000288 status = tfm_crypto_operation_lookup(TFM_CRYPTO_CIPHER_OPERATION,
Antonio de Angelis4743e672019-04-11 11:38:48 +0100289 handle,
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100290 (void **)&operation);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000291 if (status != PSA_SUCCESS) {
292 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100293 }
294
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100295 status = psa_cipher_finish(operation, output, output_size, &out_vec[1].len);
Antonio de Angeliscf85ba22018-10-09 13:29:40 +0100296 if (status != PSA_SUCCESS) {
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100297 /* Release the operation context, ignore if the operation fails. */
298 (void)tfm_crypto_operation_release(handle_out);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000299 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100300 }
301
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100302 status = tfm_crypto_operation_release(handle_out);
303
Antonio de Angelis4743e672019-04-11 11:38:48 +0100304 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100305}
306
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000307psa_status_t tfm_crypto_cipher_abort(psa_invec in_vec[],
308 size_t in_len,
309 psa_outvec out_vec[],
310 size_t out_len)
Antonio de Angelis8908f472018-08-31 15:44:25 +0100311{
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000312 psa_status_t status = PSA_SUCCESS;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100313 psa_cipher_operation_t *operation = NULL;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100314
Antonio de Angelis4743e672019-04-11 11:38:48 +0100315 if ((in_len != 1) || (out_len != 1)) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800316 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100317 }
318
Antonio de Angelis4743e672019-04-11 11:38:48 +0100319 if ((in_vec[0].len != sizeof(struct tfm_crypto_pack_iovec)) ||
320 (out_vec[0].len != sizeof(uint32_t))) {
Summer Qin4b1d03b2019-07-02 14:56:08 +0800321 return PSA_ERROR_CONNECTION_REFUSED;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000322 }
Antonio de Angelis4743e672019-04-11 11:38:48 +0100323 const struct tfm_crypto_pack_iovec *iov = in_vec[0].base;
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100324 uint32_t handle = iov->op_handle;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100325 uint32_t *handle_out = out_vec[0].base;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000326
Antonio de Angelis4743e672019-04-11 11:38:48 +0100327 /* Init the handle in the operation with the one passed from the iov */
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100328 *handle_out = iov->op_handle;
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000329
Antonio de Angelis8908f472018-08-31 15:44:25 +0100330 /* Look up the corresponding operation context */
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000331 status = tfm_crypto_operation_lookup(TFM_CRYPTO_CIPHER_OPERATION,
Antonio de Angelis4743e672019-04-11 11:38:48 +0100332 handle,
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100333 (void **)&operation);
Antonio de Angelisab85ccd2019-03-25 15:14:29 +0000334 if (status != PSA_SUCCESS) {
Antonio de Angelis25e2b2d2019-04-25 14:49:50 +0100335 /* Operation does not exist, so abort has no effect */
336 return PSA_SUCCESS;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100337 }
338
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100339 status = psa_cipher_abort(operation);
340
341 if (status != PSA_SUCCESS) {
342 /* Release the operation context, ignore if the operation fails. */
343 (void)tfm_crypto_operation_release(handle_out);
344 return status;
Antonio de Angelis4743e672019-04-11 11:38:48 +0100345 }
Jamie Fox0e54ebc2019-04-09 14:21:04 +0100346
347 status = tfm_crypto_operation_release(handle_out);
348
Antonio de Angelis4743e672019-04-11 11:38:48 +0100349 return status;
Antonio de Angelis8908f472018-08-31 15:44:25 +0100350}
351/*!@}*/