1
10
13
14
20
21
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
100
101
102
103
104
105
106
107
108
109
110
111
112
113
115
116
117
118
119
120
121
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
...
...
#if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE)
UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_SESSION *tls_session, UCHAR **psk_data, UINT *psk_length,
UCHAR *psk_identity_hint, UINT identity_length, UINT *psk_store_index)
{
UINT psk_list_size;
UINT compare_val;
UINT i;
tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
psk_list_size = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_count;
if ((psk_identity_hint[0] == 0) && (psk_list_size > 0))
{
*psk_data = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data;
*psk_length = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data_size;
if(psk_store_index != NX_NULL)
{
*psk_store_index = 0;
}if (psk_store_index != NX_NULL) { ... }
tx_mutex_put(&_nx_secure_tls_protection);
return(NX_SUCCESS);
}if ((psk_identity_hint[0] == 0) && (psk_list_size > 0)) { ... }
for (i = 0; i < psk_list_size; ++i)
{
compare_val = (UINT)NX_SECURE_MEMCMP(tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint, psk_identity_hint, identity_length);
/* ... */
if (compare_val == 0 && identity_length == tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint_size)
{
*psk_data = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_data;
*psk_length = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_data_size;
if(psk_store_index != NX_NULL)
{
*psk_store_index = i;
}if (psk_store_index != NX_NULL) { ... }
tx_mutex_put(&_nx_secure_tls_protection);
return(NX_SUCCESS);
}if (compare_val == 0 && identity_length == tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint_size) { ... }
}for (i = 0; i < psk_list_size; ++i) { ... }
tx_mutex_put(&_nx_secure_tls_protection);
return(NX_SECURE_TLS_NO_MATCHING_PSK);
}_nx_secure_tls_psk_find (NX_SECURE_TLS_SESSION *tls_session, UCHAR **psk_data, UINT *psk_length, UCHAR *psk_identity_hint, UINT identity_length, UINT *psk_store_index) { ... }
/* ... */#endif...