1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Secure Component                                                 */
17 /**                                                                       */
18 /**    Transport Layer Security (TLS)                                     */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SECURE_SOURCE_CODE
24 
25 #include "nx_secure_tls.h"
26 
27 #ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
28 
29 #ifndef NX_SECURE_DISABLE_X509
30 /* Supported named curves. */
31 extern const USHORT *_nx_secure_x509_ecc_supported_groups;
32 
33 /* Number of supported named curves. */
34 extern USHORT  _nx_secure_x509_ecc_supported_groups_count;
35 
36 /* Corresponding crypto methods for the supported named curve. */
37 extern const NX_CRYPTO_METHOD **_nx_secure_x509_ecc_curves;
38 #endif
39 
40 /**************************************************************************/
41 /*                                                                        */
42 /*  FUNCTION                                               RELEASE        */
43 /*                                                                        */
44 /*    _nx_secure_tls_ecc_initialize                       PORTABLE C      */
45 /*                                                           6.1.6        */
46 /*  AUTHOR                                                                */
47 /*                                                                        */
48 /*    Timothy Stapko, Microsoft Corporation                               */
49 /*                                                                        */
50 /*  DESCRIPTION                                                           */
51 /*                                                                        */
52 /*    This function initializes supported curve lists for TLS.            */
53 /*                                                                        */
54 /*  INPUT                                                                 */
55 /*                                                                        */
56 /*    tls_session                           TLS control block             */
57 /*    supported_groups                      List of supported groups      */
58 /*    supported_group_count                 Number of supported groups    */
59 /*    curves                                List of curve methods         */
60 /*                                                                        */
61 /*  OUTPUT                                                                */
62 /*                                                                        */
63 /*    status                                Completion status             */
64 /*                                                                        */
65 /*  CALLS                                                                 */
66 /*                                                                        */
67 /*    None                                                                */
68 /*                                                                        */
69 /*  CALLED BY                                                             */
70 /*                                                                        */
71 /*    Application Code                                                    */
72 /*                                                                        */
73 /*  RELEASE HISTORY                                                       */
74 /*                                                                        */
75 /*    DATE              NAME                      DESCRIPTION             */
76 /*                                                                        */
77 /*  05-19-2020     Timothy Stapko           Initial Version 6.0           */
78 /*  09-30-2020     Timothy Stapko           Modified comment(s),          */
79 /*                                            resulting in version 6.1    */
80 /*  04-02-2021     Timothy Stapko           Modified comment(s), added    */
81 /*                                            ECC curve table in X509,    */
82 /*                                            resulting in version 6.1.6  */
83 /*                                                                        */
84 /**************************************************************************/
_nx_secure_tls_ecc_initialize(NX_SECURE_TLS_SESSION * tls_session,const USHORT * supported_groups,USHORT supported_group_count,const NX_CRYPTO_METHOD ** curves)85 UINT _nx_secure_tls_ecc_initialize(NX_SECURE_TLS_SESSION *tls_session,
86                                    const USHORT *supported_groups, USHORT supported_group_count,
87                                    const NX_CRYPTO_METHOD **curves)
88 {
89 
90     tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_supported_groups = supported_groups;
91     tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_supported_groups_count = supported_group_count;
92     tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_curves = curves;
93 
94 #ifndef NX_SECURE_DISABLE_X509
95     _nx_secure_x509_ecc_supported_groups = supported_groups;
96     _nx_secure_x509_ecc_supported_groups_count = supported_group_count;
97     _nx_secure_x509_ecc_curves = curves;
98 #endif
99 
100     return(NX_SUCCESS);
101 }
102 #endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */
103 
104 
105