feat: define CredentialStore serialization contract

Adds in-tree SerializationSink/Source interfaces matching the shape of
the AMD-H Element API, plus writeTo/readFrom on CredentialStore and a
round-trip test. The AMD-H adapter (added in a later epic) just bridges
Element -> these interfaces, so the field layout is testable today
without depending on a JCOP 4.5 image.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
michael
2026-05-26 10:50:47 -07:00
parent 1f54a690d0
commit 40a079a539
4 changed files with 266 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.dangerousthings.aliro;
/**
* Minimal write-side abstraction matching the shape of the GlobalPlatform
* Amendment H {@code org.globalplatform.upgrade.Element} write API. The
* AMD-H adapter (added in a later epic, J3R452-only) is a one-class bridge
* that implements this interface against the real {@code Element}.
*
* <p>Keeping the interface in the main source tree means
* {@link CredentialStore#writeTo(SerializationSink)} can be authored,
* tested, and locked down today without pulling in the AMD-H package, which
* only exists on JCOP 4.5 / J3R452-class cards.
*
* <p>Element semantics: once a byte[] reference is written, the storage
* provider treats it as immutable from the caller's perspective. Test
* fakes that buffer writes should make defensive copies to mirror this.
*/
interface SerializationSink {
SerializationSink write(byte b);
SerializationSink write(short s);
SerializationSink write(boolean z);
SerializationSink write(byte[] arr);
}