Repository navigation
feat(sdk): add opt-in hexless policy binding - #4232
pflynn-virtru wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Benchmark results, click to expandBulk Benchmark Results
TDF3 Benchmark Results
|
Benchmark results, click to expandBulk Benchmark Results
TDF3 Benchmark Results
|
…egacy KAS The spec defines a key access object's policy binding hash as Base64(HMAC). Every SDK writes Base64(hex(HMAC)) instead, and no KAS released before the dual-accept fix can verify the spec's form: older ones always hex-decode it, later ones compare an untrimmed decode buffer. Flipping the writer outright breaks decryption against every deployed KAS. Keep the legacy form as the default and add WithSpecCompliantPolicyBinding (and chunked and experimental/tdf equivalents) to write the spec's form. A pre-4.3.0 target mode overrides it. On read, re-encode a 32-byte binding to the legacy form in the rewrap request. Every KAS verifies that form, so a TDF carrying the spec's binding decrypts through this reader against any KAS. Older readers forward the binding unchanged and still need a KAS with the fix, which is why the default stays legacy until fixed KAS are broadly deployed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
"Spec compliant" depends on which spec version the reader has in mind. Name the option for what it changes instead: it drops the hex layer. WithSpecCompliantPolicyBinding -> WithHexlessPolicyBinding WithChunkedSpecCompliantPolicyBinding -> WithChunkedHexlessPolicyBinding Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
938b5a2 to
b7dfbb1
Compare
|
Benchmark results, click to expandBulk Benchmark Results
TDF3 Benchmark Results
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Part of #3578. Adds an opt-in hexless policy binding: the spec's
Base64(HMAC)form, without the hex layer of the legacyBase64(hex(HMAC)). The default output is unchanged.Proposed Changes
The spec defines a key access object's policy binding hash as
Base64(HMAC), but the Go SDK writesBase64(hex(HMAC)). KAS releases before #4223 can't verify the spec form, so switching the default would break decryption against every deployed KAS. Instead, this adds an opt-in:WithHexlessPolicyBinding()(CreateTDF),WithChunkedHexlessPolicyBinding()(chunked writer), andWithHexlessPolicyBinding()insdk/experimental/tdfwriteBase64(HMAC). The name describes the encoding rather than claiming compliance with a particular spec version. Without them, output is byte-for-byte the same as today.WithTargetMode/WithChunkedTargetModeoverrides the opt-in and keeps the legacy form.Base64(hex(HMAC))in the rewrap request. Both forms carry the same HMAC, and every KAS verifies the legacy form, so this SDK can decrypt a hexless TDF against any KAS. Other bindings are forwarded unchanged for the KAS to judge.#3597 (now a draft) is the follow-up that makes the spec form the default, once KAS versions with #4223 are broadly deployed.
Checklist
Testing Instructions
cd sdk && go test ./... -race: all packages pass, includingexperimental/tdf.TestCreatePolicyBinding.tdf_test.go,chunked_test.goandexperimental/tdf/writer_test.gocover the default, the opt-in, and the opt-in overridden by a pre-4.3.0 target mode.cd sdk && go test -run TestREADMECodeBlocks: passes.golangci-lint run --new-from-rev=origin/main ./...insdk: 0 issues.Interop: opentdf/tests#648 checks that a KAS accepts a hexless binding by rewriting one into an otherwise normal TDF. It is expected to fail against platform versions without #4223.
Compatibility
🤖 Generated with Claude Code
Summary by CodeRabbit