JavaCard ARA-M
Minimal single-rule Java Card ARA-M (SEAC access rule) applet for Android OMAPI access control
jc-ara-m — bounded Java Card ARA-M applet
jc-ara-m is a bounded GlobalPlatform Secure Element Access Control (SEAC)
ARA-M applet. Its instance AID is the standard ARA-M AID
A00000015141434C00. The installed profile holds up to 16 active rules in a
17-record copy-on-write arena:
- idempotently upsert validated
REF-AR-DOvalues by exactREF-DO; - delete by AID, exact
REF-DO, or the complete catalog; - return active rules to Android’s
AccessControlEnforcer; - mutate only through authenticated Security Domain personalization;
- receive personalization data through the standard
org.globalplatform.Applicationcontract; - support empty, SHA-1, and SHA-256
DeviceAppID-REF-DOvalues without changing the persistent representation.
The applet implementation does not install anything on hardware. The repository
also ships a host provisioner whose default modes are read-only or offline
dry-runs. Physical authenticated mutation requires explicit --execute, a
0600 Security Domain credential file, and—during standard-AID migration—the
exact maintenance acknowledgement emitted by migration-plan.
Architecture
The accepted multi-rule design is specified in
docs/architecture/multi-rule-seac-architecture.md.
Its focused lifecycle diagrams live under diagrams/.
WP1 implements the bounded catalog, F0/F1, and atomic rule/refresh/revision
publication. WP2 streams that catalog through full-length FF40 and raw
FF60 continuation responses without allocating a second catalog buffer.
Installation-time capacity
The active-rule capacity R is read at install time from the GlobalPlatform
application-specific install parameter block, so one CAP covers several capacity
profiles without a rebuild. The block carries the proprietary TLV 80 01 R,
optionally still inside its C9 container:
| Install parameters | Resulting R |
|---|---|
| absent or empty | 16 (default) |
80 01 R, 1 <= R <= 64 |
R |
80 01 R, R > 64 |
64 (compiled maximum, clamped) |
| anything else | rejected 6A80, installation fails |
Every buffer is allocated once, in the constructor, from the resolved R; the
catalog never grows afterwards. The manifest capacity used by the host
provisioner must match the R the instance was installed with — a mismatch
surfaces as a 6A84 at commit time. Format and rationale:
docs/architecture/multi-rule-seac-architecture.md
§3.2.
Project layout
jc-ara-m/
├── diagrams/ # PlantUML lifecycle views
├── docs/architecture/ # Architecture decisions
├── host/ # Go desired-state provisioner + migration controls
├── scripts/
│ └── build-migration-assets.sh # signed rollback/release/canary CAP builder
├── README.md
├── UNRESOLVED_QUESTIONS.md # Evidence gates not settled by design
└── jc/
├── build.gradle
├── cap-build.xml
├── build-cap.sh # build the real CAP on the fly (artifacts are not stored)
├── gradlew
└── src/
├── main/java/works/relux/jcaram/
│ ├── AraMApplet.java
│ └── AraMJCApplet.java
├── test/java/works/relux/jcaram/
│ ├── AraMAppletTest.java
│ ├── AraMPersonalizationFuzzTest.java # TLV validator property/fuzz harness
│ ├── InstallParametersTest.java
│ ├── SeacParserOracleTest.java
│ └── Sha256VectorTest.java
└── test/resources/works/relux/jcaram/
└── cts-seac-rules.txt # 41 real Android-CTS REF-AR-DOs, fuzz seeds
The CAP package AID is A00000015141434C; the installable applet instance AID
is A00000015141434C00.
Host desired-state provisioner
host/cmd/aram-provisioner treats desired/current catalogs as maps keyed by
exact REF-DO. It validates complete bounded-profile E2 rules, rejects
duplicate keys, sorts by AID bytes and then DeviceAppID length/bytes, and emits
the fail-closed order updates -> deletes -> adds. Every add/update is one
complete F0; every obsolete exact key is one F1. Output contains only
counts, lengths, and truncated SHA-256 identifiers—not AIDs, certificate
hashes, refresh values, APDUs, or Security Domain keys.
Manifest files contain policy material and must be regular, non-symlink files with mode 0600. Their schema is:
{
"capacity": 16,
"rules": [
{"ref_ar_do": "<complete E2 REF-AR-DO hex>"}
]
}
Offline plan, with no reader access:
cd host
go run ./cmd/aram-provisioner plan \
--current /secure/current.json \
--desired /secure/desired.json
Read/re-diff from a card through jc-harness; add --execute and a secure
credential file only inside the authorized maintenance flow:
go run ./cmd/aram-provisioner reconcile \
--desired /secure/desired.json \
--reader OMNIKEY
go run ./cmd/aram-provisioner reconcile \
--desired /secure/desired.json \
--reader OMNIKEY \
--execute \
--credentials /secure/sd-credentials.json
Catch-all guard
The applet stores the SEAC catch-all reference — a zero-length AID-REF-DO
(4F 00), matching every SE applet — like any other exact key. The policy
question of whether such a rule may grant access is answered on the host,
where it is reviewable and shows up in a manifest diff: plan and reconcile
refuse a desired rule with a zero-length AID whose AR-DO grants anything
(D0 01 01 or an APDU filter list), naming the offending rule, unless
--allow-catch-all is passed. A catch-all deny (D0 01 00) needs no flag,
and an already-installed catch-all can always be diffed away without one.
The execution path opens one authenticated gp-t0-helper secure-apdu session,
enters INSTALL [for personalization], and sends the deterministic N-command
manifest. If the process or transport fails, the command reports unknown state;
rerunning always re-reads FF40/FF60 and recomputes the remaining diff. It
never replays an assumed suffix. Final readback must equal the normalized
desired set exactly.
v0.1.1 migration controls
Build automation creates three signed, digest-pinned CAPs: v0.1.1 rollback
from the immutable tag, the multi-rule standard-AID release, and an
alternate-AID canary. It also writes toolchain manifests, a canary-evidence
template whose physical gates are initially false, and a migration-config
template. --dry-run validates the asset plan without building or touching a
card:
scripts/build-migration-assets.sh \
--output-dir .temp/migration-assets/release \
--toolchain /abs/path/to/cap-toolchain \
--signing-key /secure/path/release-signing.pem \
--canary-package-aid A00000015141434D \
--canary-instance-aid A00000015141434D00 \
--dry-run
The guarded runbook is inspectable without hardware:
cd host
go run ./cmd/aram-provisioner migration-plan \
--config /secure/migration-config.json \
--desired /secure/desired.json
Execution is rejected until rollback/canary/release digests, detached
signatures, toolchain manifests, and every canary evidence check match the
configured capacity. Each toolchain manifest binds the CAP digest, source
commit plus working-tree diff digest, Java/Java Card toolchain identity,
expected package/applet AIDs, and the active-rule capacity R the CAP was
built with together with its compiled ceiling.
The capacity in a desired-state manifest is a claim about the applet that will
enforce it, so both migration-plan and migrate require --desired and
refuse to produce a plan when that claim disagrees with the pinned release CAP.
The check runs on the planning path, so a dry run catches the disagreement
before any card is mutated; without it the same mismatch only appears as a
mid-rollout 6A84. reconcile --migration-config FILE applies the same binding
to steady-state runs. The forward path exports the current v0.1.1 rule to a
0600 task-scoped file, deletes/installs through authenticated
gp-t0-helper delete-if-present/install, restores the exported rule first,
then reconciles the full desired catalog. Any failure after standard-package
deletion runs the explicit rollback branch: remove a partial release, reinstall
v0.1.1, restore the exported rule through authenticated personalization, and
verify exact catalog plus raw selected-applet E2=6982 denial. Rollback uses a
fresh bounded recovery context, independent of forward-operation cancellation
or deadline expiry, so a timed-out forward command cannot suppress recovery.
Android/SEAC APDUs
Android selects the ARA-M and performs the refresh query before fetching all rules.
| Operation | Command APDU | Successful response data |
|---|---|---|
| SELECT ARA-M | 00 A4 04 00 09 A00000015141434C00 |
empty |
| GET DATA [refresh tag] | 80 CA DF 20 00 |
DF 20 08 <8-byte tag> |
| GET DATA [all] | 80 CA FF 40 00 |
FF 40 <full BER length> <first E2 bytes> |
| GET DATA [next] | 80 CA FF 60 00 |
next raw catalog bytes |
Raw STORE DATA is not a runtime ARA-M command. Sending
80 E2 90 00 <Lc> <F0 command DO> directly to the selected applet is rejected
with 6982 (Security status not satisfied) and cannot change the catalog or
refresh tag. Rule mutation is available only when an authenticated Security
Domain personalization flow delivers the same command buffer through
Application.processData(...).
The implementation accepts the GlobalPlatform proprietary CLA ranges
80-8F, C0-CF, and E0-EF. Android currently uses 80.
Access-rule TLV layout
GET DATA [all] wraps the active rules in Response-ALL-AR-DO:
FF40 <length> Response-ALL-AR-DO
E2 <length> REF-AR-DO
E1 <length> REF-DO
4F <0|5..16> <target applet AID> AID-REF-DO
C1 <0|20|32> <DeviceAppID> DeviceAppID-REF-DO
E3 <length> AR-DO
D0 <length> <rule> APDU-AR-DO (mandatory)
DB 08 <8-byte permission mask> PERM-AR-DO (optional)
AR-DO members are validated in SEAC member order. D0 is mandatory and comes
first; DB is optional, must carry exactly eight bytes, and must be the last
member. Anything else — DB before D0, a DB length other than 8, a repeated
DB, a DB without D0, or trailing bytes after DB — is rejected with
6A80 and changes neither the catalog nor the refresh tag. NFC-AR-DO (D1)
remains out of this profile.
A zero-length 4F is the SEAC catch-all reference and is stored, replaced, and
deleted through its exact REF-DO like any other key; sub-AID lengths 1..4
remain 6A80. The F1 delete-by-AID selector still requires a real 5..16-byte
AID, because a zero-length selector would be an ambiguous second spelling of
the empty delete-all value.
For the phase-1 permissive rule:
C1 00is the generic device-application reference;D0 01 01means APDU access is always allowed;- the target
4Fvalue is the HelloApplet AIDF0000000AA01.
The exact REF-AR-DO is:
E2 11
E1 0A
4F 06 F0000000AA01
C1 00
E3 03
D0 01 01
After provisioning, GET DATA [all] returns:
FF 40 13 E2 11 E1 0A 4F 06 F0000000AA01 C1 00 E3 03 D0 01 01
FF40 advertises the complete concatenated active-rule length in BER short,
81, or 82 form. Its first response carries as many catalog bytes as fit.
If bytes remain, Android repeats FF60; each successful response contains only
the next raw bytes and status 9000, with no repeated FF40 tag or length.
One transient continuation is bound to the originating logical channel. A
second channel receives 6984; FF60 without a live continuation receives
6985. A catalog mutation invalidates the continuation by revision: the next
bound-channel FF60 returns 6984 once and clears it. A new same-channel
FF40 restarts from offset zero, and reset/deselect clears transient read state.
The DF20 refresh tag is eight bytes generated at installation and changed
atomically with every real catalog mutation. A byte-identical F0 retry and an
empty F1 00 retry are idempotent and leave refresh/revision unchanged.
Authenticated STORE DATA provisioning APDUs
STORE DATA carries one complete F0 upsert or F1 delete command.
P1=90 means the last BER-TLV-formatted block is present, and P2=00 is block
zero. This implementation accepts one complete short-APDU block; the supported
rule forms are far below that limit.
The command buffer for the phase-1 permissive HelloApplet rule is:
80 E2 90 00 15
F0 13
E2 11
E1 0A
4F 06 F0000000AA01
C1 00
E3 03
D0 01 01
As one hex string:
80E2900015F013E211E10A4F06F0000000AA01C100E303D00101
Send these two APDUs in one authenticated gp-t0-helper secure-apdu Security
Domain session. The first enters personalization for this ARA-M instance; the
second is the exact STORE DATA command above:
80E620000F000009A00000015141434C00000000
80E2900015F013E211E10A4F06F0000000AA01C100E303D00101
AraMJCApplet implements org.globalplatform.Application, so the Security
Domain delivers the second command data to processData(...) only after the
authenticated INSTALL [for personalization] step succeeds. Do not select the
ARA-M instance and send the STORE DATA command directly: the applet’s raw ISO
dispatch rejects INS E2 with 6982 by design.
Sending the same exact REF-DO with D0 01 00 replaces only that key’s APDU
rule with NEVER:
80E2900015F013E211E10A4F06F0000000AA01C100E303D00100
The phase-2 SHA-1 certificate-bound shape replaces C1 00 with
C1 14 <20-byte certificate hash> and updates the enclosing lengths:
80 E2 90 00 29
F0 27
E2 25
E1 1E
4F 06 F0000000AA01
C1 14 <20-byte SHA-1 certificate hash>
E3 03
D0 01 01
For SHA-256, use C1 20 <32-byte hash>; the corresponding enclosing lengths
are E1 2A, E2 31, F0 33, and APDU Lc=35.
A rule may also carry the optional PERM-AR-DO after its APDU-AR-DO. This is
the Android carrier-privilege rule shape — a SHA-256 signing-certificate key
plus an eight-byte permission mask:
80 E2 90 00 3F
F0 3D
E2 3B
E1 2A
4F 06 F0000000AA01
C1 20 <32-byte SHA-256 certificate hash>
E3 0D
D0 01 01
DB 08 <8-byte permission mask>
That rule serialises to 61 bytes. The worst shape this profile accepts — a
16-byte AID, a SHA-256 hash, two 8-byte APDU filter/mask pairs, and a
PERM-AR-DO — serialises to 86 bytes, still inside the 96-byte record.
Authenticated deletion uses these F1 command forms:
F1 00 delete all rules
F1 <len> 4F <len> <AID> delete every rule for one applet AID
F1 <len> E1 <len> 4F ... C1 ... delete one exact REF-DO key
Adding a new key at 16 active rules returns 6A84; exact-key overwrite still
uses the seventeenth copy-on-write spare. A targeted delete with no match
returns 6A88. Neither rejection changes the catalog, refresh tag, or revision.
Within the authenticated personalization callback, the applet validates the
complete nested TLV before mutating persistent state. Malformed data returns
6A80 and leaves the prior catalog and refresh tag unchanged. At transaction
depth zero the applet stages into an inactive record and owns the small metadata
transaction. Inside a caller/Security-Domain transaction it atomically journals
the complete candidate record and leaves commit/abort ownership with the caller.
In a hardware flow, send provisioning through an authenticated GlobalPlatform
administrative channel. The applet intentionally does not invent a second
proprietary authentication protocol around standard SEAC STORE DATA.
Simulator tests
From jc/:
./gradlew clean test --no-daemon
The jCardSim suite proves:
- SELECT returns
9000; - the applet implements the Security Domain personalization contract;
- raw
INS E2is rejected with6982without changing rules or refresh tag; - the actual
Application.processData(...)callback accepts full-buffer personalization and honors a non-zero buffer offset; - unprovisioned GET DATA [all] returns
FF4000; - small catalogs complete in one
FF40response, while large catalogs stream every active arena record through rawFF60responses with9000; FF40uses short/81/82BER lengths at 127/128/255/256 boundaries;- continuation is logical-channel-bound, restarts on same-channel
FF40, and clears on reset; - mutation during a read returns
6984once and invalidates the stale session; FF60beforeFF40or after a completed read returns6985;F0adds several exact keys, overwrites one key, and treats identical retries as no-ops;F1deletes by AID, exactREF-DO, and all, including no-match semantics;- capacity rejects the seventeenth active key while allowing a full-catalog overwrite through the spare record;
- the installation-time capacity
Rdefaults to 16 when absent, is honoured in range (bare orC9-wrapped), is clamped above the compiled maximum of 64, and fails installation on a malformed parameter block, with arena and bitmaps sized once from the resolved value (InstallParametersTest); - every real mutation changes
DF20, while rejected/no-op commands do not; - caller-owned transaction composition leaves transaction ownership outside the applet;
- corruption of every inactive spare remains unreachable and a later upsert safely overwrites one spare;
- SHA-1 and SHA-256 certificate-bound keys coexist;
- the zero-length-AID catch-all is stored, replaced in place, and deleted by its
exact
REF-DO, while sub-AID lengths 1..4 and a zero-lengthF1AID selector are rejected with6A80without changing catalog metadata; - malformed and unsupported personalization do not clobber existing state.
jCardSim 3.0.5.9 tracks transaction depth but does not journal array writes, so it cannot prove outer-transaction rollback. JC304 CAP verification proves the transactional APIs convert; real abort/tear behavior remains a physical-card acceptance gate.
JUnit XML and HTML reports are written under jc/build/test-results/test/ and
jc/build/reports/tests/test/.
Personalization fuzz harness
AraMPersonalizationFuzzTest runs as part of the normal test task. The
hand-rolled TLV validator behind Application.processData is the only code that
consumes attacker-influenced bytes, so it is driven with a bounded,
deterministic-seeded corpus that asserts three invariants on every case:
- only
ISOExceptionescapes, with a status word from the small admitted set (6700,6581,6981,6A80,6A84,6A88) — any otherThrowablefails the build; - on any rejection the observable catalog, the refresh tag and the catalog revision are bit-identical to the entry state, and the caller’s input buffer comes back untouched;
- the applet stays usable — after every rejection a well-formed store still lands and deleting it returns the catalog exactly where it was.
Every case runs in two buffer shapes: padded (the command at a non-zero
offset inside a larger buffer, as a Security Domain hands over its APDU buffer)
and tight (the array ends exactly where the command does). The tight shape is
what actually tests the parser’s bounds arithmetic — in the padded shape a read
past the command end still lands inside the allocated array and returns a 0xA5
guard byte, whose top bit is set, so readLength rejects it and the over-read is
laundered into a clean-looking 6A80. Mutation runs confirmed this: deleting the
end > limit check from checkedEnd, or the bounds check from readLength,
survived the entire padded-only corpus and are caught immediately once the tight
shape is included.
shapesRejectedByDesignAreStillRejectedAtTheRuleTheyName closes the
complementary blind spot. Every invariant above constrains how the applet
rejects; none of them requires that anything be rejected at all, so a parser
that silently grew more permissive would sail through the corpus (the accepted
branch just resets the baseline and moves on). That test asserts the 17
SEAC-plausible shapes the applet refuses by design — unimplemented members,
wrong member order, out-of-range lengths, long-form lengths, trailing bytes, a
third AR-DO member — are still refused. A shape that becomes legitimately
supported must move out of that list rather than be quietly accepted.
Asserting that a shape is rejected is not enough, and the gap was a real
defect rather than a theoretical one: three entries of the first version of the
list declared BER lengths that disagreed with their own content (E2 claiming 26
bytes over 25, E3 claiming 15 over 12), so upsert’s outer checkedEnd threw
them out before the member rule named in the entry’s comment was ever consulted.
Each passed for the wrong reason, and each would have kept passing with the rule
it claimed to guard deleted from the applet — the same false comfort the harness
exists to remove. Three independent facts are therefore pinned per entry, any one
of which falsifies that failure mode on its own:
- the rejection site — the
AraMAppletframes on the stack at the refusal, asrequireTag<-validateArDo<-upsert<-store, together with the exact status word. A shape refused upstream reportscheckedEnd<-upsert<-storeand fails; - its own structure —
byDesignRejectedShapesCarryOnlyTheStructuralDefectTheyNamewalks each encoding as BER with a checker independent of the applet, and every declared length must span exactly its content. The two entries whose named defect is the length encoding pin the exact disagreement instead of being waved through; - attribution —
byDesignRejectedShapesAreAcceptedOnceTheirNamedPropertyIsRepairedstores a repair that touches only the named property and requires it to be accepted, so the refusal is caused by that property and not by a second flaw living in the same method.
theByDesignRejectionInventoryIsPinnedAndCoversEveryRejectionSite pins the entry
count and the set of rejection sites covered. That count is deliberately not a
completeness claim — the rejection surface is every shape the grammar refuses,
which is unbounded and unenumerated here. What it buys is that dropping an entry
to turn a red build green has to be a visible edit, and that no rejection site the
parser has is left without a by-design witness.
A fourth invariant is asserted by the pass that runs the corpus inside a
transaction the applet does not own: it must never commit or abort that
transaction. That pass also covers the other half of the write side —
upsert branches on JCSystem.getTransactionDepth(), and at depth one it skips
the non-atomic staging and joins the caller’s commit instead. Rejections there
are checked through a commit rather than an abort, which is both the stronger
claim (committing publishes anything that was staged, so an unchanged catalog
proves nothing was) and the only honest one available: jCardSim 3.0.5.9 does not
journal persistent array writes, so abortTransaction does not roll them back
and an abort-based assertion would pass for reasons unrelated to this applet.
The corpus is seeded with real encodings rather than random bytes:
jc/src/test/resources/works/relux/jcaram/cts-seac-rules.txt holds all 41
REF-AR-DOs extracted verbatim from cheeriotb/aram-cardlet’s Android Secure
Element CTS catalog — valuable precisely because it mixes shapes this applet
accepts with shapes it deliberately rejects (zero-length catch-all reference,
all-FF wildcard AID with a carrier-privilege PERM-AR-DO, 8/16-byte APDU
filter/mask pairs, 20-byte certificate hashes). Those seeds are extended with
hand-written unsupported SEAC shapes (NFC-AR-DO, PKG-REF-DO, long-form BER
lengths, reordered members) and then mutated by truncation, length-field
corruption, tag substitution, bit flips, byte insertion/deletion, splicing and
nesting-depth abuse. The invariants are checked both with a small baseline
catalog and with the catalog provisioned to capacity, which is a different parser
state: every stored record is re-parsed on each upsert.
Install-parameter fuzz harness
AraMInstallParameterFuzzTest covers the applet’s second attacker-influenced
parser, AraMJCApplet.resolveActiveRuleCapacity, which reads the active-rule
capacity R out of the GlobalPlatform installation parameter array. It runs in the
same test task from a deterministic corpus (~422 cases, ~844 executions across
the two buffer shapes) built from ten well-formed parameter blocks — absent
block, bare 80 01 R, C9-wrapped, at and over the compiled maximum — under the
same mutators.
The invariant is inverted relative to the personalization path. There, a rejection must be a no-op, because the catalog is already live. Here there is no prior state to preserve; the danger is the opposite one — a malformed block that is quietly tolerated and silently yields a default capacity nobody asked for. An operator who requested R=48 and got R=16 because a byte was mangled in transit would not find out until the seventeenth rule failed to store on a card already in the field. So:
- only
ISOExceptionescapes (asserted at the parser boundary, since jCardSim wraps install-time throws inSystemExceptionand would erase the distinction); - a returned capacity is always in
1..MAX_ACTIVE_RULE_CAPACITY— never zero, never over the compiled maximum; - a block the parser refuses also fails the real installation and leaves no instance registered;
- an accepted block yields an instance whose reported capacity, arena and bitmaps are sized from exactly the capacity the parser resolved.
everyEncodableCapacityByteIsRefusedHonouredOrClamped walks all 256 capacity
bytes so the boundary cannot be missed by sampling: 0 refused, 1..64
honoured, 65..255 clamped. aPresentButMalformedBlockNeverSilentlyYieldsTheDefaultCapacity
pins the specific failure mode above — an absent block legitimately means “use
the default”, but a block that is present and corrupt must never resolve to it.
anInstallArrayTruncatedBeforeTheParameterBlockIsRejectedRatherThanDefaulted
covers the other half of the same risk: every prefix of a well-formed array that
stops short of the parameters length byte, plus a bare C9 container tag with no
length behind it.
Invariants 1–4 are all upper bounds — they constrain what the parser may do
when it accepts or rejects, but none of them says anything must be rejected, so
a parser that gradually stops rejecting things would stay green.
theCorpusAcceptRejectDecisionMatchesItsPinnedGoldenVector closes that gap by
making the corpus’s own verdict the assertion: every execution contributes
A<capacity> or R<statusWord> to a vector that is counted, histogrammed and
SHA-256 digested, and the summary is pinned in the test. The same verdicts are
pinned per case in
jc/src/test/resources/works/relux/jcaram/install-fuzz-golden-decisions.txt.
When it fails, it is not a flake. Either the parser changed its mind about an
input — decide whether that is intended and, if so, re-pin in the same commit as
the parser change — or the corpus construction changed, in which case re-pin and
say so. Never re-pin to turn red green without naming which inputs moved and why,
which is exactly why a digest alone is not the failure message: a hash can only
say that something moved, leaving “identify which inputs moved” as an unaided
bisect and, in practice, an invitation to re-pin and move on. So the failure names
the first twelve cases that changed their mind, with the label that reproduces
each, and writes the full observed vector to
build/reports/install-fuzz-observed-decisions.txt ready to copy over the
resource. Under either soak property the test skips rather than fails, since it is
pinned to the default corpus.
The committed personalization run is ~2325 cases — ~4650 executions across the two buffer shapes — and both harnesses together finish in well under a second. To widen a run deliberately — for example when vetting a new default seed (both harnesses read the same two properties):
./gradlew test --tests '*AraMPersonalizationFuzzTest*' --no-daemon \
-Param.fuzz.seed=0xDEADBEEF -Param.fuzz.mutants=64
Both properties are unset in CI, so the checked-in corpus stays reproducible and
a failure reproduces from the case label and hex the assertion prints. Widening
the run is worth doing when the harness changes: a soak at
-Param.fuzz.seed=0x1234 is what caught the harness asserting byte-exact catalog
equality across a re-provisioning. Record placement rotates with the catalog
revision (findInactiveRecord starts its scan at catalogRevision % recordCount),
so the same rule set legitimately comes back in a different slot order. The
catalog is a set of rules and no host may key on its order;
reprovisionedCatalogKeepsItsRuleSetAndAddressabilityRegardlessOfSlotOrder pins
that, along with the part that must not move — every rule stays individually
addressable by its exact REF-DO whatever slot it landed in.
CAP build
Building a real CAP needs an external Java Card toolchain (ant-javacard.jar
plus an Oracle Java Card SDK kit). It is not vendored here. Point the build
at it via -Dtoolchain.dir=/abs/path, the JC_CAP_TOOLCHAIN env var, or a
local jc/.toolchain/ directory (Ant resolves them in that order). The
toolchain layout cap-build.xml expects:
<toolchain.dir>/
├── ant-javacard.jar
└── oracle_javacard_sdks/
└── <jckit.name>/ # e.g. jc304_kit, jc320v25.1_kit
The target UICC uses Java Card 3.0.4. The CAP is a build artifact — it is not
stored in the repo (artifacts/ is gitignored); build it on demand with the
wrapper script, which wires JDK 11 and the toolchain and runs the Ant target:
cd jc
JC_CAP_TOOLCHAIN=/abs/path/to/cap-toolchain ./build-cap.sh
# other kit/suffix: ./build-cap.sh --jckit jc320v25.1_kit --suffix ''
Or drive Ant directly:
cd jc
./gradlew --no-daemon prepareCapDependencies
JDK11=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home
JAVA_HOME="$JDK11" PATH="$JDK11/bin:$PATH" \
JC_CAP_TOOLCHAIN=/abs/path/to/cap-toolchain \
ant -f cap-build.xml \
-Djckit.name=jc304_kit \
-Dcap.suffix=-jc304 \
-Dglobalplatform.javacard.jar="$PWD/build/cap-dependencies/javacard-1.1.jar" \
dist
Outputs (created fresh under the gitignored artifacts/caps/):
jc/artifacts/caps/jc-ara-m-0.1-jc304.cap;jc/artifacts/caps/jc-ara-m-0.1-jc304.jca.
cap-build.xml uses ints="false". Main applet code has short-typed array
indices and sizes, no System.arraycopy, and no string-bearing exceptions.
Passing jCardSim is not treated as converter proof; the Ant target runs the
Java Card converter and CAP verifier.
Tools
-
Go (
host/) — builds and tests the desired-state provisioner and migration controls. Rungo test ./...,go vet ./..., andgo build ./cmd/aram-provisionerfromhost/; normal Go build/test outputs stay in the Go cache, while an explicit-ooutput should go under.temp/. -
jc-harness— forced-T=0 read-onlySELECT/FF40/FF60/DF20catalog access and raw-STORE-denial verification. Invoked byaram-provisioner; it does not implement GlobalPlatform secure-channel crypto. -
gp-t0-helper— forced-T=0 GlobalPlatform authenticatedsecure-apdu/install/delete-if-presentoperations. The provisioner never uses its unauthenticated rawapdupath for rule mutation. -
OpenSSL +
scripts/build-migration-assets.sh— detached CAP signatures and public-key verification inputs. Generated release/rollback/canary assets and task evidence belong under task-scoped.temp/, not in git. -
Gradle wrapper (
jc/gradlew) — compiles the applet against jCardSim and runs JUnit 5 tests, and resolves the GlobalPlatform Java Card API used by the CAP converter. Run./gradlew clean test --no-daemonfromjc/; output goes tojc/build/. -
jCardSim (
com.klinec:jcardsim:3.0.5.9) — simulator used byAraMAppletTest; Gradle resolves it from Maven Central. -
Personalization fuzz harness (
AraMPersonalizationFuzzTest) — property/fuzz gate over the TLV validator, run by the normaltesttask. Widen a run with-Param.fuzz.seed=.../-Param.fuzz.mutants=...; see “Personalization fuzz harness” above. Seeds live injc/src/test/resources/works/relux/jcaram/cts-seac-rules.txt. -
Install-parameter fuzz harness (
AraMInstallParameterFuzzTest) — the same gate overAraMJCApplet.resolveActiveRuleCapacity, with the inverted invariant (a malformed block must fail installation loudly and register nothing). Carries a pinned accept/reject golden vector, so an over-accepting parser fails the build rather than passing quietly; the pin is skipped under either soak property. Same two soak properties; see “Install-parameter fuzz harness”. -
Ant + ant-javacard (
jc/cap-build.xml) — converts and verifies a real Java Card Classic CAP. Run the JDK 11 command above; output goes tojc/artifacts/caps/. -
PlantUML (
diagrams/**/*.puml) — validates and renders the multi-rule lifecycle views. Runplantuml -checkonly diagrams/plantuml/sequence/*.puml diagrams/plantuml/state/*.pumlfrom the repository root; optional review renders go under.temp/TASK-260719-3r17pa/plantuml/.
References
- GlobalPlatform Secure Element Access Control v1.1 public review
- AOSP AccessRuleApplet
- AOSP AraController
- AOSP UICC carrier privileges
- Multi-rule SEAC architecture
License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2026 Alexey Grigorev
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.