Skip to content

5.2.0

Latest

Choose a tag to compare

@arkavo-com arkavo-com released this 09 Nov 02:57
3f9f0f3

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 an ec-wrapped key 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's cnf key.
      • It accepts at most 64 KiB, ES256 only, no crit header, canonical base64url, and no duplicate JSON members.
      • It returns clientPublicKey, the policies with their key access objects, and any extension members.
      • It returns exp without enforcing it, so a KAS can still sign a denial for an expired request.
    • 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, without schemaVersion;
    • TDFKAS.publicKeyFingerprint: SHA-256 of the uncompressed SEC1 point.
  • A Rewrap client for a KAS that answers later (#68). KASRewrapClient.prepareRewrap, then submitRewrap, then pollRewrap(_:until:), or rewrap(...) to run all three.
    • Signing: requests are signed with the init signingKey. The caller sets the token's exp and can add one requestBody extension member. Resending the same PreparedRewrap sends identical bytes.
    • Polling: a 202 is polled at its Location, which must be on the KAS's own origin; this is checked on submit and again on every poll.
      • Retry-After is 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 a 404 at or after the token's exp, 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.
  • ec-wrapped encryption (#68). With TDFKasInfo(..., keyType: .ecP256), TDFEncryptor writes an ec-wrapped key access object in the go SDK / opentdf-platform scheme: HKDF salt SHA256("TDF") and a PEM ephemeral key. It requires a kid and AES-256. TDFCrypto.wrapSymmetricKeyWithECForKAS is the wrap on its own.
  • CLI: OpenTDFKitCLI supports ecwrap. With XT_WITH_ECWRAP=true, tdf encrypt 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;
    • /kas is treated the same as no path.

    A platform KAS and owner KASs on one host each claim only their own objects.

  • KASRewrapClient.unwrapKey wipes the opened key bytes before returning.

  • Every TDFEncryptor entry 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 example https://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: KASRewrapError has three new cases, .invalidRewrapOptions, .pendingWithoutLocation and .unsafeLocation. Exhaustive switch statements over it need them.
  • TDFKasInfo: it defaults to .rsa, so existing callers write the same output.
  • Two EC schemes: wrapSymmetricKeyWithEC / unwrapSymmetricKeyWithEC are the TDF-JSON / TDF-CBOR draft scheme (empty salt, compressed SEC1 key), not the platform's ec-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-wrapped is a go program built on lib/ocrypto. It generates the go → Swift fixture, and its verify command opens what Swift writes. The CI job interop-ec-wrapped runs it on every PR.
  • xtest runs the tdf-ecwrap container against the live platform. swift → go, go → swift and swift → swift all pass.

Full changelog: 5.1.0...5.2.0