Skip to content

Commit 20d24fe

Browse files
committed
Add client dtls connection ID.
Simple client side implementation indicates support and uses the cid of the server, when negotiated by that. Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
1 parent 1f1bc2a commit 20d24fe

4 files changed

Lines changed: 198 additions & 52 deletions

File tree

crypto.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ typedef struct {
113113
uint64_t bitfield;
114114
} seqnum_t;
115115

116+
/* Maximum CID length. */
117+
#ifndef DTLS_MAX_CID_LENGTH
118+
#define DTLS_MAX_CID_LENGTH 16
119+
#endif
120+
121+
#if (DTLS_MAX_CID_LENGTH > 0)
122+
#ifndef DTLS_USE_CID_DEFAULT
123+
#define DTLS_USE_CID_DEFAULT 1
124+
#endif /* DTLS_USE_CID_DEFAULT */
125+
#endif /* DTLS_MAX_CID_LENGTH > 0 */
126+
116127
typedef struct {
117128
dtls_compression_t compression; /**< compression method */
118129

@@ -127,7 +138,12 @@ typedef struct {
127138
* access the components of the key block.
128139
*/
129140
uint8 key_block[MAX_KEYBLOCK_LENGTH];
130-
141+
142+
#if (DTLS_MAX_CID_LENGTH > 0)
143+
uint8_t write_cid[DTLS_MAX_CID_LENGTH];
144+
uint8_t write_cid_length;
145+
#endif /* DTLS_MAX_CID_LENGTH > 0 */
146+
131147
seqnum_t cseq; /**<sequence number of last record received*/
132148
} dtls_security_parameters_t;
133149

@@ -148,6 +164,9 @@ typedef struct dtls_user_parameters_t {
148164
dtls_cipher_t cipher_suites[DTLS_MAX_CIPHER_SUITES + 1];
149165
unsigned int force_extended_master_secret:1; /** force extended master secret extension (RFC7627) */
150166
unsigned int force_renegotiation_info:1; /** force renegotiation info extension (RFC5746) */
167+
#if (DTLS_MAX_CID_LENGTH > 0)
168+
unsigned int support_cid:1; /** indicate CID support (RFC9146) */
169+
#endif
151170
} dtls_user_parameters_t;
152171

153172
typedef struct {
@@ -165,6 +184,12 @@ typedef struct {
165184
dtls_compression_t compression; /**< compression method */
166185
dtls_user_parameters_t user_parameters; /**< user parameters */
167186
dtls_cipher_index_t cipher_index; /**< internal index for cipher_suite_params, DTLS_CIPHER_INDEX_NULL for TLS_NULL_WITH_NULL_NULL */
187+
188+
#if (DTLS_MAX_CID_LENGTH > 0)
189+
uint8_t write_cid[DTLS_MAX_CID_LENGTH];
190+
uint8_t write_cid_length;
191+
#endif /* DTLS_MAX_CID_LENGTH > 0 */
192+
168193
unsigned int do_client_auth:1;
169194
unsigned int extended_master_secret:1;
170195
unsigned int renegotiation_info:1;

0 commit comments

Comments
 (0)