ISO 15118 is the protocol your car and a DC fast charger speak while deciding whether to move 350 kW between them. This crate is the whole of it that runs on a CPU: a schema-informed EXI codec generated from the official schemas, the ISO 15118-2 and -20 message sets, HomePlug link setup, SECC discovery, V2GTP framing, the message-ordering rules and spec timers of both generations, sans-I/O session engines for either role, and the Plug & Charge signature profile.
No sockets, no clock, no async runtime, no cryptography in the core โ those are the caller's, and that is the point.
๐ง Status: pre-1.0, but the protocol is real. All 121 message types round-trip byte-for-byte against the EXI reference implementation, as documents and as signature fragments.
examples/completes an AC charging session over a real socket. What is missing is named rather than implied โ the V2G PKI above all.
๐ก Why
The implementations that exist are C (OpenV2G, unmaintained), C++ (EVerest/libiso15118, tied to its runtime) or Python (Josev, unusable on an ECU). None lets you run the same protocol logic on a charge-point back end and on a bare-metal microcontroller.
- Sans-I/O. Bytes and a timestamp in; bytes, events and deadlines out. The
pattern behind
quinn-protoandrustlsโ and why a whole DC charging session runs as a unit test in microseconds, with time as a variable. no_std+alloc. The core builds forthumbv7em-none-eabihf. Features are additive and every one gates real code, grammar tables included.- A wire format someone else agrees with. Round-tripping your own encoder through your own decoder proves they agree with each other and nothing more.
- A decoder you can point at the internet. Every length bounded by both its
schema facets before anything is allocated โ
xs:lengthis notxs:maxLengthโ plus#![forbid(unsafe_code)]and nine fuzz targets. The layers above hold the same line: half-duplex enforced in both directions, a SLAC engine that treats a malformed frame as weather rather than an error, and a Plug & Charge signature that has to name the session it arrived in.
๐ฆ Install
A DC-only embedded vehicle controller, with nothing else compiled in:
Rust 1.88 or newer.
๐ A charging station, without a socket
The engine owns framing, decoding, the handshake, session-id checking, message ordering and every spec timer. Your code owns the charging decisions.
use Message;
use ;
use ;
use Protocol;
# use ;
#
#
#
#
#
Arm your own timer for secc.poll_timeout() and call secc.handle_timeout(now)
when it fires. That is the whole integration surface. evcc::Evcc is driven the
same way from the vehicle's side โ it answers with request rather than
respond, because the vehicle chooses what to send rather than replying to it.
๐จ Messages
use ExiDocument;
use MessageHeader;
use ;
let req = SessionStopReq ;
let bytes = req.to_vec?;
assert_eq!;
# Ok::
โ What works
| Layer | State |
|---|---|
| EXI codec โ schema-informed, bit-packed | primitives, string table, grammars, header, documents and fragments, every length facet enforced both ways |
| V2GTP framing ยท SDP discovery | all payload types, hostile-length handling, bounded reassembly, TLS-downgrade rejection |
| SLAC (ISO 15118-3) | frame codec with every layout pinned byte for byte, timers, and the matching state machine for both roles |
| ISO 15118-2 message set | all 34 body messages, ds:Signature included |
| ISO 15118-20 message sets | CommonMessages, AC, DC, WPT, ACDP |
| Session layer | clock, spec timers and loop budgets, ordering graphs for both generations |
| EVCC / SECC drivers | handshake, sequencing, session-id stamping and checking, half-duplex in both directions, pause and resume โ with a whole DC session per generation as an end-to-end test |
| Plug & Charge signatures | XMLDSig over EXI fragments, build and verify, algorithm restrictions enforced, and the two bindings that make a signature mean something: the GenChallenge for authorization and the echoed reading for metering |
โ ๏ธ Not here: V2G PKI (X.509 path validation and the certificate flows), transport bindings, DIN SPEC 70121. See what is not here.
๐ฌ Verification
Four layers, in increasing strength. Only the last two say anything about other implementations.
scripts/verify-grammars.sh all 2 / 80 / 54 / 42 / 48 / 38 / 34 element
grammars agree with the reference (298 total)
scripts/verify-messages.sh all 121 documents round-trip against the reference
all 121 fragments round-trip against the reference
Between them, and the fuzzers, they have found nine defects no round-trip test
could โ a dropped substitution-group head, mixed content on the wrong side of
EE, a string-table partition populated on a global hit, and six more.
The scripts prove the encoding and nothing above it. Reading the layers against
the standards, and against what EVerest and Josev do, found twenty-two more the
scripts cannot reach: a deadlocked DC renegotiation, a SLAC key handover any
station on the segment could forge, ISO 15118-20 service ids mapped to the wrong
flows, xs:length treated as xs:maxLength on the six types where a truncated
value is a security problem, and eighteen others. Each is a test.
Three of those found further defects on their first run โ including a four-byte
ISO 15118-20 SessionID in this README, legal in ISO 15118-2 and not in -20,
which stopped compiling the moment the facet was enforced.
SLAC is the one wire format with no reference implementation to differ against, so its thirteen message layouts are pinned byte for byte instead โ checked field for field against EVerest's libslac, because "our encoder agrees with our decoder" is not evidence and this crate says so on every other page.
&&
The last three need a JDK and the ISO schemas, which scripts/fetch-schemas.sh
downloads. Building or using the crate never needs them โ src/generated/ is
committed.
๐ Documentation
| Getting started | Install, the five steps, a session end to end |
| Architecture | The layers, and why each is separate |
| Sessions and ordering | Which request is legal when, and what happens when one is not |
| The EXI profile | Every coding option ISO 15118 pins out of band |
| Plug & Charge | What gets signed, and what a valid signature does not prove |
| SLAC | Which station this cable is plugged into |
Embedded and no_std |
Shipping it on a microcontroller |
| FAQ | Short answers to the common questions |
The API reference is on docs.rs.
๐ค Contributing
Issues and pull requests welcome โ see CONTRIBUTING.md. A change to any wire format needs a golden vector or a spec citation; "it round-trips with itself" is not evidence that it matches what a charger will send.
โ๏ธ License
Dual-licensed under MIT or Apache-2.0, at your option.
ISO 15118 is a standard published by the International Organization for Standardization. This is an independent implementation, not affiliated with or endorsed by ISO, and no part of the standard is redistributed here.