Contiki-NG
Loading...
Searching...
No Matches
An EDHOC implementation (RFC9528)

This is an implementation of Ephemeral Diffie-Hellman Over COSE (EDHOC), a very compact and lightweight authenticated Diffie-Hellman key exchange with ephemeral keys that provides mutual authentication, perfect forward secrecy, and identity protection as described in RFC9528. More...

Functions

void edhoc_storage_init (void)
 Reserve memory for the EDHOC context struct.
uint8_t edhoc_setup_suites (edhoc_context_t *ctx)
 Initialize the EDHOC Context with the defined EDHOC parameters.
void edhoc_finalize (edhoc_context_t *ctx)
 Close the EDHOC context.
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_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.
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_error_message (uint8_t *msg_er, size_t msg_er_sz, const edhoc_context_t *ctx, int8_t err)
 Generate the EDHOC ERROR Message.
int edhoc_authenticate_msg (edhoc_context_t *ctx, uint8_t *ad, bool msg2)
 Authenticate the rx message.
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).
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).
uint8_t edhoc_initialize_context (edhoc_context_t *ctx)
 Internal API functions.
uint8_t edhoc_get_own_auth_key (edhoc_context_t *ctx, cose_key_t **key)
 Retrieve own authentication key from key storage.
int8_t edhoc_set_config_from_suite (edhoc_context_t *ctx, uint8_t suite)
 Set EDHOC configuration parameters based on cipher suite.
void edhoc_print_session_info (const edhoc_context_t *ctx)
 Print current EDHOC session information for debugging.
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.
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.
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.
bool edhoc_generate_prk_2e (edhoc_context_t *ctx)
 Generate pseudorandom key PRK_2e.
bool edhoc_generate_prk_3e2m (edhoc_context_t *ctx, const ecc_key_t *auth_key, uint8_t gen)
 Generate pseudorandom key PRK_3e2m.
bool edhoc_generate_prk_4e3m (edhoc_context_t *ctx, const ecc_key_t *auth_key, uint8_t gen)
 Generate pseudorandom key PRK_4e3m.
int16_t edhoc_generate_keystream_2e (edhoc_context_t *ctx, uint16_t length, uint8_t *ks_2e)
 Generate keystream KS_2e for encryption.
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.
size_t edhoc_generate_cred_x (const cose_key_t *cose, uint8_t *cred, size_t cred_sz)
 Generate CBOR-encoded credential CRED_X.
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.
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).
void edhoc_print_config_summary (const edhoc_context_t *ctx)
 Print EDHOC session configuration summary.

Variables

edhoc_context_t * edhoc_ctx
 EDHOC context struct used in the EDHOC protocol.

Detailed Description

This is an implementation of Ephemeral Diffie-Hellman Over COSE (EDHOC), a very compact and lightweight authenticated Diffie-Hellman key exchange with ephemeral keys that provides mutual authentication, perfect forward secrecy, and identity protection as described in RFC9528.

Function Documentation

◆ edhoc_authenticate_msg()

int edhoc_authenticate_msg ( edhoc_context_t * ctx,
uint8_t * ad,
bool msg2 )

Authenticate the rx message.

Parameters
ctxEDHOC Context struct
adA pointer to a buffer to copy the Application Data of the rx message
msg2Determines whether the message is a Message 2
Return values
negativeerror code when an EDHOC ERROR is detected
ad_szThe length of the Application Data received in Message 2, when EDHOC success

Used by Initiator and Responder EDHOC role to Authenticate the other party

  • Verify that the EDHOC Responder role identity is among the allowed if it is necessary
  • Verify MAC
  • Pass Application data AD

If any verification step fails to return an EDHOC ERROR code and, if all the steps success the length of the Application Data receive on the Message is returned.

Definition at line 867 of file edhoc.c.

References cbor_end_writer(), cbor_get_position(), cbor_get_remaining(), cbor_init_reader(), cbor_init_writer(), cbor_write_data(), cbor_write_object(), cose_sign1_verify(), edhoc_calc_mac(), EDHOC_ERR_CRYPTO_AUTHENTICATION, EDHOC_ERR_INTERNAL_ERROR, edhoc_generate_cred_x(), edhoc_generate_id_cred_x(), edhoc_generate_prk_3e2m(), edhoc_generate_prk_4e3m(), edhoc_generate_transcript_hash_4(), edhoc_get_ad(), edhoc_get_key_id_cred_x(), edhoc_get_sign(), EDHOC_MAX_AD_SZ, EDHOC_MAX_CRED_LEN, and edhoc_read_byte_identifier().

◆ edhoc_calc_mac()

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).

Parameters
ctxEDHOC context
mac_numMAC number (2 or 3)
mac_lenMAC length
macOutput buffer for MAC
Returns
1 on success, 0 on failure

Computes MAC_2 or MAC_3 for EDHOC message authentication

Definition at line 417 of file edhoc.c.

References cbor_end_writer(), cbor_init_writer(), cbor_write_data(), cbor_write_object(), edhoc_kdf(), EDHOC_MAX_CID_LEN, and EDHOC_ROLE.

Referenced by edhoc_authenticate_msg().

◆ edhoc_enc_dec_ciphertext_2()

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.

Parameters
ctxEDHOC context
ks_2eKeystream for XOR operation
plaintextInput/output buffer for plaintext/ciphertext
plaintext_szBuffer size
Returns
Size of processed data

Performs XOR encryption/decryption of EDHOC message 2 content

Definition at line 665 of file edhoc.c.

Referenced by edhoc_generate_message_2(), and edhoc_handler_msg_2().

◆ edhoc_expand()

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).

Parameters
prkPRK (Pseudorandom Key) - a pseudorandom key used as input for the HMAC-based key derivation.
infoAdditional context information used in the key derivation, which is generated from the info_label and context.
info_szThe size of the info parameter in bytes.
lengthThe desired length of the output key material (OKM) in bytes.
resultOKM (Output Keying Material) - the buffer where the derived key will be stored.
Returns
The number of output key bytes generated (equal to length).

This function implements the HKDF-Expand function as described in RFC 5869. It takes the PRK, context info, and the desired length to produce the final key material. It calls hkdf_expand internally to perform the HMAC-based key expansion using SHA-256.

The steps include:

  • Verifying the size of the info and output key material (OKM).
  • Using HMAC-Expand to expand the PRK and info into OKM.
  • Returning the length of the derived key or an error code in case of failure.

Example usage:

  • OKM = HKDF-Expand(PRK, info, length)

Definition at line 406 of file edhoc.c.

References sha_256_hkdf_expand().

Referenced by edhoc_kdf().

◆ edhoc_finalize()

void edhoc_finalize ( edhoc_context_t * ctx)

Close the EDHOC context.

Parameters
ctxEDHOC context struct

Used by both Initiator and Responder EDHOC roles to de-allocate the memory reserved for the EDHOC context when EDHOC protocol finalize.

Definition at line 83 of file edhoc.c.

References memb_free().

Referenced by edhoc_client_close(), and edhoc_server_close().

◆ edhoc_generate_cred_x()

size_t edhoc_generate_cred_x ( const cose_key_t * cose,
uint8_t * cred,
size_t cred_sz )

Generate CBOR-encoded credential CRED_X.

Parameters
coseCOSE key containing credential information
credOutput buffer for credential
cred_szOutput buffer size
Returns
Size of generated credential, 0 on error

Generates CBOR credential structure from COSE key

Definition at line 210 of file edhoc.c.

References cbor_close_map(), cbor_end_writer(), cbor_init_writer(), cbor_open_map(), cbor_write_data(), cbor_write_signed(), cbor_write_text(), and cbor_write_unsigned().

Referenced by edhoc_authenticate_msg(), edhoc_generate_id_cred_x(), edhoc_generate_message_2(), and edhoc_generate_message_3().

◆ edhoc_generate_error_message()

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.

Parameters
msg_erA pointer to a buffer to copy the generated CBOR message error
msg_er_szThe size of the destination buffer
ctxEDHOC Context struct
errEDHOC error number
Returns
err_sz CBOR Message Error size

An EDHOC error message can be sent by both parties as a reply to any non-error EDHOC message. If any verification step fails on the EDHOC protocol the Initiator or Responder must send an EDHOC error message back that contains a brief human-readable diagnostic message.

  • msg_er = (?C_x_identifier, ERR_MSG:tstr)

Definition at line 784 of file edhoc.c.

References EDHOC_ERR_BUFFER_OVERFLOW, EDHOC_ERR_CID_INVALID, EDHOC_ERR_CORRELATION, EDHOC_ERR_CREDENTIAL_NOT_FOUND, EDHOC_ERR_CRITICAL_EAD_UNSUPPORTED, EDHOC_ERR_CRYPTO_AUTHENTICATION, EDHOC_ERR_CRYPTO_DECRYPT, EDHOC_ERR_ID_CRED_MALFORMED, EDHOC_ERR_INTERNAL_ERROR, EDHOC_ERR_KEY_NOT_FOUND, EDHOC_ERR_METHOD_NOT_SUPPORTED, EDHOC_ERR_MSG_MALFORMED, EDHOC_ERR_NETWORK_TIMEOUT, EDHOC_ERR_NOT_ALLOWED_IDENTITY, EDHOC_ERR_SEQUENCE_ERROR, EDHOC_ERR_SUITE_NOT_SUPPORTED, EDHOC_ERR_WRONG_CID, and edhoc_serialize_err().

◆ edhoc_generate_id_cred_x()

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.

Parameters
coseCOSE key containing credential information
credOutput buffer for credential ID
cred_szOutput buffer size
Returns
Size of generated credential ID, 0 on error

Generates credential identifier (KID or full credential)

Definition at line 242 of file edhoc.c.

References cbor_close_map(), cbor_end_writer(), cbor_init_writer(), cbor_open_map(), cbor_write_data(), cbor_write_unsigned(), EDHOC_AUTHENT_TYPE, and edhoc_generate_cred_x().

Referenced by edhoc_authenticate_msg(), edhoc_generate_message_2(), and edhoc_generate_message_3().

◆ edhoc_generate_keystream_2e()

int16_t edhoc_generate_keystream_2e ( edhoc_context_t * ctx,
uint16_t length,
uint8_t * ks_2e )

Generate keystream KS_2e for encryption.

Parameters
ctxEDHOC context
lengthKeystream length
ks_2eOutput keystream buffer
Returns
1 on success, negative on error

Derives keystream for encrypting/decrypting EDHOC message 2

Definition at line 561 of file edhoc.c.

References EDHOC_DBG_VALUE, and edhoc_kdf().

Referenced by edhoc_generate_message_2(), and edhoc_handler_msg_2().

◆ edhoc_generate_message_1()

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.

Parameters
ctxEDHOC Context struct
adApplication data to include in MSG1
ad_szApplication data length
suite_arrayIf true, MSG1 includes an array of cipher suites when more than one is supported. If false, MSG1 includes a single unsigned suite value regardless of the number of suites supported by the initiator.
Returns
EDHOC_SUCCESS on success, error code on failure

Composes EDHOC Message 1 as described in RFC9528 for EDHOC authentication with asymmetric keys, encoded as a CBOR sequence in the MSG1 element of the context struct. Uses the ephemeral key, cipher suite, and connection identifier already set in the context (they are established by the caller, not by this function). Used by the Initiator EDHOC role.

  • ctx->MSG1 = (METHOD:unsigned, SUITES_I, G_X, C_I_identifier)

Definition at line 199 of file edhoc-msg-generators.c.

References EDHOC_ERR_NULL_POINTER, EDHOC_ERR_SUITE_NOT_SUPPORTED, and EDHOC_SUITES_MAX_COUNT.

◆ edhoc_generate_message_2()

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.

Parameters
ctxEDHOC Context struct
auth_dataApplication data to include in MSG2
auth_data_sizeApplication data length
Returns
EDHOC_SUCCESS on success, error code on failure

Used by the EDHOC Responder role to generate message 2. Computes the transcript hash TH_2 = H(ctx->MSG1, data_2), computes MAC_2 (Message Authentication Code), computes CIPHERTEXT_2, and composes EDHOC Message 2 as described in RFC9528 for EDHOC authentication with asymmetric keys, encoded as a CBOR sequence in the MSG2 element of the context struct. Uses the ephemeral key and connection identifier already set in the context.

  • ctx->MSG2 = a single CBOR byte string containing G_Y || CIPHERTEXT_2
  • where: data_2 = G_Y (C_R is carried inside the plaintext of CIPHERTEXT_2, not in data_2)

Definition at line 258 of file edhoc-msg-generators.c.

References cbor_close_data(), cbor_end_writer(), cbor_init_writer(), cbor_open_data(), cbor_write_data(), cbor_write_object(), cose_sign1_sign(), edhoc_enc_dec_ciphertext_2(), EDHOC_ERR_CBOR_ENCODING, EDHOC_ERR_CRYPTO_HASH, EDHOC_ERR_CRYPTO_SIGN, EDHOC_ERR_NULL_POINTER, edhoc_generate_cred_x(), edhoc_generate_id_cred_x(), edhoc_generate_keystream_2e(), edhoc_generate_prk_2e(), edhoc_generate_prk_3e2m(), edhoc_generate_transcript_hash_2(), EDHOC_MAC_OR_SIG_BUF_LEN, EDHOC_MAX_CRED_LEN, and edhoc_print_credential().

◆ edhoc_generate_message_3()

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.

Parameters
ctxEDHOC Context struct
auth_dataApplication data to include in MSG3
auth_data_sizeApplication data length
Returns
EDHOC_SUCCESS on success, error code on failure

Used by the EDHOC Initiator role to generate message 3. Computes the transcript hash TH_3 = H(TH_2, PLAINTEXT_2, data_3), computes MAC_3 (Message Authentication Code), computes CIPHERTEXT_3, and composes EDHOC Message 3 as described in RFC9528 for EDHOC authentication with asymmetric keys, encoded as a CBOR sequence in the MSG3 element of the context struct.

  • ctx->MSG3 = (data_3, CIPHERTEXT_3)
  • where: data_3 = (?C_R_identifier)

Definition at line 406 of file edhoc-msg-generators.c.

References cbor_end_writer(), cbor_init_writer(), cbor_write_data(), cbor_write_object(), cose_print_key(), cose_sign1_sign(), EDHOC_ERR_BUFFER_TOO_SMALL, EDHOC_ERR_CRYPTO_ENCRYPT, EDHOC_ERR_CRYPTO_SIGN, EDHOC_ERR_NULL_POINTER, edhoc_generate_cred_x(), edhoc_generate_id_cred_x(), edhoc_generate_prk_4e3m(), edhoc_generate_transcript_hash_3(), edhoc_generate_transcript_hash_4(), EDHOC_MAC_OR_SIG_BUF_LEN, EDHOC_MAX_CRED_LEN, and edhoc_print_credential().

◆ edhoc_generate_prk_2e()

bool edhoc_generate_prk_2e ( edhoc_context_t * ctx)

Generate pseudorandom key PRK_2e.

Parameters
ctxEDHOC context
Returns
true on success, false on failure

Generates PRK_2e using ECDH shared secret and TH_2

Definition at line 542 of file edhoc.c.

References ecdh_generate_ikm(), EDHOC_DBG_VALUE, and edhoc_trace_prk_derivation().

Referenced by edhoc_generate_message_2(), and edhoc_handler_msg_2().

◆ edhoc_generate_prk_3e2m()

bool edhoc_generate_prk_3e2m ( edhoc_context_t * ctx,
const ecc_key_t * auth_key,
uint8_t gen )

Generate pseudorandom key PRK_3e2m.

Parameters
ctxEDHOC context
auth_keyAuthentication key
genKey generation mode
Returns
true on success, false on failure

Generates PRK_3e2m using authentication key and ephemeral key

Referenced by edhoc_authenticate_msg(), and edhoc_generate_message_2().

◆ edhoc_generate_prk_4e3m()

bool edhoc_generate_prk_4e3m ( edhoc_context_t * ctx,
const ecc_key_t * auth_key,
uint8_t gen )

Generate pseudorandom key PRK_4e3m.

Parameters
ctxEDHOC context
auth_keyAuthentication key
genKey generation mode
Returns
true on success, false on failure

Generates PRK_4e3m using authentication key and ephemeral key

Referenced by edhoc_authenticate_msg(), and edhoc_generate_message_3().

◆ edhoc_generate_transcript_hash_2()

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.

Parameters
ctxEDHOC context
eph_pubEphemeral public key
msgMessage 1 buffer
msg_szMessage 1 size
Returns
0 on success, negative on error

Computes TH_2 = H(G_Y, H(message_1)) for EDHOC protocol

Definition at line 279 of file edhoc.c.

References cbor_end_writer(), cbor_init_writer(), cbor_write_data(), EDHOC_DBG_VALUE, edhoc_trace_transcript_hash(), and EDHOC_TRACE_VALUE.

Referenced by edhoc_generate_message_2(), and edhoc_handler_msg_2().

◆ edhoc_generate_transcript_hash_3()

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.

Parameters
ctxEDHOC context
credCredential data
cred_szCredential size
plaintextPlaintext data
plaintext_szPlaintext size
Returns
0 on success, 1 on buffer overflow

Computes TH_3 = H(TH_2, PLAINTEXT_2, CRED_R) for EDHOC protocol

Definition at line 306 of file edhoc.c.

References cbor_end_writer(), cbor_init_writer(), cbor_write_data(), cbor_write_object(), EDHOC_DBG_VALUE, EDHOC_MAX_BUFFER, edhoc_trace_transcript_hash(), and EDHOC_TRACE_VALUE.

Referenced by edhoc_generate_message_3(), and edhoc_handler_msg_3().

◆ edhoc_generate_transcript_hash_4()

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.

Parameters
ctxEDHOC context
credCredential data
cred_szCredential size
plaintextPlaintext data
plaintext_szPlaintext size
Returns
0 on success, 1 on buffer overflow

Computes TH_4 = H(TH_3, PLAINTEXT_3, CRED_I) for EDHOC protocol

Definition at line 335 of file edhoc.c.

References cbor_end_writer(), cbor_init_writer(), cbor_write_data(), cbor_write_object(), EDHOC_DBG_VALUE, EDHOC_MAX_BUFFER, edhoc_trace_transcript_hash(), and EDHOC_TRACE_VALUE.

Referenced by edhoc_authenticate_msg(), and edhoc_generate_message_3().

◆ edhoc_get_own_auth_key()

uint8_t edhoc_get_own_auth_key ( edhoc_context_t * ctx,
cose_key_t ** key )

Retrieve own authentication key from key storage.

Parameters
ctxEDHOC context
keyPointer to store the found authentication key
Returns
1 if key found, 0 if not found

Searches for authentication key using subject name or key ID

Definition at line 743 of file edhoc.c.

References edhoc_check_key_list_identity(), and edhoc_check_key_list_kid().

Referenced by edhoc_initialize_context().

◆ edhoc_initialize_context()

uint8_t edhoc_initialize_context ( edhoc_context_t * ctx)

Internal API functions.

Initialize the EDHOC context with default parameters

Parameters
ctxEDHOC context to initialize
Returns
1 on success, 0 on failure

Sets up cipher suites, authentication keys, connection ID, role, and method

Definition at line 688 of file edhoc.c.

References EDHOC_CID, EDHOC_DEFAULT_CID_LEN, edhoc_get_own_auth_key(), EDHOC_MAX_CID_LEN, EDHOC_METHOD, EDHOC_ROLE, edhoc_set_config_from_suite(), and edhoc_setup_suites().

Referenced by edhoc_server_reset_handshake().

◆ edhoc_kdf()

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).

Parameters
resultOKM (Output Keying Material) - the buffer where the derived key will be stored.
prkPRK (Pseudorandom Key) - a pseudorandom key used as input to the key derivation, should be at least HASH_LEN bytes.
info_labelLabel used to generate the CBOR-based info input for key derivation.
contextContext data used to generate the info input for key derivation.
context_szThe size of the Context data.
lengthDesired length of the output key material (OKM) in bytes.
Returns
The number of output key bytes generated (equal to length) on success, or 0 on failure.

This function combines the PRK, info_label, and context to generate an input info parameter that is used for HKDF-Expand as defined in RFC 5869. It is used by both the Initiator and Responder in the EDHOC protocol to generate keying material. Internally, this function calls edhoc_expand to compute the final OKM.

The function performs the following steps:

  • Calls generate_info to prepare the info input.
  • Passes the PRK, generated info, and length to edhoc_expand.

Example usage:

  • OKM = EDHOC_Expand(PRK, info, length)

Definition at line 373 of file edhoc.c.

References edhoc_expand().

Referenced by edhoc_calc_mac(), edhoc_exporter(), edhoc_exporter_oscore(), and edhoc_generate_keystream_2e().

◆ edhoc_print_config_summary()

void edhoc_print_config_summary ( const edhoc_context_t * ctx)

Print EDHOC session configuration summary.

Parameters
ctxEDHOC context

Prints a comprehensive summary of the current EDHOC session configuration including role, method, cipher suite, and key information.

Definition at line 1003 of file edhoc.c.

◆ edhoc_print_session_info()

void edhoc_print_session_info ( const edhoc_context_t * ctx)

Print current EDHOC session information for debugging.

Parameters
ctxEDHOC context

Logs session details including role, method, cipher suite, and connection IDs

Definition at line 366 of file edhoc.c.

References edhoc_trace_session_summary().

Referenced by edhoc_handler_msg_1().

◆ edhoc_set_config_from_suite()

int8_t edhoc_set_config_from_suite ( edhoc_context_t * ctx,
uint8_t suite )

Set EDHOC configuration parameters based on cipher suite.

Parameters
ctxEDHOC context
suiteSelected cipher suite
Returns
1 on success, 0 on failure

Configures ECDH curve, MAC length, AEAD algorithm, and signature algorithm

Definition at line 188 of file edhoc.c.

Referenced by edhoc_initialize_context().

◆ edhoc_setup_suites()

uint8_t edhoc_setup_suites ( edhoc_context_t * ctx)

Initialize the EDHOC Context with the defined EDHOC parameters.

Parameters
ctxAn EDHOC context struct to fill in
Returns
1 on success, 0 if no supported cipher suites are configured

Used in the edhoc_new to set the default protocol definitions and in the Responder to reset the initial values to prepare for a new EDHOC connection. Sets up the cipher suites selection logic and validates that at least one cipher suite is supported.

Definition at line 89 of file edhoc.c.

References EDHOC_ERR_SUITE_NOT_SUPPORTED, and EDHOC_SUPPORTED_SUITE_1.

Referenced by edhoc_initialize_context(), and edhoc_server_reset_handshake().

◆ edhoc_storage_init()

void edhoc_storage_init ( void )

Reserve memory for the EDHOC context struct.

Used by both Initiator and Responder EDHOC roles to reserve memory

Definition at line 67 of file edhoc.c.

References memb_init().