Skip to content

Add jCardsim test suite for all applets (official + THD-89) - #5

Open
3rdIteration wants to merge 1 commit into
mainfrom
add-jcardsim-test-suite
Open

3rdIteration wants to merge 1 commit into
mainfrom
add-jcardsim-test-suite

Conversation

@3rdIteration

Copy link
Copy Markdown
Owner

Summary

Adds a jCardsim-based test suite that exercises the Satochip, Satodime and Seedkeeper applets in both the official and THD-89 builds, plus the cross-applet Seedkeeper -> Satochip secure import. 318 tests, all passing.

Also fixes the two open issues:

What's included

tests/ is a Gradle multi-project (wrapper included, JDK 8):

  • testkit/common - jCardsim Card wrapper, a full secure-channel client (ECDH handshake, ephemeral-pubkey recovery from the self-signature, 0x82 wrap/unwrap), crypto/secp256k1 helpers, RFC known-answer tests.
  • testkit/tests-* - per-applet suites shared by both forks:
    • secure channel: handshake, wrapped round-trips, wrong MAC / IV / length, uninitialized.
    • Satochip: status, setup, PIN, label, BIP32 seed import/reset, authentikey, extended key, message signing, 2FA, trusted-pubkey + encrypted-secret import, PKI, challenge-response.
    • Satodime: status, setup, keyslot seal/unseal/privkey/reset/transfer, metadata, contactless unlock counter + HMAC unlock code, PKI.
    • Seedkeeper: status, setup, PIN, label, NFC policy, masterseed generation, plaintext import/export, listing, reset, storage layer (ObjectManager/MemoryManager/Logger) unit tests, authentikey, PKI.
  • applet-<name>[-thd89] - one module per variant compiling the real applet sources; integration-pairing[-thd89] - Satochip + Seedkeeper on one simulated card.

CI

.github/workflows/ant.yml now has a test job (recursive checkout, JDK 8, ./gradlew test, report upload) in addition to the existing Ant build job, which now generates and verifies the checksum manifest (issue #2).

Notes

  • The THD-89 regression tests assert the fixed behaviour, so they depend on the submodule PR Fix THD-89 trusted_pubkey allocation (Seedkeeper secure import) SatochipApplet#3. This branch's submodule pointer already references that commit (8693b23); merge the submodule PR without squashing (or update the pointer after merge) so the SHA stays reachable.
  • jCardsim implements every primitive the applets need, so it cannot reproduce hardware-only failures (missing ALG_EC_SVDP_DH_PLAIN_XY, CAP memory-fit, side channels). CAP files are still built and checksum-verified by the Ant job.
  • The applet change itself (issue THD-89 Satochip cannot import a Seedkeeper pubkey #3) should be verified on a real THD-89 card before merging the submodule PR.

Adds tests/: a jCardsim (JC 3.0.5) test suite covering the Satochip, Satodime and Seedkeeper applets in both the official and THD-89 builds, driven over APDUs including the full secure channel. 318 tests across 6 per-variant modules plus cross-applet pairing modules.

Highlights:

- Shared harness with a secure-channel client (ECDH handshake, ephemeral pubkey recovery, 0x82 wrap/unwrap) and RFC known-answer tests.

- Per-applet suites: secure-channel negatives, setup/PIN/label/status, Satochip BIP32/signing/2FA/PKI/trusted-pubkey import, Satodime keyslot lifecycle + contactless unlock-code HMAC, Seedkeeper secrets/NFC policy/storage layer.

- End-to-end Seedkeeper -> Satochip secure seed import (INS 0xA8 -> 0xAA + 0xAC), a regression for the THD-89 trusted_pubkey bug (issue #3).

- Fix the sha256sums.txt artifact so it verifies (issue #2) and add a CI test job.

The THD-89 trusted_pubkey fix lives in the applets/satochip-thd89 submodule (3rdIteration/SatochipApplet#3).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant