blob: a20c13fc3dcdd400a049523dca3e7c29afce4970 [file] [log] [blame]
Steven Cooreman0e307642021-02-18 16:18:32 +01001/*
2 * PSA hashing layer on top of Mbed TLS software crypto
3 */
4/*
5 * Copyright The Mbed TLS Contributors
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#include "common.h"
22
23#if defined(MBEDTLS_PSA_CRYPTO_C)
24
25#include <psa/crypto.h>
26#include "psa_crypto_core.h"
27#include "psa_crypto_hash.h"
28
29#include <mbedtls/error.h>
30#include <string.h>
31
Ronald Cron0266cfe2021-03-13 18:50:11 +010032#if defined(MBEDTLS_PSA_BUILTIN_HASH)
33psa_status_t mbedtls_psa_hash_abort(
Steven Cooreman83f300e2021-03-08 17:09:48 +010034 mbedtls_psa_hash_operation_t *operation )
Steven Cooreman0e307642021-02-18 16:18:32 +010035{
Steven Cooreman83f300e2021-03-08 17:09:48 +010036 switch( operation->alg )
37 {
38 case 0:
39 /* The object has (apparently) been initialized but it is not
40 * in use. It's ok to call abort on such an object, and there's
41 * nothing to do. */
42 break;
Ronald Cron0266cfe2021-03-13 18:50:11 +010043#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
Steven Cooreman83f300e2021-03-08 17:09:48 +010044 case PSA_ALG_MD5:
45 mbedtls_md5_free( &operation->ctx.md5 );
46 break;
47#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +010048#if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
Steven Cooreman83f300e2021-03-08 17:09:48 +010049 case PSA_ALG_RIPEMD160:
50 mbedtls_ripemd160_free( &operation->ctx.ripemd160 );
51 break;
52#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +010053#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
Steven Cooreman83f300e2021-03-08 17:09:48 +010054 case PSA_ALG_SHA_1:
55 mbedtls_sha1_free( &operation->ctx.sha1 );
56 break;
57#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +010058#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
Steven Cooreman83f300e2021-03-08 17:09:48 +010059 case PSA_ALG_SHA_224:
60 mbedtls_sha256_free( &operation->ctx.sha256 );
61 break;
62#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +010063#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256)
Steven Cooreman83f300e2021-03-08 17:09:48 +010064 case PSA_ALG_SHA_256:
65 mbedtls_sha256_free( &operation->ctx.sha256 );
66 break;
67#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +010068#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
Steven Cooreman83f300e2021-03-08 17:09:48 +010069 case PSA_ALG_SHA_384:
70 mbedtls_sha512_free( &operation->ctx.sha512 );
71 break;
72#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +010073#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512)
Steven Cooreman83f300e2021-03-08 17:09:48 +010074 case PSA_ALG_SHA_512:
75 mbedtls_sha512_free( &operation->ctx.sha512 );
76 break;
77#endif
78 default:
79 return( PSA_ERROR_BAD_STATE );
80 }
81 operation->alg = 0;
82 return( PSA_SUCCESS );
Steven Cooreman0e307642021-02-18 16:18:32 +010083}
84
Ronald Cron0266cfe2021-03-13 18:50:11 +010085psa_status_t mbedtls_psa_hash_setup(
Steven Cooreman0e307642021-02-18 16:18:32 +010086 mbedtls_psa_hash_operation_t *operation,
87 psa_algorithm_t alg )
88{
89 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
90
91 /* A context must be freshly initialized before it can be set up. */
92 if( operation->alg != 0 )
93 {
94 return( PSA_ERROR_BAD_STATE );
95 }
96
97 switch( alg )
98 {
Ronald Cron0266cfe2021-03-13 18:50:11 +010099#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
Steven Cooreman0e307642021-02-18 16:18:32 +0100100 case PSA_ALG_MD5:
101 mbedtls_md5_init( &operation->ctx.md5 );
TRodziewicz26371e42021-06-08 16:45:41 +0200102 ret = mbedtls_md5_starts( &operation->ctx.md5 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100103 break;
104#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100105#if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
Steven Cooreman0e307642021-02-18 16:18:32 +0100106 case PSA_ALG_RIPEMD160:
107 mbedtls_ripemd160_init( &operation->ctx.ripemd160 );
TRodziewicz26371e42021-06-08 16:45:41 +0200108 ret = mbedtls_ripemd160_starts( &operation->ctx.ripemd160 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100109 break;
110#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100111#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
Steven Cooreman0e307642021-02-18 16:18:32 +0100112 case PSA_ALG_SHA_1:
113 mbedtls_sha1_init( &operation->ctx.sha1 );
TRodziewicz26371e42021-06-08 16:45:41 +0200114 ret = mbedtls_sha1_starts( &operation->ctx.sha1 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100115 break;
116#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100117#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
Steven Cooreman0e307642021-02-18 16:18:32 +0100118 case PSA_ALG_SHA_224:
119 mbedtls_sha256_init( &operation->ctx.sha256 );
TRodziewicz26371e42021-06-08 16:45:41 +0200120 ret = mbedtls_sha256_starts( &operation->ctx.sha256, 1 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100121 break;
122#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100123#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256)
Steven Cooreman0e307642021-02-18 16:18:32 +0100124 case PSA_ALG_SHA_256:
125 mbedtls_sha256_init( &operation->ctx.sha256 );
TRodziewicz26371e42021-06-08 16:45:41 +0200126 ret = mbedtls_sha256_starts( &operation->ctx.sha256, 0 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100127 break;
128#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100129#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
Steven Cooreman0e307642021-02-18 16:18:32 +0100130 case PSA_ALG_SHA_384:
131 mbedtls_sha512_init( &operation->ctx.sha512 );
TRodziewicz26371e42021-06-08 16:45:41 +0200132 ret = mbedtls_sha512_starts( &operation->ctx.sha512, 1 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100133 break;
134#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100135#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512)
Steven Cooreman0e307642021-02-18 16:18:32 +0100136 case PSA_ALG_SHA_512:
137 mbedtls_sha512_init( &operation->ctx.sha512 );
TRodziewicz26371e42021-06-08 16:45:41 +0200138 ret = mbedtls_sha512_starts( &operation->ctx.sha512, 0 );
Steven Cooreman0e307642021-02-18 16:18:32 +0100139 break;
140#endif
141 default:
142 return( PSA_ALG_IS_HASH( alg ) ?
143 PSA_ERROR_NOT_SUPPORTED :
144 PSA_ERROR_INVALID_ARGUMENT );
145 }
146 if( ret == 0 )
147 operation->alg = alg;
148 else
Ronald Cron0266cfe2021-03-13 18:50:11 +0100149 mbedtls_psa_hash_abort( operation );
Steven Cooreman0e307642021-02-18 16:18:32 +0100150 return( mbedtls_to_psa_error( ret ) );
151}
152
Ronald Cron0266cfe2021-03-13 18:50:11 +0100153psa_status_t mbedtls_psa_hash_clone(
Steven Cooreman0e307642021-02-18 16:18:32 +0100154 const mbedtls_psa_hash_operation_t *source_operation,
155 mbedtls_psa_hash_operation_t *target_operation )
156{
157 switch( source_operation->alg )
158 {
159 case 0:
160 return( PSA_ERROR_BAD_STATE );
Ronald Cron0266cfe2021-03-13 18:50:11 +0100161#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
Steven Cooreman0e307642021-02-18 16:18:32 +0100162 case PSA_ALG_MD5:
163 mbedtls_md5_clone( &target_operation->ctx.md5,
164 &source_operation->ctx.md5 );
165 break;
166#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100167#if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
Steven Cooreman0e307642021-02-18 16:18:32 +0100168 case PSA_ALG_RIPEMD160:
169 mbedtls_ripemd160_clone( &target_operation->ctx.ripemd160,
170 &source_operation->ctx.ripemd160 );
171 break;
172#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100173#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
Steven Cooreman0e307642021-02-18 16:18:32 +0100174 case PSA_ALG_SHA_1:
175 mbedtls_sha1_clone( &target_operation->ctx.sha1,
176 &source_operation->ctx.sha1 );
177 break;
178#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100179#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
Steven Cooreman0e307642021-02-18 16:18:32 +0100180 case PSA_ALG_SHA_224:
181 mbedtls_sha256_clone( &target_operation->ctx.sha256,
182 &source_operation->ctx.sha256 );
183 break;
184#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100185#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256)
Steven Cooreman0e307642021-02-18 16:18:32 +0100186 case PSA_ALG_SHA_256:
187 mbedtls_sha256_clone( &target_operation->ctx.sha256,
188 &source_operation->ctx.sha256 );
189 break;
190#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100191#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
Steven Cooreman0e307642021-02-18 16:18:32 +0100192 case PSA_ALG_SHA_384:
193 mbedtls_sha512_clone( &target_operation->ctx.sha512,
194 &source_operation->ctx.sha512 );
195 break;
196#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100197#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512)
Steven Cooreman0e307642021-02-18 16:18:32 +0100198 case PSA_ALG_SHA_512:
199 mbedtls_sha512_clone( &target_operation->ctx.sha512,
200 &source_operation->ctx.sha512 );
201 break;
202#endif
203 default:
Steven Cooreman5adf52c2021-03-04 18:09:49 +0100204 (void) source_operation;
205 (void) target_operation;
Steven Cooreman0e307642021-02-18 16:18:32 +0100206 return( PSA_ERROR_NOT_SUPPORTED );
207 }
208
209 target_operation->alg = source_operation->alg;
210 return( PSA_SUCCESS );
211}
212
Ronald Cron0266cfe2021-03-13 18:50:11 +0100213psa_status_t mbedtls_psa_hash_update(
Steven Cooreman0e307642021-02-18 16:18:32 +0100214 mbedtls_psa_hash_operation_t *operation,
215 const uint8_t *input,
216 size_t input_length )
217{
218 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
219
Steven Cooreman0e307642021-02-18 16:18:32 +0100220 switch( operation->alg )
221 {
Ronald Cron0266cfe2021-03-13 18:50:11 +0100222#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
Steven Cooreman0e307642021-02-18 16:18:32 +0100223 case PSA_ALG_MD5:
TRodziewicz26371e42021-06-08 16:45:41 +0200224 ret = mbedtls_md5_update( &operation->ctx.md5,
Steven Cooreman0e307642021-02-18 16:18:32 +0100225 input, input_length );
226 break;
227#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100228#if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
Steven Cooreman0e307642021-02-18 16:18:32 +0100229 case PSA_ALG_RIPEMD160:
TRodziewicz26371e42021-06-08 16:45:41 +0200230 ret = mbedtls_ripemd160_update( &operation->ctx.ripemd160,
Steven Cooreman0e307642021-02-18 16:18:32 +0100231 input, input_length );
232 break;
233#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100234#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
Steven Cooreman0e307642021-02-18 16:18:32 +0100235 case PSA_ALG_SHA_1:
TRodziewicz26371e42021-06-08 16:45:41 +0200236 ret = mbedtls_sha1_update( &operation->ctx.sha1,
Steven Cooreman0e307642021-02-18 16:18:32 +0100237 input, input_length );
238 break;
239#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100240#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
Steven Cooreman0e307642021-02-18 16:18:32 +0100241 case PSA_ALG_SHA_224:
TRodziewicz26371e42021-06-08 16:45:41 +0200242 ret = mbedtls_sha256_update( &operation->ctx.sha256,
Steven Cooreman0e307642021-02-18 16:18:32 +0100243 input, input_length );
244 break;
245#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100246#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256)
Steven Cooreman0e307642021-02-18 16:18:32 +0100247 case PSA_ALG_SHA_256:
TRodziewicz26371e42021-06-08 16:45:41 +0200248 ret = mbedtls_sha256_update( &operation->ctx.sha256,
Steven Cooreman0e307642021-02-18 16:18:32 +0100249 input, input_length );
250 break;
251#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100252#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
Steven Cooreman0e307642021-02-18 16:18:32 +0100253 case PSA_ALG_SHA_384:
TRodziewicz26371e42021-06-08 16:45:41 +0200254 ret = mbedtls_sha512_update( &operation->ctx.sha512,
Steven Cooreman0e307642021-02-18 16:18:32 +0100255 input, input_length );
256 break;
257#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100258#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512)
Steven Cooreman0e307642021-02-18 16:18:32 +0100259 case PSA_ALG_SHA_512:
TRodziewicz26371e42021-06-08 16:45:41 +0200260 ret = mbedtls_sha512_update( &operation->ctx.sha512,
Steven Cooreman0e307642021-02-18 16:18:32 +0100261 input, input_length );
262 break;
263#endif
264 default:
Steven Cooreman5adf52c2021-03-04 18:09:49 +0100265 (void) input;
266 (void) input_length;
Steven Cooreman0e307642021-02-18 16:18:32 +0100267 return( PSA_ERROR_BAD_STATE );
268 }
269
Steven Cooreman0e307642021-02-18 16:18:32 +0100270 return( mbedtls_to_psa_error( ret ) );
271}
272
Ronald Cron0266cfe2021-03-13 18:50:11 +0100273psa_status_t mbedtls_psa_hash_finish(
Steven Cooreman0e307642021-02-18 16:18:32 +0100274 mbedtls_psa_hash_operation_t *operation,
275 uint8_t *hash,
276 size_t hash_size,
277 size_t *hash_length )
278{
279 psa_status_t status;
280 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
281 size_t actual_hash_length = PSA_HASH_LENGTH( operation->alg );
282
283 /* Fill the output buffer with something that isn't a valid hash
284 * (barring an attack on the hash and deliberately-crafted input),
285 * in case the caller doesn't check the return status properly. */
286 *hash_length = hash_size;
287 /* If hash_size is 0 then hash may be NULL and then the
288 * call to memset would have undefined behavior. */
289 if( hash_size != 0 )
290 memset( hash, '!', hash_size );
291
292 if( hash_size < actual_hash_length )
293 {
294 status = PSA_ERROR_BUFFER_TOO_SMALL;
295 goto exit;
296 }
297
298 switch( operation->alg )
299 {
Ronald Cron0266cfe2021-03-13 18:50:11 +0100300#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
Steven Cooreman0e307642021-02-18 16:18:32 +0100301 case PSA_ALG_MD5:
TRodziewicz26371e42021-06-08 16:45:41 +0200302 ret = mbedtls_md5_finish( &operation->ctx.md5, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100303 break;
304#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100305#if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
Steven Cooreman0e307642021-02-18 16:18:32 +0100306 case PSA_ALG_RIPEMD160:
TRodziewicz26371e42021-06-08 16:45:41 +0200307 ret = mbedtls_ripemd160_finish( &operation->ctx.ripemd160, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100308 break;
309#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100310#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
Steven Cooreman0e307642021-02-18 16:18:32 +0100311 case PSA_ALG_SHA_1:
TRodziewicz26371e42021-06-08 16:45:41 +0200312 ret = mbedtls_sha1_finish( &operation->ctx.sha1, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100313 break;
314#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100315#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
Steven Cooreman0e307642021-02-18 16:18:32 +0100316 case PSA_ALG_SHA_224:
TRodziewicz26371e42021-06-08 16:45:41 +0200317 ret = mbedtls_sha256_finish( &operation->ctx.sha256, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100318 break;
319#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100320#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256)
Steven Cooreman0e307642021-02-18 16:18:32 +0100321 case PSA_ALG_SHA_256:
TRodziewicz26371e42021-06-08 16:45:41 +0200322 ret = mbedtls_sha256_finish( &operation->ctx.sha256, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100323 break;
324#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100325#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
Steven Cooreman0e307642021-02-18 16:18:32 +0100326 case PSA_ALG_SHA_384:
TRodziewicz26371e42021-06-08 16:45:41 +0200327 ret = mbedtls_sha512_finish( &operation->ctx.sha512, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100328 break;
329#endif
Ronald Cron0266cfe2021-03-13 18:50:11 +0100330#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512)
Steven Cooreman0e307642021-02-18 16:18:32 +0100331 case PSA_ALG_SHA_512:
TRodziewicz26371e42021-06-08 16:45:41 +0200332 ret = mbedtls_sha512_finish( &operation->ctx.sha512, hash );
Steven Cooreman0e307642021-02-18 16:18:32 +0100333 break;
334#endif
335 default:
Steven Cooreman5adf52c2021-03-04 18:09:49 +0100336 (void) hash;
Steven Cooreman0e307642021-02-18 16:18:32 +0100337 return( PSA_ERROR_BAD_STATE );
338 }
339 status = mbedtls_to_psa_error( ret );
340
341exit:
342 if( status == PSA_SUCCESS )
Steven Cooreman0e307642021-02-18 16:18:32 +0100343 *hash_length = actual_hash_length;
Steven Cooreman61bb8fc2021-03-15 12:32:48 +0100344 return( status );
Steven Cooreman0e307642021-02-18 16:18:32 +0100345}
346
Ronald Cron0266cfe2021-03-13 18:50:11 +0100347psa_status_t mbedtls_psa_hash_compute(
Steven Cooreman83f300e2021-03-08 17:09:48 +0100348 psa_algorithm_t alg,
349 const uint8_t *input,
350 size_t input_length,
351 uint8_t *hash,
352 size_t hash_size,
353 size_t *hash_length)
354{
355 mbedtls_psa_hash_operation_t operation = MBEDTLS_PSA_HASH_OPERATION_INIT;
356 psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
Steven Cooreman61bb8fc2021-03-15 12:32:48 +0100357 psa_status_t abort_status = PSA_ERROR_CORRUPTION_DETECTED;
Steven Cooreman83f300e2021-03-08 17:09:48 +0100358
359 *hash_length = hash_size;
Ronald Cron0266cfe2021-03-13 18:50:11 +0100360 status = mbedtls_psa_hash_setup( &operation, alg );
Steven Cooreman83f300e2021-03-08 17:09:48 +0100361 if( status != PSA_SUCCESS )
362 goto exit;
Ronald Cron0266cfe2021-03-13 18:50:11 +0100363 status = mbedtls_psa_hash_update( &operation, input, input_length );
Steven Cooreman83f300e2021-03-08 17:09:48 +0100364 if( status != PSA_SUCCESS )
365 goto exit;
Ronald Cron0266cfe2021-03-13 18:50:11 +0100366 status = mbedtls_psa_hash_finish( &operation, hash, hash_size, hash_length );
Steven Cooreman83f300e2021-03-08 17:09:48 +0100367 if( status != PSA_SUCCESS )
368 goto exit;
369
370exit:
Ronald Cron0266cfe2021-03-13 18:50:11 +0100371 abort_status = mbedtls_psa_hash_abort( &operation );
Steven Cooreman83f300e2021-03-08 17:09:48 +0100372 if( status == PSA_SUCCESS )
Steven Cooreman61bb8fc2021-03-15 12:32:48 +0100373 return( abort_status );
Steven Cooreman83f300e2021-03-08 17:09:48 +0100374 else
Steven Cooreman61bb8fc2021-03-15 12:32:48 +0100375 return( status );
376
Steven Cooreman83f300e2021-03-08 17:09:48 +0100377}
Steven Cooreman0d586662021-03-08 20:28:18 +0100378#endif /* MBEDTLS_PSA_BUILTIN_HASH */
Steven Cooreman0e307642021-02-18 16:18:32 +0100379
Steven Cooreman0e307642021-02-18 16:18:32 +0100380#endif /* MBEDTLS_PSA_CRYPTO_C */