scll_core/lib.rs
1//! # scll-core
2//!
3//! Hardware- and crypto-free core of the Simple Card Lifecycle Library.
4//! Holds transport/backend **traits**, `GlobalPlatform` command builders, the
5//! SCP02/SCP03 state machines (state only — crypto is delegated to a backend),
6//! the CAP parser, and the public model/report/error types.
7//!
8//! Design reference: `docs/pdd.md`. Section numbers in module docs refer
9//! to that document.
10//!
11//! ## `no_std`
12//! This crate is `no_std` and **alloc-free**: no `extern crate alloc`. Every
13//! former `Vec`/`String` is a fixed-capacity `heapless` collection sized from
14//! [`limits`]. `std` is enabled only under `cfg(test)` so dev-dependencies
15//! (e.g. `proptest`, §10.4) and host-side tests can use it; the shipped library
16//! never links `std`. Concrete transports (`scll-transport-pcsc`/`-jcsim`) are
17//! separate `std` host crates and are not part of an embedded build.
18//!
19//! ## Testability (PDD §3.5)
20//! Every byte-level transform here is a pure function with no transport and no
21//! crypto dependency, so it is unit-testable and fuzzable directly.
22
23#![cfg_attr(not(test), no_std)]
24#![forbid(unsafe_code)]
25
26// --- Capacity constants for the no_std/heapless build ---
27pub mod limits; // fixed buffer/collection capacities (wire-level + product caps)
28
29// --- Public model & API surface ---
30pub mod error; // §8 ScllError / WarningKind / BackendError
31pub mod model; // §6 CardInfo and friends
32pub mod report; // §7 per-function *Report and *Params types
33
34// --- Primitive transforms (pure; §3.5) ---
35pub mod aid; // Aid newtype (5..16 bytes, ISO/IEC 7816-5)
36pub(crate) mod hexfmt; // Debug helper: render raw byte fields as hex strings
37pub mod tlv; // BER-TLV parse/encode
38
39// --- Abstractions implemented outside the core ---
40pub mod backend;
41pub mod transport; // §3.2 Transport trait // §3.3 split backend traits
42
43// --- GlobalPlatform wire layer ---
44pub mod cap; // §5.4a CAP-file parser (JC VM Spec v3.1 Ch. 6)
45pub mod command; // §5 APDU builders (SELECT, GET DATA/STATUS, PUT KEY, DELETE, INSTALL, LOAD, SET STATUS)
46pub mod lifecycle;
47pub mod response; // §5.2 card-response parsers (CRD '66', CCI '67', GET STATUS 'E3', key-info '00E0')
48pub mod scp; // §4.3 selection rule + §5.9 SCP02/03 state machines // §5.11 card life-cycle transition state machine
49
50// --- High-level workflow orchestration ---
51pub mod workflow; // §5 steps 1–12 (discover, keys, ssd, applet, open_scp, transmit, card_status)
52
53/// Library version string, surfaced here instead of stamped on every report
54/// (PDD §7: audit metadata belongs in a tracing span or this constant).
55pub const VERSION: &str = env!("CARGO_PKG_VERSION");
56
57/// Spec baseline this crate targets (PDD front-matter).
58pub const SPEC_BASELINE: &str = "GPCS v2.3.1; Amendment D v1.1.2 (SCP03); Amendment E v1.0.1";