Verification

How iso15118 is verified: 3760 real captured messages replayed byte for byte, 395 grammars and 166 messages differed against the EXI reference implementation, layouts pinned, twelve fuzz targets, live sessions against Josev and EVerest, and every spec citation checked against the text.

Round-tripping your own encoder through your own decoder proves only that the two agree. So the codec is checked against other implementations, and against equipment: a reference implementation says whether it is right, a captured session whether the field can read it, a live peer whether a session completes.

LayerWhat it proves
Property testsdecode(encode(m)) == m and bit reader/writer duality — self-consistency only.
Layout pinsEvery SLAC message encoded with a distinct byte per field and asserted verbatim: field order, offsets, widths, reserved gaps.
Golden vectorsReal ISO 15118-20 frames from an independent C++ implementation, re-encoded byte for byte.
Differential grammarsEvery derived state and production compared against exificient, the EXI reference implementation, for all 395 element grammars — both generations and Amd 1's AC_DER sets.
Differential messagesA schema-valid instance of every message type, encoded by the reference implementation as a document and as a fragment, re-encoded byte for byte. 166 × 2.
Requirement registerEvery [V2G2-nnn] cited anywhere in the repository checked against the text of ISO 15118-2:2014 itself — 110 cited, against the standard's 852 — and every [V2G20-nnnn] against ISO 15118-20:2022 and its Amd 1:2026. scripts/requirement-coverage.sh: 56 implemented and tested, 45 implemented only, 4 cited only by tests, 5 only in documentation.
Differential certificatesChains, Ed448 chains and the -2 contract-key envelope minted by OpenSSL; -20 envelopes (secp521r1, X448) and Ed448 and SHAKE256 vectors by cryptography (OpenSSL-backed), opened here and sealed here to the same bytes (scripts/make-test-pki.sh); the TPM 2.0 contract-key blob imported by swtpm, whose signature verifies (scripts/verify-tpm-import.sh); all ten OEM provisioning leaves of Hubject's published test PKI validate to its real V2G Root under -2's rules (tests/pki_pool.rs).
Captured sessions3 760 messages from sixteen captures — dSPACE DS5366 hardware against Josev and RiseV2G — re-encoded byte for byte: ISO 15118-2 AC and DC, pause, renegotiation, sales tariff, multi-EVSE SLAC, ISO 15118-20 AC bidirectional and DC over TLS 1.3 and mutual TLS, four Plug & Charge sessions whose signatures verify, and a DIN session declined by name.
Live peersThis crate's engines on a real link: Josev 8 of 8 rows, both roles; EVerest 4 of 4, Plug & Charge included — see below.
scripts/verify-grammars.sh   all 2 / 80 / 54 / 42 / 48 / 38 / 34 / 48 / 49 element
                             grammars agree with the reference  (395 total)
scripts/verify-messages.sh   all 166 documents round-trip against the reference
                             all 166 fragments round-trip against the reference
scripts/verify-captures.sh   3760 messages decoded, 3760 re-encoded byte-identical,
                             198 DIN frames declined by name,
                             4/4 Plug & Charge authorizations verify
  • A fragment is indexed over every declared element, a document over global elements only, so the fragment half is a separate claim — and the bytes Plug & Charge signs.
  • The scripts need a JDK and the licensed schemas, so they run locally, not in CI. Each checks every schema against a pinned SHA-256 (scripts/schemas.sha256) and fails if the totals above differ from what it measured.
  • The capture corpus is GPL and is fetched, never committed. The replay also checks that string-table coding would change some captured messages, so it can see that regression.
  • scripts/generate.sh followed by git diff checks the committed codec still matches its generator.

Live peers

examples/v2g_node runs this crate's engines on a real link — SDP over a veth pair, then TCP — in a Linux container beside a peer nobody here wrote.

PeerRowsPassing
Josev 0.31.2 (Python, Apache-2.0, tests/josev.rs)Our EVCC at its SECC and its EVCC at ours; -2 and -20, AC and DC; EIM over TCP8 of 8
EVerest SIL station, everest-demo 2025.10.0 (C++, Apache-2.0, tests/everest.rs)Our EVCC at its station; -2 and -20 DC over TCP, -2 over TLS 1.2, -2 Plug & Charge4 of 4
  • Josev's EXI codec is exificient, so its rows are session evidence. EVerest's is libcbv2g, so its rows are codec evidence too.
  • In the Plug & Charge row EVerest verifies the AuthorizationReq signature this crate made.
  • TLS is the harness's: socat with OpenSSL, since ISO 15118-2's TLS suite is CBC. The crate links no TLS code.
  • Without a Docker daemon running Linux containers each test is skipped by name. Each runs in its own CI job on every pull request.
  • What the sessions found, and whose it was: tests/interop/PEERS.md.

What the grammar layers catch

Things a round trip cannot see, because encoder and decoder agree on them:

  • substitution groups — the abstract head of ISO 15118-2's body choice occupies an event code of its own;
  • mixed content — an untyped character-data production sorted after EE;
  • wildcard ordering — declared elements precede xs:any;
  • bounded repetition — maxOccurs="2048" unrolled exactly;
  • repeated choices — every branch re-offered after an occurrence;
  • string-table partitions — a value found in the global partition is not added to the local one.

Length facets are enforced both ways: six V2G types have an exact length (GenChallenge, ISO 15118-20's SessionID, the ECDH key, the contract-key envelopes), and a truncated one does not decode. See EXI.

Rules above the encoding

Each is a test:

  • the ordering graphs of both generations, including the DC renegotiation exits;
  • half-duplex in both directions;
  • session ids checked against the assigned id; ISO 15118-20 service ids mapped as EVerest's ServiceCategory assigns them, and a request refused if it comes from a message set the session did not select;
  • loop budgets armed, so an Ongoing loop that repeats promptly still ends;
  • the Plug & Charge challenge and metering-receipt bindings.

Unauthenticated peers

A frame on SDP or SLAC cannot be authenticated, so it must set neither a deadline nor a queue length:

  • a refused SDP answer does not end discovery, and an answer cannot redirect the vehicle off the link;
  • a forged SLAC attenuation report can move the choice earlier, never later;
  • every collection a peer can reach is bounded; terminal events are never dropped;
  • a malformed SLAC frame is ignored — handle_frame returns no Result. See SLAC.

SLAC has no reference implementation. tests/slac_layout.rs pins all thirteen layouts field by field, checked against EVerest's libslac; a same-width field swap in encoder and decoder passes a round trip and fails this.

Citations

scripts/verify-citations.sh  every [V2G2-nnn] cited in this repository names a
                             requirement ISO 15118-2:2014 defines  (110 of 852)
                             and every [V2G20-nnnn] one ISO 15118-20:2022
                             or its Amd 1:2026 defines

The script fetches ISO 15118-2:2014(E) and ISO 15118-20:2022(E) from a US FHWA rulemaking docket, which publishes both in full, and the free preview of Amd 1:2026, and fails on a citation that names no requirement in any of them. It writes nothing into the repository. Whether a requirement says what the code claims is checked by reading. Timing constants match ISO 15118-2 Tables 109 and 111 and ISO 15118-20 Tables 215-223. [V2G2-ED2-1664]/[V2G2-ED2-1667] cite the unpublished second edition and are outside the script's pattern.

Beyond the wire format

ConcernApproach
FuzzingTwelve cargo-fuzz targets: EXI primitives, every message decoder, fragments, V2GTP, SDP, SLAC frames, SLAC matching, X.509 certificates, OCSP responses and CRLs, the ISO 15118-20 contract-key envelope, and the station's front door from raw TCP bytes at arbitrary read boundaries. The certificate target asserts every borrowed field lies inside the input; the revocation target that no chain is accepted with a certificate shown revoked, evidence rejected, or a required status missing; the session target that any error from handle_input has already closed the session.
ProofsKani, for every input up to a stated size: split_frame returns a payload inside its input and within the ceiling, write_frame never writes past its buffer (16 bytes, any ceiling), and the EXI bit reader advances by exactly the width read or fails without moving (4 bytes, widths to 64 bits). Run locally with cargo kani.
X.509 path validationx509-limbo at 519f4bc, the suite rustls-webpki and Go run: of 9 807 cases, 8 800 reach limbo's verdict, 45 use algorithms ISO 15118 lacks, and 962 are listed with a reason in tests/x509_limbo/divergences.tsv — profile rules (819), the caller's checks such as host name and EKU (114), revocation (15), chains over three certificates (14). Run locally.
Session testsA whole DC session per generation through byte vectors with a mock clock; sequence violations, failures, pauses, timer expiry and protocol mismatch each tested.
Hostile peersPipelined bursts, unsolicited responses, forged SLAC key handover, replayed signatures.
Examplesevcc_tcp and secc_tcp complete an AC session over a real socket. v2g_node plays either role after SDP, every generation and service of the live-peer matrix; tests/v2g_node_loopback.rs completes each against itself.
Unsafe#![forbid(unsafe_code)] crate-wide.
Feature matrixcargo hack check --feature-powerset --depth 2, 160 combinations.
no_stdCI builds for thumbv7em-none-eabihf with iso2, iso20, sdp, slac, evcc, secc and pnc.
MSRVcargo check --all-targets on 1.88 in CI.

What is not claimed

  • Not conformance-tested. The test plans (EN ISO 15118-4/-5, ISO 15118-21, ISO/PAS 15118-23) are paid documents run on a bench; "verified against third implementations" is the accurate claim.
  • Not tested against production vehicles. Captures and reference stacks, live or not, are not a vehicle population.
  • Connection's buffer ceilings are not proved, only tested and fuzzed; the model exceeds what Kani can check here.
  • Two of three certificate profiles (SeccCertificate, ContractCertificate) are tested only on OpenSSL-minted chains: the public pool has no real leaf for them.

Running it yourself

cargo test --workspace --all-features
cargo hack check -p iso15118 --feature-powerset --depth 2 --no-dev-deps
cargo +nightly fuzz run session fuzz/corpus/session fuzz/seeds/session
cargo test --test josev --test everest -- --nocapture       # needs Docker

scripts/generate.sh && git diff --exit-code src/generated   # codegen has not drifted
scripts/verify-grammars.sh              # every grammar vs. the reference
scripts/verify-messages.sh              # every message, as document and fragment
scripts/verify-citations.sh             # every [V2G2-nnn]/[V2G20-nnnn] vs. the text
scripts/verify-captures.sh              # every captured message, replayed
scripts/verify-tpm-import.sh            # swtpm imports the TPM contract key and signs
scripts/fetch-x509-limbo.sh /tmp/limbo # then ISO15118_X509_LIMBO=/tmp/limbo/limbo.json cargo test --test x509_limbo
cargo kani -p iso15118 --all-features   # the bound proofs

scripts/fetch-schemas.sh downloads the XSDs, which ISO publishes freely. The citation check needs pdftotext and network access; the capture replay tshark; the live peer Docker. None of this is needed to build or use the crate — src/generated/ is committed.