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.
Summary
This PR introduces cryptographic infrastructure to encrypt secrets transmitted by the disco-agent, implementing support for HPKE (Hybrid Public Key Encryption) as the primary encryption mechanism.
Motivation
The disco-agent needs to encrypt sensitive secrets before transmitting them to the DisCo backend. This PR provides the cryptographic building blocks to enable end-to-end encryption of secrets, ensuring that sensitive data is protected in transit and at rest.
Note: This encryption is specifically for disco-agent and not for venafi-kubernetes-agent although the code here is not used in either agent yet.
What's Added
internal/hpkePackageImplements HPKE encryption/decryption using modern cryptographic standards:
Algorithm Suite: X25519 KEM (Key Encapsulation Mechanism), HKDF-SHA256 (Key Derivation Function), and AES-256-GCM (Authenticated Encryption)
Core Components:
Encryptor: Encrypts data using HPKE public keysDecryptor: Decrypts data using HPKE private keys (not strictly needed but helpful for testing)EncryptedData: Contains encapsulated key and ciphertextFeatures:
Encrypt()EncryptWithInfo()EncryptWithAAD()Testing: Comprehensive test coverage including round-trip encryption/decryption, various data sizes, non-deterministic behavior, error cases, and authentication failure scenarios
Why HPKE?
HPKE is a modern IETF standard (RFC 9180) that combines key encapsulation and authenticated encryption in a single, efficient operation. Benefits over traditional approaches:
Dependencies
filippo.io/hpke v0.4.0- Go implementation of HPKENext Steps
This PR provides the cryptographic primitives needed for disco-agent secret encryption. Future work will integrate these components into the disco-agent communication flow to encrypt sensitive data in transit.