1
10
13
14
20
21
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
82
83
84
90
91
93
94
95
96
97
103
104
105
106
107
121
122
123
125
127
128
129
133
138
139
140
144
145
146
151
152
153
154
...
...
...
#define NX_SECURE_SOURCE_CODE
#include "nx_secure_tls.h"
...
...
UINT _nx_secure_tls_session_iv_size_get(NX_SECURE_TLS_SESSION *tls_session, USHORT *iv_size)
{
const NX_CRYPTO_METHOD *session_cipher_method;
UINT algorithm;
/* ... */
if (tls_session -> nx_secure_tls_local_session_active)
{
if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL)
{
return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE);
}if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) { ... }
/* ... */
session_cipher_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_session_cipher;
algorithm = session_cipher_method -> nx_crypto_algorithm;
#ifdef NX_SECURE_ENABLE_AEAD_CIPHER
if (NX_SECURE_AEAD_CIPHER_CHECK(algorithm))
{
algorithm = NX_CRYPTO_ENCRYPTION_AES_GCM_16;
}if (NX_SECURE_AEAD_CIPHER_CHECK(algorithm)) { ... }
/* ... */#endif
switch (algorithm)
{
case NX_CRYPTO_ENCRYPTION_AES_CBC:
/* ... */
if (tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0)
{
*iv_size = (session_cipher_method -> nx_crypto_IV_size_in_bits >> 3);
}if (tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0) { ... }
else
{
*iv_size = 0;
}else { ... }
break;
#ifdef NX_SECURE_ENABLE_AEAD_CIPHERcase NX_CRYPTO_ENCRYPTION_AES_CBC:
case NX_CRYPTO_ENCRYPTION_AES_CCM_8:
case NX_CRYPTO_ENCRYPTION_AES_CCM_8:
case NX_CRYPTO_ENCRYPTION_AES_CCM_12:
case NX_CRYPTO_ENCRYPTION_AES_CCM_12:
case NX_CRYPTO_ENCRYPTION_AES_CCM_16:
case NX_CRYPTO_ENCRYPTION_AES_CCM_16:
case NX_CRYPTO_ENCRYPTION_AES_GCM_16:
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
if (tls_session -> nx_secure_tls_1_3)
{
*iv_size = 0;
}if (tls_session -> nx_secure_tls_1_3) { ... }
else
#endif
{
*iv_size = 8;
}else { ... }
break;/* ... */
#endif
default:
*iv_size = 0;
break;default
}switch (algorithm) { ... }
}if (tls_session -> nx_secure_tls_local_session_active) { ... }
else
{
*iv_size = 0;
}else { ... }
return(NX_SUCCESS);
}{ ... }