crypto_helper.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022-2025, Texas Instruments Incorporated
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef CRYPTO_HELPER_H
19 #define CRYPTO_HELPER_H
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
25 
27 #include <ti/drivers/ECDH.h>
28 #include <ti/drivers/ECDSA.h>
29 
30 #include <ti/devices/DeviceFamily.h>
31 
32 /* Error mapping functions. These functions take as input SimpleLink driver
33  * error codes and maps them to nearest PSA error code.
34  */
35 psa_status_t map_AES_status(int_fast16_t status);
36 psa_status_t map_ECDH_status(int_fast16_t status);
37 psa_status_t map_ECDSA_status(int_fast16_t status, bool isVerifyOp);
38 psa_status_t map_EDDSA_status(int_fast16_t status, bool isVerifyOp);
39 psa_status_t map_RNG_status(int_fast16_t status);
40 psa_status_t map_SHA2_status(int_fast16_t status);
41 psa_status_t map_TRNG_status(int_fast16_t status);
42 
43 /* Convert to and from the keyID format expected by the SimpleLink KeyStore API */
46 
47 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX) || defined(DeviceFamily_CC35XX))
48 /* Maps PSA ECC key types to their corresponding ECDSA Curve Type for HSM.
49  * Assumes that the keyType is some form of ECC key type. Returns 0 if could not
50  * find a mapping.
51  */
53 
54 /* Maps PSA ECC key types to their corresponding ECDH Curve Type for HSM.
55  * Assumes that the keyType is some form of ECC key type. Returns 0 if could not
56  * find a mapping.
57  */
59 #endif
60 
61 /* Maps PSA ECC key types to their corresponding ECCParams_CurveParams struct
62  * pointer. Assumes that the keyType is some form of ECC key type. Returns NULL
63  * if could not find a mapping.
64  */
65 const ECCParams_CurveParams *map_keyTypeToECCParams(psa_key_type_t keyType, size_t keyBits);
66 
67 #endif /* CRYPTO_HELPER_H */
ECDSA_CurveType
mbedtls_svc_key_id_t toKeyStoreKeyID(psa_key_id_t keyID)
ECDH_CurveType
Platform Security Architecture cryptography module.
uint32_t psa_key_id_t
Definition: crypto_types.h:298
psa_status_t map_AES_status(int_fast16_t status)
ECDH_CurveType map_keyTypeToECDHCurveTypeHSM(psa_key_type_t keyType, size_t keyBits)
psa_status_t map_TRNG_status(int_fast16_t status)
psa_status_t map_EDDSA_status(int_fast16_t status, bool isVerifyOp)
psa_status_t map_SHA2_status(int_fast16_t status)
psa_status_t map_ECDH_status(int_fast16_t status)
psa_key_id_t toKeyID(mbedtls_svc_key_id_t keystoreKeyID)
Definition: crypto_types.h:353
psa_status_t map_ECDSA_status(int_fast16_t status, bool isVerifyOp)
psa_status_t map_RNG_status(int_fast16_t status)
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:101
ECDSA_CurveType map_keyTypeToECDSACurveTypeHSM(psa_key_type_t keyType, size_t keyBits)
const ECCParams_CurveParams * map_keyTypeToECCParams(psa_key_type_t keyType, size_t keyBits)
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:82
© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale