Mistake on this page?
Report an issue in GitHub or email us
mbedtls_ecc_group_to_psa.h
Go to the documentation of this file.
1 /**
2  * \file mbedtls_ecc_group_to_psa.h
3  *
4  * Excerpted from Mbed TLS for internal use by Mbed TLS's PK module to
5  * interface with generic PSA Crypto implementations.
6  *
7  */
8 /*
9  * Copyright The Mbed TLS Contributors
10  * SPDX-License-Identifier: Apache-2.0
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License"); you may
13  * not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
20  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef MBEDTLS_ECC_GROUP_TO_PSA_H
26 #define MBEDTLS_ECC_GROUP_TO_PSA_H
27 
28 //#include "mbedtls/platform_util.h"
29 
30 //#include "crypto_compat.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /** \defgroup psa_tls_helpers TLS helper functions
37  * @{
38  */
39 
40 #if defined(MBEDTLS_ECP_C)
41 #include <mbedtls/ecp.h>
42 
43 /** Convert an ECC curve identifier from the Mbed TLS encoding to PSA.
44  *
45  * \note This function is provided solely for the convenience of
46  * Mbed TLS and may be removed at any time without notice.
47  *
48  * \param grpid An Mbed TLS elliptic curve identifier
49  * (`MBEDTLS_ECP_DP_xxx`).
50  * \param[out] bits On success, the bit size of the curve.
51  *
52  * \return The corresponding PSA elliptic curve identifier
53  * (`PSA_ECC_FAMILY_xxx`).
54  * \return \c 0 on failure (\p grpid is not recognized).
55  */
56 static inline psa_ecc_family_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
57  size_t *bits )
58 {
59  switch( grpid )
60  {
61  case MBEDTLS_ECP_DP_SECP192R1:
62  *bits = 192;
63  return( PSA_ECC_FAMILY_SECP_R1 );
64  case MBEDTLS_ECP_DP_SECP224R1:
65  *bits = 224;
66  return( PSA_ECC_FAMILY_SECP_R1 );
67  case MBEDTLS_ECP_DP_SECP256R1:
68  *bits = 256;
69  return( PSA_ECC_FAMILY_SECP_R1 );
70  case MBEDTLS_ECP_DP_SECP384R1:
71  *bits = 384;
72  return( PSA_ECC_FAMILY_SECP_R1 );
73  case MBEDTLS_ECP_DP_SECP521R1:
74  *bits = 521;
75  return( PSA_ECC_FAMILY_SECP_R1 );
76  case MBEDTLS_ECP_DP_BP256R1:
77  *bits = 256;
79  case MBEDTLS_ECP_DP_BP384R1:
80  *bits = 384;
82  case MBEDTLS_ECP_DP_BP512R1:
83  *bits = 512;
85  case MBEDTLS_ECP_DP_CURVE25519:
86  *bits = 255;
87  return( PSA_ECC_FAMILY_MONTGOMERY );
88  case MBEDTLS_ECP_DP_SECP192K1:
89  *bits = 192;
90  return( PSA_ECC_FAMILY_SECP_K1 );
91  case MBEDTLS_ECP_DP_SECP224K1:
92  *bits = 224;
93  return( PSA_ECC_FAMILY_SECP_K1 );
94  case MBEDTLS_ECP_DP_SECP256K1:
95  *bits = 256;
96  return( PSA_ECC_FAMILY_SECP_K1 );
97  case MBEDTLS_ECP_DP_CURVE448:
98  *bits = 448;
99  return( PSA_ECC_FAMILY_MONTGOMERY );
100  default:
101  *bits = 0;
102  return( 0 );
103  }
104 }
105 
106 #endif /* MBEDTLS_ECP_C */
107 
108 /**@}*/
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* MBEDTLS_ECC_GROUP_TO_PSA_H */
#define PSA_ECC_FAMILY_MONTGOMERY
Curve25519 and Curve448.
#define PSA_ECC_FAMILY_BRAINPOOL_P_R1
Brainpool P random curves.
#define PSA_ECC_FAMILY_SECP_R1
SEC random curves over prime fields.
#define PSA_ECC_FAMILY_SECP_K1
SEC Koblitz curves over prime fields.
uint8_t psa_ecc_family_t
The type of PSA elliptic curve family identifiers.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.