Status
SCP02 is fully tested and working (19/19 hardware tests, 54/54 CI tests). SCP03 code exists in src/keystore/javacard/gp/scp03.py and src/keystore/javacard/gp/aes_cmac.py but has not been tested on any hardware.
What exists
scp03.py — Complete SCP03 implementation: NIST SP 800-108 KDF, AES-CMAC wrapping, R-MAC verification, C-DEC/C-ENC encryption. Uses ucryptolib.aes (available in MicroPython) and aes_cmac.py.
aes_cmac.py — Pure Python AES-CMAC (NIST SP 800-38B) using ucryptolib.aes as block cipher primitive.
What's missing
- No hardware test — We only have a JCOP4 card with SCP02 default keys provisioned. SCP03 keys have not been provisioned.
- No reference traces — No GPPro traces for SCP03 session establishment.
- No CI tests — No software tests verifying SCP03 crypto against known values.
Why we can't test SCP03 yet
The JCOP4 card reports SCP02 when sent INITIALIZE UPDATE with P1=0x00 (any protocol). To test SCP03:
- Use the existing SCP02 channel to send
PUT KEY commands provisioning AES-128 keys (ENC, MAC, RMAC) with a new key version number (e.g., version 2)
- Send
INITIALIZE UPDATE with P1=0x03 (explicitly request SCP03) and the new key version
- If the card accepts, capture the full APDU trace
How to help
If you have a JavaCard that supports SCP03 (most modern cards do), you can help by:
1. Capture SCP03 reference traces
# Using GlobalPlatformPro with a card that has SCP03 keys
gp -dv -install SomeApplet.cap 2>&1 | tee scp03_trace.txt
# Or just list the registry
gp -dv -l 2>&1 | tee scp03_trace.txt
2. Add trace files
Copy the trace to test/data/gp_traces/ with a descriptive name (e.g., scp03_jcop4_list.txt).
3. Add software tests
Create test/tests_native/test_scp03_crypto.py following the pattern of test_scp02_crypto.py:
- Parse session keys from the trace
- Verify KDF derivation matches
- Verify card/host cryptogram computation
- Verify MAC computation
4. (Optional) Implement PUT KEY
Add a put_key() function to enable provisioning SCP03 keys via the existing SCP02 channel. This would allow testing SCP03 on cards that only have SCP02 keys initially.
Roadmap
Related
Status
SCP02 is fully tested and working (19/19 hardware tests, 54/54 CI tests). SCP03 code exists in
src/keystore/javacard/gp/scp03.pyandsrc/keystore/javacard/gp/aes_cmac.pybut has not been tested on any hardware.What exists
scp03.py— Complete SCP03 implementation: NIST SP 800-108 KDF, AES-CMAC wrapping, R-MAC verification, C-DEC/C-ENC encryption. Usesucryptolib.aes(available in MicroPython) andaes_cmac.py.aes_cmac.py— Pure Python AES-CMAC (NIST SP 800-38B) usingucryptolib.aesas block cipher primitive.What's missing
Why we can't test SCP03 yet
The JCOP4 card reports SCP02 when sent
INITIALIZE UPDATEwith P1=0x00 (any protocol). To test SCP03:PUT KEYcommands provisioning AES-128 keys (ENC, MAC, RMAC) with a new key version number (e.g., version 2)INITIALIZE UPDATEwith P1=0x03 (explicitly request SCP03) and the new key versionHow to help
If you have a JavaCard that supports SCP03 (most modern cards do), you can help by:
1. Capture SCP03 reference traces
2. Add trace files
Copy the trace to
test/data/gp_traces/with a descriptive name (e.g.,scp03_jcop4_list.txt).3. Add software tests
Create
test/tests_native/test_scp03_crypto.pyfollowing the pattern oftest_scp02_crypto.py:4. (Optional) Implement PUT KEY
Add a
put_key()function to enable provisioning SCP03 keys via the existing SCP02 channel. This would allow testing SCP03 on cards that only have SCP02 keys initially.Roadmap
test/tests_native/test_scp03_crypto.pywith trace-based verificationtest_gp_flow.pyprofiles.pybased on card responseRelated