Secure, non-blocking, full-duplex ISO-TP (ISO 15765-2) implementation for CAN-based ECUs, integrated with emb::TLS for end-to-end vehicle network security.
- Project Overview
- Goals
- Features
- Architecture
- Quick Start
- API Reference
isotp_init()isotp_send()isotp_receive()- Callback registration
- Performance & Testing
- Contributing
- License
Modern in-vehicle networks (IVNs) are exposed to eavesdropping, message injection, and DoS attacks. This project provides:
- ISO-TP (ISO 15765-2) transport layer over CAN for messages up to 4095 bytes.
Note: This repo ships only the ISO-TP stack itself and the “emb::TLS integration” is provided conceptually—you get the hooks and the transport layer over which you can run a TLS 1.2 handshake, but the emb::TLS library sources are not bundled here. emb::TLS integration "can" be made for mutual authentication, confidentiality, and integrity on deeply embedded ECUs.
All designed for resource-constrained microcontrollers (e.g., ARM Cortex-M) to secure ECU-to-gateway channels.
- Understand ISO 15765-2 specification.
- Provide a standalone, non-blocking ISO-TP implementation.
- Integrate emb::TLS over ISO-TP for secure channel establishment.
- Perform interoperability and performance evaluations.
- Independency
Abstract data-link interface decouples ISO-TP from any specific CAN driver (CAN_init,CAN_snd,CAN_recv,CAN_ioctl). - Non-Blocking
All send/receive operations are spread across periodicisotp_tick()calls; CAN frames are sent via interrupt-driven driver, avoiding application stalls. - Full-Duplex Mode
Independent Tx/Rx state machines allow simultaneous transmission and reception of large messages.
┌───────────────────┐ CAN ┌───────────────────┐
│ Application │ <──────────> │ Other ECU / PC │
│ + emb::TLS API │ │ ISO-TP Socket │
└─▲──────────▲──────┘ └───────┬───────────┘
│ │ │
│ TLS over │ │
│ ISO-TP │ │
│ │ │
┌─┴──────────┴───────┐ CAN │
│ isoTP Layer │ <──────────> ────────────┘
│ ┌───────────────┐ │
│ │ tpSnd (Tx FSM)│ │
│ │ tpRcv (Rx FSM)│ │
│ └───────────────┘ │
└────────────────────┘
- tpSnd: segments messages into SF/FF/CF, handles FlowControl replies.
- tpRcv: reassembles frames, allocates buffers, signals completion or errors.
- isoTP: top-level FSM that dispatches frames to
tpSndortpRcv.
- ARM Cortex-M toolchain (GCC, CMSIS)
- CAN driver that implements:
CAN_init(baudrate)CAN_snd(id, data, len)CAN_recv(&id, buffer, &len)CAN_ioctl(...)
- Clone repository:
git clone https://github.com/yahyabarghash/ISO-TP.git cd ISO-TP - Configure your toolchain and CAN driver in
Makefile. - Build:
make all
// Define callback for send/receive completion
void isotp_cb(uint32_t task_id, N_Result_t result);
// Init ISO-TP at 500 kbps and register callback
isotp_init(500000, &isotp_cb);- baudrate: CAN bit-rate (e.g. 500000)
- cb: invoked on message completion or error
- Buffers and begins transmission of an
len-byte message. - Returns a task ID or error if no buffer space.
- Attempts to fetch a complete message.
- Returns task ID, sets
*len, or 0 if none available.
typedef void (*isotp_callback_t)(uint32_t task_id, N_Result_t status);- status: e.g.
en_nResultOk,en_nResult_timeoutAs,en_nResultRx_wrongSNRx, etc.
- Interoperability with Linux Socket CAN: successful SF/FF exchange.
- Overhead: ≈10 µs per frame at 1 Mbps
- TLS Handshake: tuning
BSandSTminyields min latency atBS=10, STmin=0 ms. - Secure Data Rate: linear with payload; best at
STmin=0 msbut watch bus occupancy. - Memory Footprint:
- ISO-TP alone: ~9.8 KB SRAM
- ISO-TP + emb::TLS: ~110 KB SRAM
- Fork & clone.
- Create feature branch:
git checkout -b feat/my-feature. - Commit & push.
- Submit a PR.
Please follow the existing coding style and include tests for new functionality.
This project is licensed under the MIT License. See LICENSE for details.