Repository navigation
Minor release: an owner KAS, meaning a device that holds a KAS key and answers OpenTDF Rewrap itself; a Rewrap client for a KAS that answers later; ec-wrapped key access objects from TDFEncryptor; and path-aware key access object matching. Closes #66.
Added
- KAS-side TDF rewrap (#68). These are pure functions: no network, no storage, keys as CryptoKit values.
TDFKAS.rewrap(keyAccessObject:policyBase64:kasPrivateKey:receiverPublicKey:)opens the key share in anec-wrappedkey access object. It then verifies the policy binding and seals the share to the receiver under a fresh session key.- It accepts only the spec-form binding: HS256 over the manifest's base64 policy text, as the raw HMAC. go's legacy hex form is refused.
- The share is wiped on every exit.
TDFKAS.verifyRewrapRequest(body:signingPublicKey:)verifies a received Rewrap, for example under an owner-KAS token'scnfkey.- It accepts at most 64 KiB,
ES256only, nocritheader, canonical base64url, and no duplicate JSON members. - It returns
clientPublicKey, the policies with their key access objects, and any extension members. - It returns
expwithout enforcing it, so a KAS can still sign a denial for an expired request.
- It accepts at most 64 KiB,
TDFKAS.rewrapResponseBody(sessionPublicKey:responses:)builds the Rewrap response, with caller metadata.TDFKAS.unwrap(wrappedKey:sessionPublicKey:receiverPrivateKey:)opens a rewrapped share outside HTTP.
- Shared digests, which a KAS and its client compute identically and without hashing JSON bytes:
TDFKAS.requestTokenDigest: SHA-256 of the signed request token;TDFKAS.keyAccessObjectDigest: a fixed field encoding, withoutschemaVersion;TDFKAS.publicKeyFingerprint: SHA-256 of the uncompressed SEC1 point.
- A Rewrap client for a KAS that answers later (#68).
KASRewrapClient.prepareRewrap, thensubmitRewrap, thenpollRewrap(_:until:), orrewrap(...)to run all three.- Signing: requests are signed with the init
signingKey. The caller sets the token'sexpand can add onerequestBodyextension member. Resending the samePreparedRewrapsends identical bytes. - Polling: a
202is polled at itsLocation, which must be on the KAS's own origin; this is checked on submit and again on every poll.Retry-Afteris clamped to 1–60 s.- The last wait ends at the caller's deadline, with one final poll. There is no poll after the deadline.
410, or a404at or after the token'sexp, is.expired.
- Results: every result is returned with its status, error, metadata and
kasWrappedKey, together with the session key and the request-token digest. A denial is a result, not a thrown error.
- Signing: requests are signed with the init
ec-wrappedencryption (#68). WithTDFKasInfo(..., keyType: .ecP256),TDFEncryptorwrites anec-wrappedkey access object in the go SDK / opentdf-platform scheme: HKDF saltSHA256("TDF")and a PEM ephemeral key. It requires akidand AES-256.TDFCrypto.wrapSymmetricKeyWithECForKASis the wrap on its own.- CLI:
OpenTDFKitCLI supports ecwrap. WithXT_WITH_ECWRAP=true,tdfencrypt wraps to the KAS's EC P-256 key.
Changed
-
Path-aware matching. A key access object now matches the configured KAS by scheme, host, port and normalized path:
- percent-encoded unreserved characters are decoded;
- a trailing
/is trimmed; /kasis treated the same as no path.
A platform KAS and owner KASs on one host each claim only their own objects.
-
KASRewrapClient.unwrapKeywipes the opened key bytes before returning. -
Every
TDFEncryptorentry point loads the KAS public key before reading the input. An unreadable or mismatched key throws before any encryption work, with the same error as before.
Upgrade notes
- KAS mounted under a prefix: if your KAS is mounted under a prefix other than
/kas(for examplehttps://host/api/kas), put that prefix in the configured KAS URL. A client configured without it no longer matches those key access objects. - New error cases:
KASRewrapErrorhas three new cases,.invalidRewrapOptions,.pendingWithoutLocationand.unsafeLocation. Exhaustiveswitchstatements over it need them. TDFKasInfo: it defaults to.rsa, so existing callers write the same output.- Two EC schemes:
wrapSymmetricKeyWithEC/unwrapSymmetricKeyWithECare the TDF-JSON / TDF-CBOR draft scheme (empty salt, compressed SEC1 key), not the platform'sec-wrapped. - Platform version: a platform KAS rewraps OpenTDFKit's files, RSA or EC, only if it includes opentdf/platform#4081 (
ca178b05), which accepts the spec-form policy binding.
Development
scripts/interop/ec-wrappedis a go program built onlib/ocrypto. It generates the go → Swift fixture, and itsverifycommand opens what Swift writes. The CI jobinterop-ec-wrappedruns it on every PR.- xtest runs the
tdf-ecwrapcontainer against the live platform. swift → go, go → swift and swift → swift all pass.
Full changelog: 5.1.0...5.2.0