Contiki-NG
Loading...
Searching...
No Matches
edhoc.h
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 * An implementation of Ephemeral Diffie-Hellman Over COSE (EDHOC)
35 * (RFC9528)
36 * \author
37 * Lidia Pocero <pocero@isi.gr>, Peter A Jonsson, Rikard Höglund, Marco Tiloca
38 * Christos Koulamas <cklm@isi.gr>, Niclas Finne <niclas.finne@ri.se>,
39 * Nicolas Tsiftes <nicolas.tsiftes@ri.se>
40 */
41
42/**
43 * \defgroup EDHOC An EDHOC implementation (RFC9528)
44 * @{
45 *
46 * This is an implementation of Ephemeral Diffie-Hellman Over COSE (EDHOC),
47 * a very compact and lightweight authenticated Diffie-Hellman key exchange with
48 * ephemeral keys that provides mutual authentication, perfect forward secrecy,
49 * and identity protection as described in RFC9528.
50 *
51 **/
52
53#ifndef EDHOC_H_
54#define EDHOC_H_
55
56#include "edhoc-config.h"
57#include "ecdh.h"
58#include "edhoc-msgs.h"
59#include <stdint.h>
60#include <string.h>
61
62/* EDHOC_KDF label values */
63#define KEYSTREAM_2_LABEL 0
64#define SALT_3E2M_LABEL 1
65#define MAC_2_LABEL 2
66#define K_3_LABEL 3
67#define IV_3_LABEL 4
68#define SALT_4E3M_LABEL 5
69#define MAC_3_LABEL 6
70#define PRK_OUT_LABEL 7
71#define K_4_LABEL 8
72#define IV_4_LABEL 9
73#define PRK_EXPORTER_LABEL 10
74
75#define EDHOC_MAC_2 2
76#define EDHOC_MAC_3 3
77
78typedef struct edhoc_config {
79 uint8_t role;
80 uint8_t method;
81 uint8_t suite[EDHOC_SUITES_MAX_COUNT];
82 uint8_t suite_num;
83 uint8_t aead_alg;
84 uint8_t mac_len;
85 uint8_t ecdh_curve;
86 uint8_t sign_alg;
87} edhoc_config_t;
88
89typedef struct edhoc_state {
90 uint8_t suite_selected;
91 uint8_t cid[EDHOC_MAX_CID_LEN]; /* Own connection identifier */
92 uint8_t cid_len; /* Length of own CID */
93 uint8_t cid_rx[EDHOC_MAX_CID_LEN]; /* Peer's connection identifier */
94 uint8_t cid_rx_len; /* Length of peer's CID */
95 uint8_t th[HASH_LEN];
96 uint8_t prk_2e[HASH_LEN];
97 uint8_t prk_3e2m[HASH_LEN];
98 uint8_t prk_4e3m[HASH_LEN];
99 uint8_t gx[ECC_KEY_LEN];
100} edhoc_state_t;
101
102typedef struct edhoc_buffers {
103 uint8_t msg_rx[EDHOC_MAX_PAYLOAD_LEN]; /* Receive buffer */
104 uint8_t msg_tx[EDHOC_MAX_PAYLOAD_LEN]; /* Transmit buffer */
105 uint16_t rx_sz; /* Size of received message */
106 uint16_t tx_sz; /* Size of message to transmit */
107 uint8_t plaintext[EDHOC_MAX_BUFFER]; /* Plaintext buffer (needed across message boundaries) */
108 size_t plaintext_sz;
109 uint8_t cred_x[EDHOC_MAX_CRED_LEN]; /* Credential storage */
110 size_t cred_x_sz;
111 uint8_t id_cred_x[EDHOC_MAX_ID_CRED_LEN]; /* Credential ID storage */
112 size_t id_cred_x_sz;
113} edhoc_buffers_t;
114
115typedef struct edhoc_creds {
116 cose_key_t *authen_key; /* Points to key in cred storage */
117 ecc_key_t ephemeral_key;
118} edhoc_creds_t;
119
120typedef struct edhoc_context {
121 edhoc_config_t config;
122 edhoc_state_t state;
123 edhoc_creds_t creds;
124 edhoc_buffers_t buffers;
125} edhoc_context_t;
126
127/**
128 * \brief EDHOC context struct used in the EDHOC protocol
129 */
130extern edhoc_context_t *edhoc_ctx;
131
132/**
133 * \brief Reserve memory for the EDHOC context struct
134 *
135 * Used by both Initiator and Responder EDHOC roles to reserve memory
136 */
137void edhoc_storage_init(void);
138
139/**
140 * \brief Create a new EDHOC context
141 * \relates edhoc_storage_init
142 * \return edhoc_context_t* Pointer to EDHOC context struct, or NULL on failure
143 *
144 * Used by both Initiator and Responder EDHOC roles to create a new EDHOC context
145 * and allocate at the memory reserved before with the edhoc_storage_init function
146 */
147edhoc_context_t *edhoc_new(void);
148
149/**
150 * \brief Initialize the EDHOC Context with the defined EDHOC parameters
151 * \param ctx An EDHOC context struct to fill in
152 * \return 1 on success, 0 if no supported cipher suites are configured
153 *
154 * Used in the edhoc_new to set the default protocol definitions and in the Responder to
155 * reset the initial values to prepare for a new EDHOC connection. Sets up the cipher
156 * suites selection logic and validates that at least one cipher suite is supported.
157 */
158
159uint8_t edhoc_setup_suites(edhoc_context_t *ctx);
160
161/**
162 * \brief Close the EDHOC context
163 * \param ctx EDHOC context struct
164 *
165 * Used by both Initiator and Responder EDHOC roles to de-allocate the memory reserved
166 * for the EDHOC context when EDHOC protocol finalize.
167 */
168void edhoc_finalize(edhoc_context_t *ctx);
169
170/* See edhoc-msg-generators.h for detailed documentation */
171edhoc_error_t edhoc_generate_message_1(edhoc_context_t *ctx, uint8_t *ad, size_t ad_sz, bool suite_array);
172
173/* See edhoc-msg-generators.h for detailed documentation */
174edhoc_error_t edhoc_generate_message_2(edhoc_context_t *ctx, const uint8_t *auth_data, size_t auth_data_size);
175
176/* See edhoc-msg-generators.h for detailed documentation */
177edhoc_error_t edhoc_generate_message_3(edhoc_context_t *ctx, const uint8_t *auth_data, size_t auth_data_size);
178
179/**
180 * \brief Generate the EDHOC ERROR Message
181 * \param msg_er A pointer to a buffer to copy the generated CBOR message error
182 * \param msg_er_sz The size of the destination buffer
183 * \param ctx EDHOC Context struct
184 * \param err EDHOC error number
185 * \return err_sz CBOR Message Error size
186 *
187 * An EDHOC error message can be sent by both parties as a reply to any non-error
188 * EDHOC message. If any verification step fails on the EDHOC protocol the Initiator
189 * or Responder must send an EDHOC error message back that contains a brief human-readable
190 * diagnostic message.
191 * - msg_er = (?C_x_identifier, ERR_MSG:tstr)
192 */
193uint8_t edhoc_generate_error_message(uint8_t *msg_er, size_t msg_er_sz, const edhoc_context_t *ctx, int8_t err);
194
195/**
196 * \brief Authenticate the rx message
197 * \param ctx EDHOC Context struct
198 * \param ad A pointer to a buffer to copy the Application Data of the rx message
199 * \param msg2 Determines whether the message is a Message 2
200 * \retval negative error code when an EDHOC ERROR is detected
201 * \retval ad_sz The length of the Application Data received in Message 2, when EDHOC success
202 *
203 * Used by Initiator and Responder EDHOC role to Authenticate the other party
204 * - Verify that the EDHOC Responder role identity is among the allowed if it is necessary
205 * - Verify MAC
206 * - Pass Application data AD
207 *
208 * If any verification step fails to return an EDHOC ERROR code and, if all the steps success
209 * the length of the Application Data receive on the Message is returned.
210 */
211int edhoc_authenticate_msg(edhoc_context_t *ctx, uint8_t *ad, bool msg2);
212
213/**
214 * \brief EDHOC Key Derivation Function (KDF) based on HMAC-based Expand (RFC 5869)
215 * \param result OKM (Output Keying Material) - the buffer where the derived key will be stored.
216 * \param prk PRK (Pseudorandom Key) - a pseudorandom key used as input to the key derivation, should be at least `HASH_LEN` bytes.
217 * \param info_label Label used to generate the CBOR-based info input for key derivation.
218 * \param context Context data used to generate the info input for key derivation.
219 * \param context_sz The size of the Context data.
220 * \param length Desired length of the output key material (OKM) in bytes.
221 * \return The number of output key bytes generated (equal to \p length) on success, or 0 on failure.
222 *
223 * This function combines the PRK, info_label, and context to generate an input info
224 * parameter that is used for HKDF-Expand as defined in RFC 5869. It is used by both
225 * the Initiator and Responder in the EDHOC protocol to generate keying material.
226 * Internally, this function calls `edhoc_expand` to compute the final OKM.
227 *
228 * The function performs the following steps:
229 * - Calls `generate_info` to prepare the `info` input.
230 * - Passes the PRK, generated `info`, and length to `edhoc_expand`.
231 *
232 * Example usage:
233 * - OKM = EDHOC_Expand(PRK, info, length)
234 */
235int16_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);
236
237/**
238 * \brief HMAC-based Key Expansion Function for EDHOC context using HKDF (RFC 5869)
239 * \param prk PRK (Pseudorandom Key) - a pseudorandom key used as input for the HMAC-based key derivation.
240 * \param info Additional context information used in the key derivation, which is generated from the info_label and context.
241 * \param info_sz The size of the info parameter in bytes.
242 * \param length The desired length of the output key material (OKM) in bytes.
243 * \param result OKM (Output Keying Material) - the buffer where the derived key will be stored.
244 * \return The number of output key bytes generated (equal to \p length).
245 *
246 * This function implements the HKDF-Expand function as described in RFC 5869.
247 * It takes the PRK, context info, and the desired length to produce the final key material.
248 * It calls hkdf_expand internally to perform the HMAC-based key expansion using SHA-256.
249 *
250 * The steps include:
251 * - Verifying the size of the info and output key material (OKM).
252 * - Using HMAC-Expand to expand the PRK and info into OKM.
253 * - Returning the length of the derived key or an error code in case of failure.
254 *
255 * Example usage:
256 * - OKM = HKDF-Expand(PRK, info, length)
257 */
258int16_t edhoc_expand(const uint8_t *prk, const uint8_t *info, uint16_t info_sz, uint16_t length, uint8_t *result);
259
260/**
261 * Internal API functions.
262 */
263
264/**
265 * \brief Initialize the EDHOC context with default parameters
266 * \param ctx EDHOC context to initialize
267 * \return 1 on success, 0 on failure
268 *
269 * Sets up cipher suites, authentication keys, connection ID, role, and method
270 */
271uint8_t edhoc_initialize_context(edhoc_context_t *ctx);
272
273/**
274 * \brief Retrieve own authentication key from key storage
275 * \param ctx EDHOC context
276 * \param key Pointer to store the found authentication key
277 * \return 1 if key found, 0 if not found
278 *
279 * Searches for authentication key using subject name or key ID
280 */
281uint8_t edhoc_get_own_auth_key(edhoc_context_t *ctx, cose_key_t **key);
282
283/**
284 * \brief Set EDHOC configuration parameters based on cipher suite
285 * \param ctx EDHOC context
286 * \param suite Selected cipher suite
287 * \return 1 on success, 0 on failure
288 *
289 * Configures ECDH curve, MAC length, AEAD algorithm, and signature algorithm
290 */
291int8_t edhoc_set_config_from_suite(edhoc_context_t *ctx, uint8_t suite);
292
293/**
294 * \brief Print current EDHOC session information for debugging
295 * \param ctx EDHOC context
296 *
297 * Logs session details including role, method, cipher suite, and connection IDs
298 */
299void edhoc_print_session_info(const edhoc_context_t *ctx);
300
301/**
302 * \brief Generate transcript hash TH_2
303 * \param ctx EDHOC context
304 * \param eph_pub Ephemeral public key
305 * \param msg Message 1 buffer
306 * \param msg_sz Message 1 size
307 * \return 0 on success, negative on error
308 *
309 * Computes TH_2 = H(G_Y, H(message_1)) for EDHOC protocol
310 */
311int8_t edhoc_generate_transcript_hash_2(edhoc_context_t *ctx, const uint8_t *eph_pub,
312 uint8_t *msg, uint16_t msg_sz);
313
314/**
315 * \brief Generate transcript hash TH_3
316 * \param ctx EDHOC context
317 * \param cred Credential data
318 * \param cred_sz Credential size
319 * \param plaintext Plaintext data
320 * \param plaintext_sz Plaintext size
321 * \return 0 on success, 1 on buffer overflow
322 *
323 * Computes TH_3 = H(TH_2, PLAINTEXT_2, CRED_R) for EDHOC protocol
324 */
325uint8_t edhoc_generate_transcript_hash_3(edhoc_context_t *ctx,
326 const uint8_t *cred, uint16_t cred_sz,
327 const uint8_t *plaintext, uint16_t plaintext_sz);
328
329/**
330 * \brief Generate transcript hash TH_4
331 * \param ctx EDHOC context
332 * \param cred Credential data
333 * \param cred_sz Credential size
334 * \param plaintext Plaintext data
335 * \param plaintext_sz Plaintext size
336 * \return 0 on success, 1 on buffer overflow
337 *
338 * Computes TH_4 = H(TH_3, PLAINTEXT_3, CRED_I) for EDHOC protocol
339 */
340uint8_t edhoc_generate_transcript_hash_4(edhoc_context_t *ctx,
341 const uint8_t *cred, uint16_t cred_sz,
342 const uint8_t *plaintext, uint16_t plaintext_sz);
343
344/**
345 * \brief Generate pseudorandom key PRK_2e
346 * \param ctx EDHOC context
347 * \return true on success, false on failure
348 *
349 * Generates PRK_2e using ECDH shared secret and TH_2
350 */
351bool edhoc_generate_prk_2e(edhoc_context_t *ctx);
352
353/**
354 * \brief Generate pseudorandom key PRK_3e2m
355 * \param ctx EDHOC context
356 * \param auth_key Authentication key
357 * \param gen Key generation mode
358 * \return true on success, false on failure
359 *
360 * Generates PRK_3e2m using authentication key and ephemeral key
361 */
362bool edhoc_generate_prk_3e2m(edhoc_context_t *ctx, const ecc_key_t *auth_key,
363 uint8_t gen);
364
365/**
366 * \brief Generate pseudorandom key PRK_4e3m
367 * \param ctx EDHOC context
368 * \param auth_key Authentication key
369 * \param gen Key generation mode
370 * \return true on success, false on failure
371 *
372 * Generates PRK_4e3m using authentication key and ephemeral key
373 */
374bool edhoc_generate_prk_4e3m(edhoc_context_t *ctx, const ecc_key_t *auth_key,
375 uint8_t gen);
376
377/**
378 * \brief Generate keystream KS_2e for encryption
379 * \param ctx EDHOC context
380 * \param length Keystream length
381 * \param ks_2e Output keystream buffer
382 * \return 1 on success, negative on error
383 *
384 * Derives keystream for encrypting/decrypting EDHOC message 2
385 */
386int16_t edhoc_generate_keystream_2e(edhoc_context_t *ctx, uint16_t length, uint8_t *ks_2e);
387
388/**
389 * \brief Encrypt/decrypt ciphertext 2 using XOR with keystream
390 * \param ctx EDHOC context
391 * \param ks_2e Keystream for XOR operation
392 * \param plaintext Input/output buffer for plaintext/ciphertext
393 * \param plaintext_sz Buffer size
394 * \return Size of processed data
395 *
396 * Performs XOR encryption/decryption of EDHOC message 2 content
397 */
398int16_t edhoc_enc_dec_ciphertext_2(const edhoc_context_t *ctx,
399 const uint8_t *ks_2e,
400 uint8_t *plaintext, uint16_t plaintext_sz);
401
402/**
403 * \brief Generate CBOR-encoded credential CRED_X
404 * \param cose COSE key containing credential information
405 * \param cred Output buffer for credential
406 * \param cred_sz Output buffer size
407 * \return Size of generated credential, 0 on error
408 *
409 * Generates CBOR credential structure from COSE key
410 */
411size_t edhoc_generate_cred_x(const cose_key_t *cose, uint8_t *cred, size_t cred_sz);
412
413/**
414 * \brief Generate credential identifier ID_CRED_X
415 * \param cose COSE key containing credential information
416 * \param cred Output buffer for credential ID
417 * \param cred_sz Output buffer size
418 * \return Size of generated credential ID, 0 on error
419 *
420 * Generates credential identifier (KID or full credential)
421 */
422size_t edhoc_generate_id_cred_x(const cose_key_t *cose, uint8_t *cred, size_t cred_sz);
423
424/**
425 * \brief Calculate message authentication code (MAC)
426 * \param ctx EDHOC context
427 * \param mac_num MAC number (2 or 3)
428 * \param mac_len MAC length
429 * \param mac Output buffer for MAC
430 * \return 1 on success, 0 on failure
431 *
432 * Computes MAC_2 or MAC_3 for EDHOC message authentication
433 */
434uint8_t edhoc_calc_mac(const edhoc_context_t *ctx, uint8_t mac_num,
435 uint8_t mac_len, uint8_t *mac);
436
437/**
438 * \brief Print EDHOC session configuration summary
439 * \param ctx EDHOC context
440 *
441 * Prints a comprehensive summary of the current EDHOC session configuration
442 * including role, method, cipher suite, and key information.
443 */
444void edhoc_print_config_summary(const edhoc_context_t *ctx);
445
446#endif /* EDHOC_H_ */
447/** @} */
ECDH interface for the EDHOC implementation.
EDHOC configuration file.
edhoc_error_t
Unified error type for EDHOC operations.
Definition edhoc-error.h:60
struct cose_key cose_key_t
KEY length in bytes.
EDHOC message serialization and parsing API.
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
uint8_t edhoc_calc_mac(const edhoc_context_t *ctx, uint8_t mac_num, uint8_t mac_len, uint8_t *mac)
Calculate message authentication code (MAC).
Definition edhoc.c:417
uint8_t edhoc_setup_suites(edhoc_context_t *ctx)
Initialize the EDHOC Context with the defined EDHOC parameters.
Definition edhoc.c:89
size_t edhoc_generate_id_cred_x(const cose_key_t *cose, uint8_t *cred, size_t cred_sz)
Generate credential identifier ID_CRED_X.
Definition edhoc.c:242
bool edhoc_generate_prk_2e(edhoc_context_t *ctx)
Generate pseudorandom key PRK_2e.
Definition edhoc.c:542
uint8_t edhoc_get_own_auth_key(edhoc_context_t *ctx, cose_key_t **key)
Retrieve own authentication key from key storage.
Definition edhoc.c:743
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
void edhoc_print_config_summary(const edhoc_context_t *ctx)
Print EDHOC session configuration summary.
Definition edhoc.c:1003
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
int16_t edhoc_expand(const uint8_t *prk, const uint8_t *info, uint16_t info_sz, uint16_t length, uint8_t *result)
HMAC-based Key Expansion Function for EDHOC context using HKDF (RFC 5869).
Definition edhoc.c:406
uint8_t edhoc_initialize_context(edhoc_context_t *ctx)
Internal API functions.
Definition edhoc.c:688
int edhoc_authenticate_msg(edhoc_context_t *ctx, uint8_t *ad, bool msg2)
Authenticate the rx message.
Definition edhoc.c:867
edhoc_error_t edhoc_generate_message_1(edhoc_context_t *ctx, uint8_t *ad, size_t ad_sz, bool suite_array)
Generate the EDHOC Message 1 and set it in the EDHOC context.
edhoc_context_t * edhoc_ctx
EDHOC context struct used in the EDHOC protocol.
Definition edhoc.c:62
void edhoc_storage_init(void)
Reserve memory for the EDHOC context struct.
Definition edhoc.c:67
bool edhoc_generate_prk_4e3m(edhoc_context_t *ctx, const ecc_key_t *auth_key, uint8_t gen)
Generate pseudorandom key PRK_4e3m.
bool edhoc_generate_prk_3e2m(edhoc_context_t *ctx, const ecc_key_t *auth_key, uint8_t gen)
Generate pseudorandom key PRK_3e2m.
uint8_t edhoc_generate_error_message(uint8_t *msg_er, size_t msg_er_sz, const edhoc_context_t *ctx, int8_t err)
Generate the EDHOC ERROR Message.
Definition edhoc.c:784
size_t edhoc_generate_cred_x(const cose_key_t *cose, uint8_t *cred, size_t cred_sz)
Generate CBOR-encoded credential CRED_X.
Definition edhoc.c:210
edhoc_error_t edhoc_generate_message_3(edhoc_context_t *ctx, const uint8_t *auth_data, size_t auth_data_size)
Generate the EDHOC Message 3 and set it in the EDHOC context.
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 edhoc_finalize(edhoc_context_t *ctx)
Close the EDHOC context.
Definition edhoc.c:83
uint8_t edhoc_generate_transcript_hash_4(edhoc_context_t *ctx, const uint8_t *cred, uint16_t cred_sz, const uint8_t *plaintext, uint16_t plaintext_sz)
Generate transcript hash TH_4.
Definition edhoc.c:335
edhoc_error_t edhoc_generate_message_2(edhoc_context_t *ctx, const uint8_t *auth_data, size_t auth_data_size)
Generate the EDHOC Message 2 and set it in the EDHOC context.
#define EDHOC_SUITES_MAX_COUNT
The max number of suites.
#define EDHOC_MAX_CRED_LEN
Optimized buffer sizes for credentials based on COSE standard analysis CRED_X: 84-120 bytes typical →...
#define EDHOC_MAX_PAYLOAD_LEN
The max length of the EDHOC 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...