Contiki-NG
Loading...
Searching...
No Matches
edhoc-msg-handlers.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024, RISE Research Institutes of Sweden AB
3 * Copyright (c) 2020, Industrial Systems Institute (ISI), Patras, Greece
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32/**
33 * \file
34 * EDHOC message handling functions.
35 * \author
36 * Lidia Pocero <pocero@isi.gr>
37 * Peter A Jonsson
38 * Rikard Höglund
39 * Marco Tiloca
40 * Niclas Finne <niclas.finne@ri.se>
41 * Nicolas Tsiftes <nicolas.tsiftes@ri.se>
42 */
43
44#include <assert.h>
45
46#include "edhoc-msg-handlers.h"
47#include "cose.h"
48
49#include "sys/log.h"
50#define LOG_MODULE "EDHOC"
51#define LOG_LEVEL LOG_LEVEL_EDHOC
52
53/*---------------------------------------------------------------------------*/
54static uint16_t
55decrypt_ciphertext_3(edhoc_context_t *ctx, const uint8_t *ciphertext,
56 uint16_t ciphertext_size, uint8_t *plaintext)
57{
58 uint8_t alg = ctx->config.aead_alg;
59 uint8_t key_len = cose_get_key_len(alg);
60 uint8_t iv_len = cose_get_iv_len(alg);
61 uint8_t tag_len = cose_get_tag_len(alg);
62 if(key_len == 0 || iv_len == 0 || tag_len == 0) {
63 return 0;
64 }
65
66 if(ciphertext_size > EDHOC_MAX_BUFFER) {
67 LOG_ERR("CIPHERTEXT_3 size (%u) exceeds max buffer (%d)\n",
68 (unsigned)ciphertext_size, EDHOC_MAX_BUFFER);
69 return 0;
70 }
71
72 /* Derive K_3. */
73 uint8_t key[COSE_MAX_KEY_LEN];
74 int16_t err = edhoc_kdf(ctx->state.prk_3e2m, K_3_LABEL, ctx->state.th,
75 HASH_LEN, key_len, key);
76 if(err < 1) {
77 LOG_ERR("Failed to derive K_3\n");
78 return 0;
79 }
80 LOG_DBG("K_3 (%d bytes): ", key_len);
81 LOG_DBG_BYTES(key, key_len);
82 LOG_DBG_("\n");
83
84 /* Derive IV_3. */
85 uint8_t nonce[COSE_MAX_IV_LEN];
86 err = edhoc_kdf(ctx->state.prk_3e2m, IV_3_LABEL, ctx->state.th, HASH_LEN,
87 iv_len, nonce);
88 if(err < 1) {
89 LOG_ERR("Failed to derive IV_3\n");
90 return 0;
91 }
92 LOG_DBG("IV_3 (%d bytes): ", iv_len);
93 LOG_DBG_BYTES(nonce, iv_len);
94 LOG_DBG_("\n");
95
96 /* COSE_Encrypt0: AAD is TH_3, in-place decrypt. */
97 uint8_t aead_buf[EDHOC_MAX_BUFFER];
98 memcpy(aead_buf, ciphertext, ciphertext_size);
99 size_t plaintext_sz = cose_encrypt0_open(alg, key, nonce,
100 ctx->state.th, HASH_LEN,
101 aead_buf, ciphertext_size);
102 if(plaintext_sz == 0) {
103 LOG_ERR("CIPHERTEXT_3 decryption failed\n");
104 return 0;
105 }
106
107 memcpy(plaintext, aead_buf, plaintext_sz);
108 return (uint16_t)plaintext_sz;
109}
110/*---------------------------------------------------------------------------*/
111static edhoc_error_t
112set_rx_cid(edhoc_context_t *ctx, const uint8_t *received_cid, size_t received_cid_size)
113{
114 /* set connection id from rx */
115 if(received_cid_size == 0 || received_cid_size > EDHOC_MAX_CID_LEN) {
116 LOG_ERR("Invalid CID length: %zu (max %d)\n", received_cid_size, EDHOC_MAX_CID_LEN);
118 }
119
120 memcpy(ctx->state.cid_rx, received_cid, received_cid_size);
121 ctx->state.cid_rx_len = (uint8_t)received_cid_size;
122
123 /* Check if received CID is same as own CID */
124 if(ctx->state.cid_rx_len == ctx->state.cid_len &&
125 memcmp(ctx->state.cid_rx, ctx->state.cid, ctx->state.cid_len) == 0) {
126 LOG_ERR("Received CID matches own CID (error: %d)\n", EDHOC_ERR_CID_INVALID);
128 }
129 return EDHOC_SUCCESS;
130}
131/*---------------------------------------------------------------------------*/
132static int8_t
133check_rx_suite_i(edhoc_context_t *ctx,
134 const uint8_t *received_suites, uint8_t suite_count)
135{
136 if(suite_count == 0) {
138 }
139 /* Get the selected cipher suite (last element) */
140 uint8_t peer_selected_suite = received_suites[suite_count - 1];
141
142 /* Check if the selected suite is supported */
143 for(uint8_t i = 0; i < ctx->config.suite_num; i++) {
144 if(ctx->config.suite[i] == peer_selected_suite) {
145 ctx->state.suite_selected = peer_selected_suite;
146 LOG_DBG("Selected cipher suite: %d\n", ctx->state.suite_selected);
147
148 /* Responder sets config to use based on selected suite */
149 int8_t err = edhoc_set_config_from_suite(ctx, ctx->state.suite_selected);
150 if(err != 1) {
151 LOG_WARN("Cipher suite not supported\n");
153 }
154 return 0;
155 }
156 }
157
158 LOG_WARN("Cipher suite not supported\n");
160}
161/*---------------------------------------------------------------------------*/
162static void
163set_rx_gx(edhoc_context_t *ctx, const uint8_t *gx)
164{
165 memcpy(ctx->state.gx, gx, ECC_KEY_LEN);
166}
167/*---------------------------------------------------------------------------*/
168static int8_t
169set_rx_method(edhoc_context_t *ctx, uint8_t method)
170{
171 if(method != EDHOC_METHOD) {
172 LOG_ERR("error code (%d)\n", EDHOC_ERR_METHOD_NOT_SUPPORTED);
174 }
175 ctx->config.method = method;
176 return 0;
177}
178/*---------------------------------------------------------------------------*/
179static int8_t
180set_rx_msg(edhoc_context_t *ctx, const uint8_t *message, size_t message_size)
181{
182 if(message_size > EDHOC_MAX_PAYLOAD_LEN) {
183 LOG_ERR("Message size (%zu) exceeds max payload (%d)\n", message_size, EDHOC_MAX_PAYLOAD_LEN);
185 }
186 memcpy(ctx->buffers.msg_rx, message, message_size);
187 ctx->buffers.rx_sz = message_size;
188 return 0;
189}
190/*---------------------------------------------------------------------------*/
192edhoc_check_err_rx_msg(uint8_t message, const uint8_t *data, size_t data_size)
193{
194 /* Check if the rx msg is an msg_err */
195 edhoc_msg_error_t err;
196
197 /* If deserialize_err succeeds, this IS an error message */
198 if(edhoc_deserialize_err(&err, data, data_size)) {
199 switch(edhoc_msg_error_get_code(&err)) {
200 case EDHOC_MSG_ERR_CODE_UNSPECIFIED_ERROR:
201 LOG_ERR("RX MSG %u ERR %u: ", message, edhoc_msg_error_get_code(&err));
202 size_t info_sz = edhoc_msg_error_get_info_sz(&err);
203 if(info_sz) {
204 LOG_ERR_(": ");
205 LOG_ERR_STRING(edhoc_msg_error_get_info(&err), info_sz);
206 }
207 LOG_ERR_("\n");
208 return EDHOC_ERR_MSG_MALFORMED; /* Return negative to indicate error message detected */
209 case EDHOC_MSG_ERR_CODE_WRONG_CIPHER_SUITE:
210 LOG_ERR("RX MSG %u ERROR WITH SUITE PROPOSE: ", message);
211 LOG_ERR_BYTES(edhoc_msg_error_get_suites(&err),
212 edhoc_msg_error_get_suites_num(&err));
213 LOG_ERR_("\n");
214 return EDHOC_ERR_SUITE_NOT_SUPPORTED; /* Return negative to indicate error message detected */
215 case EDHOC_MSG_ERR_CODE_UNKNOWN_CREDENTIAL_SELECTION:
216 LOG_ERR("RX MSG %u ERROR: Unknown credential referenced\n", message);
217 return EDHOC_ERR_CREDENTIAL_NOT_FOUND; /* Return negative to indicate error message detected */
218 default:
220 }
221 }
222
223 /* If deserialize_err fails, this is NOT an error message - continue normal parsing */
224 return EDHOC_SUCCESS;
225}
226/*---------------------------------------------------------------------------*/
227int
228edhoc_handler_msg_1(edhoc_context_t *ctx, uint8_t *payload,
229 size_t payload_size, uint8_t *auth_data)
230{
231 edhoc_msg_1_t msg1 = { 0 };
232 int err = 0;
233
234 /* Decode MSG1 */
235 err = set_rx_msg(ctx, payload, payload_size);
236 if(err < 0) {
237 return err;
238 }
239
240 /* Check if the rx msg is an msg_err */
241 edhoc_error_t error_status = edhoc_check_err_rx_msg(1, payload, payload_size);
242 if(error_status != EDHOC_SUCCESS) {
243 return error_status;
244 }
245
246 LOG_DBG("MSG1 (%d bytes): ", (int)ctx->buffers.rx_sz - 1);
247 LOG_DBG_BYTES((ctx->buffers.msg_rx) + 1, ctx->buffers.rx_sz - 1);
248 LOG_DBG_("\n");
249 err = edhoc_deserialize_msg_1(&msg1, (ctx->buffers.msg_rx) + 1,
250 ctx->buffers.rx_sz - 1);
251 if(err < 0) {
252 LOG_ERR("MSG1 malformed\n");
253 return err;
254 }
255 print_msg_1(&msg1);
256
257#if EDHOC_EAD_PROCESSING
258 /* Process EAD (External Authorization Data) items if present
259 * RFC 9528 Section 6: Critical EAD items that cannot be processed must trigger an error */
260 if(msg1.uad.ead_value_sz > 0 || msg1.uad.ead_label != 0) {
261 edhoc_error_t ead_result = edhoc_process_ead_item(&msg1.uad);
262 if(ead_result != EDHOC_SUCCESS) {
263 LOG_ERR("EAD processing failed for MSG_1: %d\n", ead_result);
264 return ead_result;
265 }
266 }
267#endif /* EDHOC_EAD_PROCESSING */
268
269 /* check rx suite and set connection identifier of the other peer */
270 err = check_rx_suite_i(ctx, msg1.suites_i, msg1.suites_i_num);
271 if(err < 0) {
272 LOG_ERR("Rx Suite not supported\n");
273 return err;
274 }
275
276 /* Check to not have the same cid */
277 err = set_rx_cid(ctx, msg1.c_i, msg1.c_i_sz);
278 if(err < 0) {
279 LOG_ERR("Not support cid rx\n");
280 return err;
281 }
282
283 /* Set EDHOC method */
284 err = set_rx_method(ctx, msg1.method);
285 if(err < 0) {
286 LOG_ERR("Rx Method not supported\n");
287 return err;
288 }
289
290 /* Set GX */
291 set_rx_gx(ctx, msg1.g_x);
293
294 LOG_DBG("MSG EAD (%d)", (int)msg1.uad.ead_value_sz);
295 LOG_DBG_STRING((char *)msg1.uad.ead_value, msg1.uad.ead_value_sz);
296 LOG_DBG_("\n");
297
298 if(msg1.uad.ead_value_sz != 0) {
299 if(msg1.uad.ead_value_sz > EDHOC_MAX_AD_SZ) {
300 LOG_ERR("EAD value size (%zu) exceeds max AD (%d)\n",
301 msg1.uad.ead_value_sz, EDHOC_MAX_AD_SZ);
303 }
304 memcpy(auth_data, msg1.uad.ead_value, msg1.uad.ead_value_sz);
305 }
306
307 return msg1.uad.ead_value_sz;
308}
309/*---------------------------------------------------------------------------*/
310int
311edhoc_handler_msg_2(edhoc_msg_2_t *msg2, edhoc_context_t *ctx,
312 uint8_t *payload, size_t payload_size)
313{
314 int err = 0;
315 err = set_rx_msg(ctx, payload, payload_size);
316 if(err < 0) {
317 return err;
318 }
319 edhoc_error_t error_status = edhoc_check_err_rx_msg(2, payload, payload_size);
320 if(error_status != EDHOC_SUCCESS) {
321 return error_status;
322 }
323 err = edhoc_deserialize_msg_2(msg2, ctx->buffers.msg_rx, ctx->buffers.rx_sz);
324 if(err < 0) {
325 LOG_ERR("MSG2 malformed\n");
326 return err;
327 }
328 print_msg_2(msg2);
329
330 set_rx_gx(ctx, msg2->gy_ciphertext_2);
331 edhoc_generate_transcript_hash_2(ctx, msg2->gy_ciphertext_2, ctx->buffers.msg_tx,
332 ctx->buffers.tx_sz);
334
335 /* Gen KS_2e */
336 if(msg2->gy_ciphertext_2_sz <= ECC_KEY_LEN) {
337 LOG_ERR("Invalid ciphertext size: %zu <= %d\n", msg2->gy_ciphertext_2_sz, ECC_KEY_LEN);
338 return 0;
339 }
340 int ciphertext2_sz = msg2->gy_ciphertext_2_sz - ECC_KEY_LEN;
341 if(ciphertext2_sz > EDHOC_MAX_BUFFER) {
342 LOG_ERR("Ciphertext size exceeds maximum buffer: %d > %d\n", ciphertext2_sz, EDHOC_MAX_BUFFER);
343 return 0;
344 }
345 uint8_t ks_2e[EDHOC_MAX_BUFFER];
346 edhoc_generate_keystream_2e(ctx, ciphertext2_sz, ks_2e);
347
348 /* Prepare ciphertext for decryption */
349 memcpy(ctx->buffers.plaintext, msg2->gy_ciphertext_2 + ECC_KEY_LEN,
350 ciphertext2_sz);
351 LOG_DBG("CIPHERTEXT_2 (%d bytes): ", ciphertext2_sz);
352 LOG_DBG_BYTES(ctx->buffers.plaintext, ciphertext2_sz);
353 LOG_DBG_("\n");
354
355 /* Actually decrypt the ciphertext */
356 size_t plaint_sz = edhoc_enc_dec_ciphertext_2(ctx, ks_2e,
357 ctx->buffers.plaintext,
358 ciphertext2_sz);
359 ctx->buffers.plaintext_sz = plaint_sz;
360 LOG_DBG("PLAINTEXT_2 (%zu bytes): ", plaint_sz);
361 LOG_DBG_BYTES(ctx->buffers.plaintext, plaint_sz);
362 LOG_DBG_("\n");
363
364 /* Parse C_R from beginning of plaintext_2 using CBOR */
365 cbor_reader_state_t cid_reader;
366 cbor_init_reader(&cid_reader, ctx->buffers.plaintext, ctx->buffers.plaintext_sz);
367 size_t cid_data_size;
368 const uint8_t *cid_data = edhoc_read_byte_identifier(&cid_reader, &cid_data_size);
369 if(!cid_data || cid_data_size == 0 || cid_data_size > EDHOC_MAX_CID_LEN) {
370 LOG_ERR("Invalid C_R in plaintext_2: size %zu\n", cid_data_size);
372 }
373 err = set_rx_cid(ctx, cid_data, cid_data_size);
374 if(err < 0) {
375 return err;
376 }
377 LOG_DBG("cid (%d bytes): ", ctx->state.cid_rx_len);
378 LOG_DBG_BYTES(ctx->state.cid_rx, ctx->state.cid_rx_len);
379 LOG_DBG_("\n");
380
381 return 1;
382}
383/*---------------------------------------------------------------------------*/
384int
385edhoc_handler_msg_3(edhoc_msg_3_t *msg3, edhoc_context_t *ctx,
386 uint8_t *payload, size_t payload_size)
387{
388 /* Decode MSG3 */
389 int8_t err = set_rx_msg(ctx, payload, payload_size);
390 if(err < 0) {
391 return err;
392 }
393
394 /* Check if the rx msg is an msg_err */
395 edhoc_error_t error_status = edhoc_check_err_rx_msg(3, payload, payload_size);
396 if(error_status != EDHOC_SUCCESS) {
397 return error_status;
398 }
399
400 /* Skip the first byte (C_R connection identifier) to parse CIPHERTEXT_3 */
401 err = edhoc_deserialize_msg_3(msg3, (ctx->buffers.msg_rx) + 1,
402 ctx->buffers.rx_sz - 1);
403 if(err < 0) {
404 LOG_ERR("MSG3 malformed\n");
405 return err;
406 }
407 print_msg_3(msg3);
408
409 LOG_DBG("CIPHERTEXT_3 (%d bytes): ", (int)msg3->ciphertext_3_sz);
410 LOG_DBG_BYTES(msg3->ciphertext_3, msg3->ciphertext_3_sz);
411 LOG_DBG_("\n");
412
413 /* generate TH_3 */
414 edhoc_generate_transcript_hash_3(ctx, ctx->buffers.cred_x, ctx->buffers.cred_x_sz,
415 ctx->buffers.plaintext, ctx->buffers.plaintext_sz);
416
417 /* decrypt msg3 and check the TAG for verify the outer */
418 uint16_t plaintext_sz = decrypt_ciphertext_3(ctx, msg3->ciphertext_3,
419 msg3->ciphertext_3_sz,
420 ctx->buffers.plaintext);
421 ctx->buffers.plaintext_sz = plaintext_sz;
422 if(plaintext_sz == 0) {
423 LOG_ERR("Error in decrypt ciphertext 3\n");
425 }
426 LOG_DBG("PLAINTEXT_3 (%d): ", (int)plaintext_sz);
427 LOG_DBG_BYTES(ctx->buffers.plaintext, plaintext_sz);
428 LOG_DBG_("\n");
429
430 return 1;
431}
432/*---------------------------------------------------------------------------*/
Public API declarations for COSE (RFC 9052).
edhoc_error_t
Unified error type for EDHOC operations.
Definition edhoc-error.h:60
@ EDHOC_ERR_CRYPTO_DECRYPT
Decryption operation failed.
Definition edhoc-error.h:76
@ EDHOC_ERR_CREDENTIAL_NOT_FOUND
Credential not found.
Definition edhoc-error.h:97
@ EDHOC_ERR_SUITE_NOT_SUPPORTED
Cipher suite not supported.
Definition edhoc-error.h:83
@ EDHOC_ERR_MSG_MALFORMED
Malformed message received.
Definition edhoc-error.h:84
@ EDHOC_ERR_CID_INVALID
Invalid connection identifier.
Definition edhoc-error.h:86
@ EDHOC_ERR_METHOD_NOT_SUPPORTED
EDHOC method not supported.
Definition edhoc-error.h:85
Declarations for the EDHOC message handlers.
edhoc_error_t edhoc_deserialize_msg_1(edhoc_msg_1_t *msg, unsigned char *buffer, size_t buff_sz)
Deserialize EDHOC message 1 from CBOR data.
Definition edhoc-msgs.c:299
void print_msg_3(edhoc_msg_3_t *msg)
Print EDHOC message 3 contents for debugging.
Definition edhoc-msgs.c:77
void print_msg_1(edhoc_msg_1_t *msg)
Print EDHOC message 1 contents for debugging.
Definition edhoc-msgs.c:51
const uint8_t * edhoc_read_byte_identifier(cbor_reader_state_t *reader, size_t *size)
Read byte identifier from CBOR reader.
Definition edhoc-msgs.c:85
void print_msg_2(edhoc_msg_2_t *msg)
Print EDHOC message 2 contents for debugging.
Definition edhoc-msgs.c:69
edhoc_error_t edhoc_deserialize_msg_3(edhoc_msg_3_t *msg, unsigned char *buffer, size_t buff_sz)
Deserialize EDHOC message 3 from CBOR data.
Definition edhoc-msgs.c:425
edhoc_error_t edhoc_deserialize_msg_2(edhoc_msg_2_t *msg, unsigned char *buffer, size_t buff_sz)
Deserialize EDHOC message 2 from CBOR data.
Definition edhoc-msgs.c:388
edhoc_error_t edhoc_process_ead_item(const edhoc_ead_data_t *ead_data)
Process and validate EAD (External Authorization Data) items.
Definition edhoc-msgs.c:765
bool edhoc_deserialize_err(edhoc_msg_error_t *msg, const uint8_t *data, size_t data_size)
Deserialize EDHOC error message from CBOR data.
Definition edhoc-msgs.c:227
uint8_t cose_get_key_len(uint8_t alg_id)
Get the symmetric key length for a COSE AEAD algorithm.
Definition cose.c:280
size_t cose_encrypt0_open(uint8_t alg, const uint8_t *key, const uint8_t *nonce, const uint8_t *external_aad, size_t external_aad_len, uint8_t *buf, size_t ciphertext_len)
AEAD-decrypt a buffer in place as a COSE_Encrypt0.
Definition cose.c:149
uint8_t cose_get_iv_len(uint8_t alg_id)
Get the nonce/IV length for a COSE AEAD algorithm.
Definition cose.c:294
uint8_t cose_get_tag_len(uint8_t alg_id)
Get the authentication tag length for a COSE AEAD algorithm.
Definition cose.c:308
void edhoc_print_session_info(const edhoc_context_t *ctx)
Print current EDHOC session information for debugging.
Definition edhoc.c:366
int8_t edhoc_generate_transcript_hash_2(edhoc_context_t *ctx, const uint8_t *eph_pub, uint8_t *msg, uint16_t msg_sz)
Generate transcript hash TH_2.
Definition edhoc.c:279
int8_t edhoc_set_config_from_suite(edhoc_context_t *ctx, uint8_t suite)
Set EDHOC configuration parameters based on cipher suite.
Definition edhoc.c:188
bool edhoc_generate_prk_2e(edhoc_context_t *ctx)
Generate pseudorandom key PRK_2e.
Definition edhoc.c:542
int16_t edhoc_kdf(const uint8_t *prk, uint8_t info_label, const uint8_t *context, uint8_t context_sz, uint16_t length, uint8_t *result)
EDHOC Key Derivation Function (KDF) based on HMAC-based Expand (RFC 5869).
Definition edhoc.c:373
int16_t edhoc_enc_dec_ciphertext_2(const edhoc_context_t *ctx, const uint8_t *ks_2e, uint8_t *plaintext, uint16_t plaintext_sz)
Encrypt/decrypt ciphertext 2 using XOR with keystream.
Definition edhoc.c:665
uint8_t edhoc_generate_transcript_hash_3(edhoc_context_t *ctx, const uint8_t *cred, uint16_t cred_sz, const uint8_t *plaintext, uint16_t plaintext_sz)
Generate transcript hash TH_3.
Definition edhoc.c:306
int16_t edhoc_generate_keystream_2e(edhoc_context_t *ctx, uint16_t length, uint8_t *ks_2e)
Generate keystream KS_2e for encryption.
Definition edhoc.c:561
void cbor_init_reader(cbor_reader_state_t *state, const uint8_t *cbor, size_t cbor_size)
Prepares for reading CBOR input.
Definition cbor.c:293
#define EDHOC_METHOD
Set the Authentication method.
int edhoc_handler_msg_3(edhoc_msg_3_t *msg3, edhoc_context_t *ctx, uint8_t *payload, size_t payload_size)
Handle the EDHOC Message 3 received.
#define EDHOC_MAX_AD_SZ
The max length of the Application Data.
int edhoc_handler_msg_1(edhoc_context_t *ctx, uint8_t *payload, size_t payload_size, uint8_t *auth_data)
Handle the EDHOC Message 1 received.
#define EDHOC_MAX_PAYLOAD_LEN
The max length of the EDHOC message.
int edhoc_handler_msg_2(edhoc_msg_2_t *msg2, edhoc_context_t *ctx, uint8_t *payload, size_t payload_size)
Handle the EDHOC Message 2 received.
edhoc_error_t edhoc_check_err_rx_msg(uint8_t message, const uint8_t *data, size_t data_size)
Try to deserialize data as an EDHOC error message.
#define EDHOC_MAX_BUFFER
The max size of the buffers.
#define EDHOC_MAX_CID_LEN
Maximum length of connection identifiers RFC 9528 allows variable-length CIDs including negative inte...
Header file for the logging system.
Structure of the internal state of a CBOR reader.
Definition cbor.h:130