Contiki-NG
Loading...
Searching...
No Matches
edhoc-trace.h File Reference

EDHOC tracing and logging header. More...

#include "edhoc.h"
#include "sys/log.h"

Go to the source code of this file.

Macros

#define EDHOC_TRACE_STEP(step_name)
 Print protocol step header in RFC 9529 style.
#define EDHOC_TRACE_VALUE(label, data, len)
 Print cryptographic value in RFC 9529 trace format.
#define EDHOC_TRACE_STATE(from_state, to_state)
 Print protocol state transition.
#define EDHOC_TRACE_COMPUTE(description)
 Print computation step description.
#define EDHOC_DBG_VALUE(label, data, len)
 Print detailed debug value (only at DBG level).

Functions

void edhoc_trace_message (uint8_t msg_num, const uint8_t *msg_data, size_t msg_len, bool is_tx)
 Print EDHOC message in RFC 9529 trace format.
void edhoc_trace_ephemeral_key (const char *role_label, const uint8_t *pub_x, const uint8_t *pub_y, const uint8_t *priv)
 Print ephemeral key generation step.
void edhoc_trace_transcript_hash (const char *th_label, const uint8_t *th_data, const uint8_t *input_data, size_t input_len)
 Print transcript hash computation.
void edhoc_trace_prk_derivation (const char *prk_label, const uint8_t *prk_data, const uint8_t *salt_data, const uint8_t *ikm_data)
 Print PRK derivation step.
void edhoc_trace_mac_computation (const char *mac_label, const uint8_t *mac_data, const uint8_t *context_data, size_t context_len)
 Print MAC computation step.
void edhoc_trace_credential (const char *cred_label, const uint8_t *cred_data, size_t cred_len, const uint8_t *id_cred_data, size_t id_cred_len)
 Print credential information.
void edhoc_trace_session_summary (const edhoc_context_t *ctx)
 Print session summary at protocol completion.

Detailed Description

EDHOC tracing and logging header.

Author
Nicolas Tsiftes nicol.nosp@m.as.t.nosp@m.sifte.nosp@m.s@ri.nosp@m..se

Definition in file edhoc-trace.h.

Macro Definition Documentation

◆ EDHOC_DBG_VALUE

#define EDHOC_DBG_VALUE ( label,
data,
len )
Value:
do { \
if(LOG_LEVEL >= LOG_LEVEL_DBG) { \
LOG_DBG("%s (%d bytes): ", label, (int)(len)); \
if((len) > 0) { \
LOG_DBG_BYTES(data, len); \
LOG_DBG_("\n"); \
} else { \
LOG_DBG_("(empty)\n"); \
} \
} \
} while(0)

Print detailed debug value (only at DBG level).

Parameters
labelDescriptive label
dataPointer to the data
lenLength of the data

Definition at line 90 of file edhoc-trace.h.

Referenced by edhoc_generate_keystream_2e(), edhoc_generate_prk_2e(), edhoc_generate_transcript_hash_2(), edhoc_generate_transcript_hash_3(), and edhoc_generate_transcript_hash_4().

◆ EDHOC_TRACE_COMPUTE

#define EDHOC_TRACE_COMPUTE ( description)
Value:
LOG_DBG("Computing: %s\n", description)

Print computation step description.

Parameters
descriptionBrief description of the computation

Definition at line 81 of file edhoc-trace.h.

◆ EDHOC_TRACE_STATE

#define EDHOC_TRACE_STATE ( from_state,
to_state )
Value:
LOG_DBG("State transition: %s -> %s\n", from_state, to_state)

Print protocol state transition.

Parameters
from_statePrevious state
to_stateNew state

Definition at line 74 of file edhoc-trace.h.

Referenced by edhoc_server_process().

◆ EDHOC_TRACE_STEP

#define EDHOC_TRACE_STEP ( step_name)
Value:
LOG_DBG("=== EDHOC %s ===\n", step_name)

Print protocol step header in RFC 9529 style.

Parameters
step_nameThe name of the protocol step (e.g., "message_1", "message_2")

Definition at line 50 of file edhoc-trace.h.

◆ EDHOC_TRACE_VALUE

#define EDHOC_TRACE_VALUE ( label,
data,
len )
Value:
do { \
if(LOG_LEVEL >= LOG_LEVEL_DBG) { \
LOG_DBG("%s (%zu bytes): ", label, (size_t)(len)); \
if((len) > 0) { \
LOG_DBG_BYTES(data, len); \
} \
LOG_DBG_("\n"); \
} \
} while(0)

Print cryptographic value in RFC 9529 trace format.

Parameters
labelDescriptive label for the value
dataPointer to the data
lenLength of the data in bytes

Definition at line 59 of file edhoc-trace.h.

Referenced by edhoc_generate_transcript_hash_2(), edhoc_generate_transcript_hash_3(), edhoc_generate_transcript_hash_4(), edhoc_trace_credential(), edhoc_trace_ephemeral_key(), edhoc_trace_mac_computation(), edhoc_trace_prk_derivation(), edhoc_trace_session_summary(), and edhoc_trace_transcript_hash().

Function Documentation

◆ edhoc_trace_credential()

void edhoc_trace_credential ( const char * cred_label,
const uint8_t * cred_data,
size_t cred_len,
const uint8_t * id_cred_data,
size_t id_cred_len )

Print credential information.

Parameters
cred_labelCredential label ("CRED_I", "CRED_R")
cred_dataCredential data
cred_lenCredential length
id_cred_dataID_CRED data (optional)
id_cred_lenID_CRED length

Definition at line 159 of file edhoc-trace.c.

References EDHOC_TRACE_VALUE.

◆ edhoc_trace_ephemeral_key()

void edhoc_trace_ephemeral_key ( const char * role_label,
const uint8_t * pub_x,
const uint8_t * pub_y,
const uint8_t * priv )

Print ephemeral key generation step.

Parameters
role_labelRole label ("Initiator" or "Responder")
pub_xPublic key X coordinate
pub_yPublic key Y coordinate (optional, can be NULL)
privPrivate key (optional for security, can be NULL)

Definition at line 64 of file edhoc-trace.c.

References EDHOC_TRACE_VALUE.

◆ edhoc_trace_mac_computation()

void edhoc_trace_mac_computation ( const char * mac_label,
const uint8_t * mac_data,
const uint8_t * context_data,
size_t context_len )

Print MAC computation step.

Parameters
mac_labelMAC label ("MAC_2", "MAC_3")
mac_dataMAC data
context_dataContext data used for MAC computation (optional)
context_lenContext data length

Definition at line 140 of file edhoc-trace.c.

References EDHOC_TRACE_VALUE.

◆ edhoc_trace_message()

void edhoc_trace_message ( uint8_t msg_num,
const uint8_t * msg_data,
size_t msg_len,
bool is_tx )

Print EDHOC message in RFC 9529 trace format.

Parameters
msg_numMessage number (1, 2, 3, or 4)
msg_dataMessage data
msg_lenMessage length
is_txTrue if transmitting, false if receiving

Definition at line 48 of file edhoc-trace.c.

◆ edhoc_trace_prk_derivation()

void edhoc_trace_prk_derivation ( const char * prk_label,
const uint8_t * prk_data,
const uint8_t * salt_data,
const uint8_t * ikm_data )

Print PRK derivation step.

Parameters
prk_labelPRK label ("PRK_2e", "PRK_3e2m", "PRK_4e3m")
prk_dataPRK data
salt_dataSalt used (optional)
ikm_dataInput keying material (optional)

Definition at line 117 of file edhoc-trace.c.

References EDHOC_TRACE_VALUE.

Referenced by edhoc_generate_prk_2e().

◆ edhoc_trace_session_summary()

void edhoc_trace_session_summary ( const edhoc_context_t * ctx)

Print session summary at protocol completion.

Parameters
ctxEDHOC context

Definition at line 181 of file edhoc-trace.c.

References EDHOC_TRACE_VALUE.

Referenced by edhoc_print_session_info().

◆ edhoc_trace_transcript_hash()

void edhoc_trace_transcript_hash ( const char * th_label,
const uint8_t * th_data,
const uint8_t * input_data,
size_t input_len )

Print transcript hash computation.

Parameters
th_labelTH label ("TH_2", "TH_3", "TH_4")
th_dataTranscript hash data
input_dataInput data for hash computation (optional)
input_lenInput data length

Definition at line 97 of file edhoc-trace.c.

References EDHOC_TRACE_VALUE.

Referenced by edhoc_generate_transcript_hash_2(), edhoc_generate_transcript_hash_3(), and edhoc_generate_transcript_hash_4().