Skip to content

feat(client): ExternalKeyProvider SPI for HSM-managed A005/X002/E002 keys#1

Open
florianpollstaetter-dot wants to merge 1 commit into
masterfrom
feature/external-key-spi
Open

feat(client): ExternalKeyProvider SPI for HSM-managed A005/X002/E002 keys#1
florianpollstaetter-dot wants to merge 1 commit into
masterfrom
feature/external-key-spi

Conversation

@florianpollstaetter-dot
Copy link
Copy Markdown
Owner

Summary

Adds an additive, non-breaking SPI that lets callers supply A005/X002/E002 key material from an HSM, smartcard, or any PKCS#11 token. When used, the library skips KeyUtil.makeKeyPair(...) and the PKCS#12 export for that subscriber — closing the heap-key duplicate path that would otherwise defeat HSM-resident custody.

  • New interface org.kopi.ebics.client.ExternalKeyProvider with a KeyMaterial(PrivateKey, X509Certificate) record (null-guarded compact constructor).
  • New User(..., ExternalKeyProvider) constructor that installs supplied keys/certs and bypasses CertificateManager.create().
  • New EbicsClient.createUser(..., ExternalKeyProvider) overload that produces the user, persists bank/partner/user, and writes the INI/HIA letters (public-key bytes only) without writing PKCS#12.

Existing createUser(...) callers see no behaviour change.

Tracked downstream as ORA-2311 / ORA-2322. This intra-fork PR exists to drive the fork's GitHub Actions CI (build + tests) before the upstream PR is opened against ebics-java/ebics-java-client.

Test plan

  • UserExternalKeysTest#constructorAssignsExternalKeysVerbatim — proves supplied PrivateKey instances reach the User unchanged for all three roles (no library-side KeyPair overwrites them) and that the public keys returned by the User match the supplied certificates.
  • UserExternalKeysTest#nullProviderRejected — null provider → IllegalArgumentException.
  • UserExternalKeysTest#partialProviderRejected — provider with a null x002()IllegalArgumentException whose message names the offending role.
  • UserExternalKeysTest#keyMaterialRecordRejectsNullPrivateKey / …NullCertificate — record-level null guards.
  • Fork CI (Java CI with Maven) green on this PR.

…002 keys

Closes the gap that forces in-process generation of EBICS subscriber RSA key
pairs. Callers that hold the private keys in an HSM, smartcard, or any other
PKCS#11 token can now pass an ExternalKeyProvider; the library installs the
supplied (PrivateKey, X509Certificate) triples on the User and skips
KeyUtil.makeKeyPair(...) for that subscriber. No PKCS#12 is written for an
externally-keyed user, so the heap-key duplicate path stays cold.

The change is additive and non-breaking: existing createUser(...) callers see
no behaviour change.

Surface:

* New interface org.kopi.ebics.client.ExternalKeyProvider with the
  KeyMaterial(PrivateKey, X509Certificate) record. Compact constructor
  rejects null components at the boundary.
* New User constructor accepting an ExternalKeyProvider; bypasses
  CertificateManager.create().
* New EbicsClient.createUser(..., ExternalKeyProvider) overload that
  produces the user, persists bank/partner/user, and writes the
  INI/HIA letters (public-key bytes only) without writing PKCS#12.

JUnit coverage:

* UserExternalKeysTest#constructorAssignsExternalKeysVerbatim verifies the
  supplied PrivateKey instances reach the User unchanged (no internal
  KeyPair generation overwrites them) and that the public keys returned by
  the User match the supplied certificates for all three roles.
* UserExternalKeysTest#nullProviderRejected and #partialProviderRejected
  cover the boundary checks; partial errors name the offending role.
* UserExternalKeysTest#keyMaterialRecordRejects{Null,Null}* verify the
  record-level null guards.

Motivated by DSGVO + ISO 27001 commitments under which EBICS subscriber
A005/X002 private keys must never reside outside their hardware token.
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.

2 participants