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 /** Datagram Transport Layer Security (DTLS) */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define NX_SECURE_SOURCE_CODE
24
25 #include "nx_secure_dtls.h"
26
27 /**************************************************************************/
28 /* */
29 /* FUNCTION RELEASE */
30 /* */
31 /* _nxe_secure_dtls_psk_add PORTABLE C */
32 /* 6.1 */
33 /* AUTHOR */
34 /* */
35 /* Timothy Stapko, Microsoft Corporation */
36 /* */
37 /* DESCRIPTION */
38 /* */
39 /* This function checks for errors in DTLS PSK key add call. */
40 /* */
41 /* INPUT */
42 /* */
43 /* dtls_session Pointer to DTLS Session */
44 /* pre_shared_key Pointer to PSK data */
45 /* psk_length Length of PSK data */
46 /* psk_identity PSK identity data */
47 /* identity_length Length of identity data */
48 /* hint PSK hint data */
49 /* hint_length Length of hint data */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* status Completion status */
54 /* */
55 /* CALLS */
56 /* */
57 /* _nx_secure_dtls_psk_add The actual DTLS PSK add call. */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* Application Code */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
68 /* 09-30-2020 Timothy Stapko Modified comment(s), */
69 /* resulting in version 6.1 */
70 /* */
71 /**************************************************************************/
72 #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE)
_nxe_secure_dtls_psk_add(NX_SECURE_DTLS_SESSION * dtls_session,UCHAR * pre_shared_key,UINT psk_length,UCHAR * psk_identity,UINT identity_length,UCHAR * hint,UINT hint_length)73 UINT _nxe_secure_dtls_psk_add(NX_SECURE_DTLS_SESSION *dtls_session, UCHAR *pre_shared_key,
74 UINT psk_length, UCHAR *psk_identity, UINT identity_length, UCHAR *hint,
75 UINT hint_length)
76 {
77 #ifdef NX_SECURE_ENABLE_DTLS
78 UINT status;
79
80 if(dtls_session == NX_NULL)
81 {
82 return(NX_PTR_ERROR);
83 }
84
85 /* Make sure the session is initialized. */
86 if(dtls_session->nx_secure_dtls_tls_session.nx_secure_tls_id != NX_SECURE_TLS_ID)
87 {
88 return(NX_SECURE_TLS_SESSION_UNINITIALIZED);
89 }
90
91 /* Call actual function. */
92 status = _nx_secure_dtls_psk_add(dtls_session, pre_shared_key, psk_length, psk_identity, identity_length, hint, hint_length);
93
94 return(status);
95 #else
96 NX_PARAMETER_NOT_USED(dtls_session);
97 NX_PARAMETER_NOT_USED(pre_shared_key);
98 NX_PARAMETER_NOT_USED(psk_length);
99 NX_PARAMETER_NOT_USED(psk_identity);
100 NX_PARAMETER_NOT_USED(identity_length);
101 NX_PARAMETER_NOT_USED(hint);
102 NX_PARAMETER_NOT_USED(hint_length);
103
104 return(NX_NOT_SUPPORTED);
105 #endif /* NX_SECURE_ENABLE_DTLS */
106 }
107 #endif
108
109