Skip to content

Commit d31cb86

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 2c33aea commit d31cb86

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
@@ -110,6 +110,17 @@ typedef struct {
110110
uint64_t bitfield;
111111
} seqnum_t;
112112

113+
/* Maximum CID length. */
114+
#ifndef DTLS_MAX_CID_LENGTH
115+
#define DTLS_MAX_CID_LENGTH 16
116+
#endif
117+
118+
#if (DTLS_MAX_CID_LENGTH > 0)
119+
#ifndef DTLS_USE_CID_DEFAULT
120+
#define DTLS_USE_CID_DEFAULT 1
121+
#endif /* DTLS_USE_CID_DEFAULT */
122+
#endif /* DTLS_MAX_CID_LENGTH > 0 */
123+
113124
typedef struct {
114125
dtls_compression_t compression; /**< compression method */
115126

@@ -124,7 +135,12 @@ typedef struct {
124135
* access the components of the key block.
125136
*/
126137
uint8 key_block[MAX_KEYBLOCK_LENGTH];
127-
138+
139+
#if (DTLS_MAX_CID_LENGTH > 0)
140+
uint8_t write_cid[DTLS_MAX_CID_LENGTH];
141+
uint8_t write_cid_length;
142+
#endif /* DTLS_MAX_CID_LENGTH > 0 */
143+
128144
seqnum_t cseq; /**<sequence number of last record received*/
129145
} dtls_security_parameters_t;
130146

@@ -141,6 +157,9 @@ typedef struct dtls_user_parameters_t {
141157
dtls_cipher_t cipher_suites[DTLS_MAX_CIPHER_SUITES + 1];
142158
unsigned int force_extended_master_secret:1; /** force extended master secret extension (RFC7627) */
143159
unsigned int force_renegotiation_info:1; /** force renegotiation info extension (RFC5746) */
160+
#if (DTLS_MAX_CID_LENGTH > 0)
161+
unsigned int support_cid:1; /** indicate CID support (RFC9146) */
162+
#endif
144163
} dtls_user_parameters_t;
145164

146165
typedef struct {
@@ -158,6 +177,12 @@ typedef struct {
158177
dtls_compression_t compression; /**< compression method */
159178
dtls_user_parameters_t user_parameters; /**< user parameters */
160179
dtls_cipher_index_t cipher_index; /**< internal index for cipher_suite_params, DTLS_CIPHER_INDEX_NULL for TLS_NULL_WITH_NULL_NULL */
180+
181+
#if (DTLS_MAX_CID_LENGTH > 0)
182+
uint8_t write_cid[DTLS_MAX_CID_LENGTH];
183+
uint8_t write_cid_length;
184+
#endif /* DTLS_MAX_CID_LENGTH > 0 */
185+
161186
unsigned int do_client_auth:1;
162187
unsigned int extended_master_secret:1;
163188
unsigned int renegotiation_info:1;

0 commit comments

Comments
 (0)