Repository navigation
Conversation
…11 + payShield Consolidates the HSM work toward roadmap B1 (production crypto path). SoftVault stays the default in-process backend; every HSM adapter is an opt-in separate module, so the root module graph remains stdlib-only. - vault capability interfaces: decompose vault.Vault into PINEncryptor / PINTranslator / Macer so an adapter advertises exactly what its device can securely do. Source-compatible — Vault keeps the same method set. PINTranslator documents the PCI PIN-Security contract (atomic in-device translate; adapters that cannot must not implement it). - adapters/pkcs11: generic PKCS#11 / SoftHSM2 adapter implementing Macer (ISO 9797-1 alg 1 and alg 3 retail MAC), composed from the token's 3DES primitives; output byte-for-byte identical to vault.GenerateMAC, cross-checked against a real token under SoftHSM2 in CI. Separate cgo module. Deliberately Macer-only: no PIN translate (no PCI-secure stock-PKCS#11 mechanism) and no clear-PIN encrypt (belongs to a payment/issuer HSM). - adapters/payshield: Thales payShield adapter over the host-command protocol, implementing the full vault.Vault — EncryptPINBlock (PINEncryptor), TranslatePIN (PINTranslator), and GenerateMAC/VerifyMAC (Macer). Ships an in-repo protocol simulator whose cryptography is the software vault, so the command flow is exercised end to end in CI without hardware. Stdlib-only module. Validated against SoftHSM2 (pkcs11) and the in-repo simulator (payshield), not real certified hardware: real-HSM validation, the exact positional wire layout, pooled transport, and independent security review remain outstanding (does not close B1). Also fixes the docs changelog link to ROADMAP-to-v1.md (absolute URL) so the strict site build passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidates the in-flight HSM work into one reviewable change toward roadmap B1 (production crypto path). SoftVault remains the default in-process backend; every HSM adapter is an opt-in separate module, so the root module graph stays stdlib-only.
What's here
Merges three branches and completes the gap:
vaultcapability interfaces (feat/vault-hsm-interfaces). Decomposesvault.VaultintoPINEncryptor/PINTranslator/Macer, so an adapter advertises exactly what its device can securely do. Source-compatible —Vaultkeeps the same method set.PINTranslatordocuments the PCI PIN-Security contract (atomic in-device translate; adapters that can't must not implement it).adapters/pkcs11(feat/pkcs11-foundation). Generic PKCS#11 / SoftHSM2 adapter implementingMacer(ISO 9797-1 alg 1 + alg 3 retail MAC), composed from the token's 3DES primitives; output is byte-for-byte identical tovault.GenerateMAC, cross-checked against a real token under SoftHSM2 in CI. Separate cgo module. DeliberatelyMacer-only — no PIN translate (no PCI-secure stock-PKCS#11 mechanism) and no clear-PIN encrypt (belongs to a payment/issuer HSM).adapters/payshield(feat/payshield-adapter+ this PR's new work). Thales payShield adapter over the host-command protocol. Now implements the fullvault.Vault: this PR addsEncryptPINBlock(PINEncryptor) on top of the existingTranslatePIN+ MAC, with theBA/BBencrypt-PIN command, simulator dispatch, and a deterministic ISO0 test that cross-checks against the software vault. Stdlib-only module.Design note (divergence worth flagging)
I considered adding
PINEncryptorto the PKCS#11 adapter too, but kept itMacer-only by design: its package doc makes a deliberate, written choice that clear-PIN handling belongs to a payment/issuer HSM, not a general-purpose token. The "fullvault.Vault" goal is met by payShield, where PIN encrypt properly belongs. Happy to revisit if you'd rather pkcs11 also offer issuer-context PIN encrypt.Scope / honesty
Verification
go build/vet/test ./...clean; zero third-party deps in the core graph.otel,sql,payshield,pkcs11) build/vet/test green; gofmt clean..github/workflows/adapters.yml): matrix over otel/sql/payshield + a dedicated SoftHSM2 job for pkcs11.Does not close B1 (real-hardware validation + security review outstanding); it lands the engineering-completable portion.