1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (C) Foundries Ltd. 2020 - All Rights Reserved
4  * Author: Jorge Ramirez <jorge@foundries.io>
5  */
6 
7 #include <crypto/crypto_se.h>
8 #include <config.h>
9 #include <se050.h>
10 
crypto_se_enable_scp03(bool rotate_keys)11 TEE_Result crypto_se_enable_scp03(bool rotate_keys)
12 {
13 	sss_status_t status = kStatus_SSS_Success;
14 
15 	status = se050_enable_scp03(se050_session);
16 	if (status != kStatus_SSS_Success)
17 		return TEE_ERROR_GENERIC;
18 
19 	if (rotate_keys) {
20 		if (IS_ENABLED(CFG_CORE_SE05X_SCP03_PROVISION)) {
21 			status = se050_rotate_scp03_keys(&se050_ctx);
22 			if (status != kStatus_SSS_Success)
23 				return TEE_ERROR_GENERIC;
24 
25 			return TEE_SUCCESS;
26 		}
27 		return TEE_ERROR_BAD_PARAMETERS;
28 	}
29 	return TEE_SUCCESS;
30 }
31