feat(crypto): support native age recipients #1021
This looks fine to me. AI says:
1. Encoding mismatch (medium): age EncryptedData.encrypted_bytes is a raw binary age file; JWK's is base64 text. Consumers must branch on provider. Consider documenting this on EncryptedData in proto/c1/connector/v2/resource.proto (a comment exists only on AgeRecipientConfig).
2. Implicit key-ID contract (medium): age sets key_ids = [hex(sha256(recipient string))], leaves deprecated key_id empty; JWK sets both to the JWK thumbprint and mirrors it in EncryptionConfig.key_id. Document the derivation in the proto so control planes can correlate. (Canonicalization is safe — non-canonical recipient strings are rejected, verified.)
3. Dual API divergence (low): GetEncryptionProviderForConfig cannot resolve age configs (even with explicit provider name); only the new GetEncryptorForConfig can. Only in-repo caller was updated, but the old exported API remains a trap for downstream users — consider deprecation comment or making it delegate.
Addressed all three points in 73258ad1:
1. Encoding contract: EncryptedData.encrypted_bytes now documents that ciphertext encoding is provider-specific: baton/jwk/v1 emits standard-base64 text and baton/age/v1 emits a standard binary age file. Consumers must dispatch on provider; schema describes plaintext semantics after decryption.
2. Key-ID contract: key_ids is documented as provider-specific correlation metadata. AgeRecipientConfig now specifies lowercase_hex(SHA-256(UTF-8(canonical recipient))), and the test explicitly proves deprecated key_id stays empty.
3. Resolver capability split: GetEncryptionProviderForConfig is now deprecated for encryption selection in favor of GetEncryptorForConfig. I did not make it delegate for age because its return interface also requires Decrypt and GenerateKey; doing so would require fake/failing operations or a breaking return-type change. A regression test locks the intended compatibility boundary: JWK resolves through both APIs; age resolves through the encryption-only API.
Validation on the updated head:
go test ./pkg/crypto/...go test -tags=baton_lambda_support ./...golangci-lint v2.12.2 run --timeout=3mbuf lintbuf breaking --against .git#branch=maingo mod verifygo build ./cmd/batonAll pass.
Approved these changes.
Approved these changes.
General PR Review: feat(crypto): support native age recipients
Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 482c7804bcfa.
Review mode: full
View review run: https://github.com/ConductorOne/baton-sdk/actions/runs/29861257083
Review Summary
Reviewed the full PR diff for security and correctness, focusing on SDK compatibility surfaces (proto/wire, exported Go APIs, serialized state, defaults, dependencies). This adds a baton/age/v1 recipient-only encryption provider and a new EncryptionConfig.age_recipient_config oneof field (number 101), upgrading filippo.io/age v1.2.1 to v1.3.1. The proto change is additive (no field renumbering or reuse), all three generated files (resource.pb.go, resource.pb.validate.go, resource_protoopaque.pb.go) are regenerated and consistent with the source, the new Encryptor interface is additive and leaves the EncryptionProvider method set unchanged, and the EncryptionManager.Encrypt switch to GetEncryptorForConfig strictly widens provider resolution without regressing existing JWK callers. Recipient validation rejects empty, whitespace, multiline, and private-identity input and does not echo the input in errors; dependency changes (filippo.io/hpke indirect, CCTV test vectors) match the age upgrade. No new issues found.
Security Issues: None found.
Correctness Issues: None found.
Suggestions: None.
No blocking issues found.
pquerna
c1-squire-dev[bot]
Summary
Upgrade
filippo.io/agefrom v1.2.1 to v1.3.1 and add first-class recipient-based age encryption to Baton credential outputs.age v1.3 adds native hybrid post-quantum recipients (
age1pq1...) alongside its existing X25519 recipients (age1...). This lets callers supply the standard public recipient directly instead of converting it through a JWK/SSH representation.API
EncryptionConfiggains:The field accepts exactly one standard public age recipient. Private identities are never accepted or transported. When selected, the
baton/age/v1provider writes a standard binary age file toEncryptedData.encrypted_bytesand records a SHA-256 fingerprint of the recipient inkey_ids.The provider registry now separates the encryption-only capability from the existing JWK provider's combined encrypt/decrypt/key-generation interface. This keeps the JWK API compatible while avoiding fake decrypt or key-generation methods on the recipient-only provider.
Supported recipients
age1...age1pq1...Parsing and encryption use the upstream age implementation; this PR does not introduce a custom envelope or cryptographic primitive.
Security behavior
Validation
go test -tags=baton_lambda_support ./...golangci-lint v2.12.2 run --timeout=3mbuf lintbuf breaking --against '.git#branch=main'go mod verify-mod=vendorgo build ./cmd/batonTests independently decrypt provider output with upstream age for both X25519 and hybrid post-quantum identities, cover the public
EncryptionManagerpath, provider inference, deterministic key IDs, metadata preservation, and invalid-input redaction.Upstream release: https://github.com/FiloSottile/age/releases/tag/v1.3.1