ISO 15118-2 · ISO 15118-20 · ISO 15118-3

Vehicle-to-grid, from the ECU to the back end.

iso15118 is the ISO 15118 protocol suite in pure Rust: a schema-informed EXI codec generated from the official schemas, both generations' message sets including ISO 15118-20 Amd 1, SLAC and SECC discovery, the V2G PKI, and sans-I/O session engines for the vehicle and the charging station alike. No sockets, no clock, no async runtime — those are yours.

cargo add iso15118
166 × 2
messages verified
395
EXI grammars checked
12
fuzz targets
0
lines of unsafe
160
feature combinations

Four decisions

ISO 15118 is what a car and a DC fast charger speak while deciding whether to move 350 kW between them. One codebase for both roles and both generations, on a charge-point back end and a bare-metal controller alike.

01

Sans-I/O

Bytes and a timestamp in; bytes, events and deadlines out. A whole DC charging session runs as a unit test, with time as a variable.

02

no_std + alloc

The core builds for thumbv7em-none-eabihf. Every feature flag gates real code, so a DC-only vehicle controller compiles the DC message set and nothing else.

03

A wire format someone else agrees with

Every grammar and message is diffed against the EXI reference implementation, as documents and signature fragments, captured sessions from real equipment re-encode byte for byte, and whole sessions run live against Josev and EVerest.

04

A decoder you can point at the internet

Every length is bounded by its schema facet before anything is allocated, nesting is capped, every decoder is fuzzed, and there is no unsafe.

Protocol, not policy

The engines own framing, decoding, the handshake, session ids, message ordering and the spec timers. Whether to authorize, which schedule to offer and how much current to deliver arrive as events you answer.

  • One engine shape everywhere. handle_input, poll_event, respond, take_transmit, poll_timeout — the same five calls for the charger, the vehicle, discovery and SLAC.
  • The ordering rules are data. One graph per protocol generation, shared by both roles. An ISO 15118-20 session speaks only the message set of the service it selected.
  • Including the rules about failing. A FAILED_* response ends the session and leaves only SessionStopReq; the drivers enter that state on their own.
  • And about stopping. Pause is not terminate, and renegotiating a schedule is neither.

How sessions and ordering work →

let mut secc = Secc::new(SeccConfig {
    protocols: Protocols::ISO,
    session_id: SessionId::new(*b"\x11\x22\x33\x44\x55\x66\x77\x88"),
    ..SeccConfig::default()
});

let mut buf = [0u8; 4096];
loop {
    let n = read(&mut buf);
    secc.handle_input(now(), &buf[..n])?;
    while let Some(event) = secc.poll_event() {
        match event {
            Event::ProtocolAgreed(p) => println!("speaking {p}"),
            Event::Request(req) => secc.respond(now(), answer(&req))?,
            Event::Refused { .. } => break,
            Event::Closed(why) => return Ok(println!("session over: {why}")),
            _ => {}
        }
    }
    write(&secc.take_transmit());
}

What is implemented

From the powerline link coming up to the charge loop turning.

LayerState
EXI — schema-informed, bit-packedPrimitives, value string table, grammars, header, documents and fragments
V2GTP framingAll payload types, hostile-length handling, bounded stream reassembly
SDP discoveryCodec, the vehicle-side retry engine, TLS-downgrade and off-link rejection
SLAC — ISO 15118-3Frame codec, timers, and the matching state machine for both roles
ISO 15118-2 message setAll 34 body messages, ds:Signature included
ISO 15118-20 message setsCommonMessages, AC, DC, WPT, ACDP, and Amd 1's AC_DER_IEC / AC_DER_SAE; MCS on the DC flow
Session layerClock, spec timers and configurable loop budgets, ordering graphs for both generations, the message-set rule, the ISO 15118-2 charging-profile rule
EVCC / SECC driversHandshake, sequencing, session-id checks, half-duplex enforcement, pause and resume
Plug & Charge signaturesXMLDSig over EXI fragments, build and verify: ECDSA over secp256r1 (-2), secp521r1 and Ed448 (-20)
V2G PKIDER/X.509 reader, RFC 5280 path validation under ISO 15118-2 Annex F and ISO 15118-20 Annex B and Amd 1, OCSP and CRL revocation status, and the contract-key envelopes of both generations

Read the documentation →

And what is not

Named rather than implied.

Fetching revocation status

OCSP responses and CRLs you hand in are verified; nothing here contacts a responder or downloads a list.

Transport bindings

No TCP, TLS or raw sockets. Bring rustls on a server and embedded-tls on an ECU; the examples show the glue.

DIN/TS 70121

Its message set is not included. The handshake declines DIN by name, and the framing and timers carry a DIN codec of your own.

All limitations →