feat: IssuerAuth verify at AD finalize + issuer pubkey provisioning (M2A.3)
Expands M2A.3 from the original plan because the credential issuer pubkey had no provisioning path. Adds INS_SET_CREDENTIAL_ISSUER_PUBK = 0x25 to PersonalizationApplet, bumps CredentialStore FIELD_VERSION 2 -> 3 to add a 64 B credentialIssuerPubKey slot + set-flag, and pivots finalizeAccessDocument to run a one-shot CoseVerifier RFC 9052 COSE_Sign1 verify against the staged AD bytes before atomically setting accessDocumentLen + accessDocumentFinalized + accessDocumentVerified inside a JCSystem transaction. PersonalizationApplet holds one CoseVerifier instance constructed at install (the 768 B CLEAR_ON_DESELECT scratch only allocates once) plus a 65 B EEPROM scratch for staging the uncompressed issuer pubkey. Status word mapping: - missing issuer pubkey at finalize -> SW_CONDITIONS_NOT_SATISFIED (0x6985) - IssuerAuth signature mismatch -> SW_DATA_INVALID (0x6984) - length out of range -> SW_WRONG_DATA (0x6A80) On verify failure the store stays untouched -- both accessDocumentFinalized and accessDocumentVerified remain false. Harness side: TrustArtifacts gains credential_issuer_pub (loaded from trust_dir/issuer.pem). The orchestrator sends INS 0x25 after the existing key writes and before the AD chunks so the trust anchor is staged by the time FINALIZE_AD runs. Test vector: AD bytes + matching issuer pubkey x||y are hardcoded into PersonalizationAppletTest from the canonical trustgen artifacts at /home/work/aliro-trust (272 B AD against a known issuer.pem). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ class CredentialStoreSerializationTest {
|
||||
|
||||
private static final byte[] KNOWN_32_BYTES = makeRange(32, 0xA0);
|
||||
private static final byte[] KNOWN_64_BYTES_B = makeRange(64, 0x80);
|
||||
private static final byte[] KNOWN_64_BYTES_ISSUER = makeRange(64, 0x40);
|
||||
|
||||
private static byte[] makeRange(int len, int start) {
|
||||
byte[] out = new byte[len];
|
||||
@@ -51,6 +52,8 @@ class CredentialStoreSerializationTest {
|
||||
src.setCredentialPrivKey(KNOWN_32_BYTES, (short) 0);
|
||||
// Intentionally do NOT setCredentialPubKey: leave credentialPubKeySet=false.
|
||||
src.setReaderPubKey(KNOWN_64_BYTES_B, (short) 0);
|
||||
// Exercise the new credentialIssuerPubKey slot (M2A.3, FIELD_VERSION=3).
|
||||
src.setCredentialIssuerPubKey(KNOWN_64_BYTES_ISSUER, (short) 0);
|
||||
// Intentionally do NOT finalizeAccessDocument: leave accessDocumentFinalized=false
|
||||
// and accessDocumentLen=0. With len=0, copyAccessDocument() returns an empty array.
|
||||
src.commit();
|
||||
@@ -64,6 +67,15 @@ class CredentialStoreSerializationTest {
|
||||
assertArrayEquals(KNOWN_32_BYTES, restored.copyCredentialPrivKey());
|
||||
assertArrayEquals(KNOWN_64_BYTES_B, restored.copyReaderPubKey());
|
||||
|
||||
// Issuer pubkey round-trips as 0x04 || x || y (uncompressed SEC1).
|
||||
byte[] expectedIssuerUncomp = new byte[65];
|
||||
expectedIssuerUncomp[0] = 0x04;
|
||||
System.arraycopy(KNOWN_64_BYTES_ISSUER, 0, expectedIssuerUncomp, 1, 64);
|
||||
byte[] gotIssuerUncomp = new byte[65];
|
||||
restored.copyCredentialIssuerPubKeyUncomp(gotIssuerUncomp, (short) 0);
|
||||
assertArrayEquals(expectedIssuerUncomp, gotIssuerUncomp);
|
||||
assertTrue(restored.hasCredentialIssuerPubKey());
|
||||
|
||||
// The unset credential pubkey buffer should round-trip as all-zero —
|
||||
// resetForTesting cleared it and we never wrote to it.
|
||||
assertArrayEquals(new byte[CredentialStore.CRED_PUBK_LEN],
|
||||
|
||||
Reference in New Issue
Block a user