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