EDHOC Examples
This directory contains simple examples demonstrating how to use the EDHOC (Ephemeral Diffie-Hellman Over COSE) implementation in Contiki-NG.
EDHOC is a lightweight authenticated key exchange protocol described in RFC 9528.
Directory Structure
edhoc-client/- Simple EDHOC client example (Initiator)edhoc-server/- Simple EDHOC server example (Responder)
Quick Start
Building the Examples
EDHOC Server
cd examples/edhoc/edhoc-server
make TARGET=native
EDHOC Client
cd examples/edhoc/edhoc-client
make TARGET=native
Running the Examples
Native Platform
Start the server:
cd examples/edhoc/edhoc-server ./edhoc-server-example.native
Start the client (in another terminal):
cd examples/edhoc/edhoc-client ./edhoc-client-example.native
Cooja Simulation
Run the interactive demo simulation:
cd examples/edhoc
make COOJA_ARGS="--no-gui" edhoc-demo.csc
For interactive mode (with GUI):
cd examples/edhoc
make edhoc-demo.csc
Configuration
Server Configuration
Edit edhoc-server/project-conf.h to customize:
Server identity:
EDHOC_AUTH_KID(orEDHOC_AUTH_SUBJECT_NAME)Logging levels
CoAP and network parameters
Client Configuration
Edit edhoc-client/project-conf.h to customize:
Server endpoint:
EDHOC_CONF_SERVER_EPLogging levels
CoAP and network parameters
EDHOC Protocol Flow
Client (Initiator) sends MSG_1 to
/.well-known/edhocServer (Responder) responds with MSG_2
Client sends MSG_3 to complete the handshake
Secure communication can now proceed using derived keys
Advanced Usage
For more comprehensive testing and advanced features, see the test suite in:
tests/21-security-protocols/
The test suite includes:
Multi-method support (Method 0, Method 3)
Comprehensive error handling
Network simulation with Cooja
Performance benchmarks
Supported Platforms
Native (Linux/macOS) - for development and testing
CC2538DK - Texas Instruments platform
Zoul - IoT platform
Other Contiki-NG supported platforms
Security Considerations
These examples use default keys and configuration suitable for testing. For production use:
Generate unique keys for each device
Implement proper key storage (secure elements, etc.)
Configure appropriate cipher suites for your security requirements
Enable proper authentication and authorization mechanisms
Troubleshooting
Common Issues
Network connectivity: Ensure both client and server can reach each other
Key mismatch: Verify both sides use compatible keys and cipher suites
CoAP issues: Check CoAP configuration and endpoint addresses
Debug Logging
Enable debug logging by modifying the log levels in project-conf.h:
#define LOG_CONF_LEVEL_EDHOC LOG_LEVEL_DBG
#define LOG_CONF_LEVEL_COAP LOG_LEVEL_DBG