Documentation
¶
Overview ¶
Package keystore implements envelope encryption for CA private key material persisted in SQLite. Each CA gets a fresh data-encryption key (DEK) wrapped under a process-wide master key (KEK) supplied through NEBULA_MGMT_MASTER_KEY. AES-256-GCM is used for both wraps.
See docs/adr/0002-per-operator-cas.md §4.1 for the design rationale.
Index ¶
Constants ¶
const ( // MasterKeySize is the expected size of the unwrapped master key, in bytes. MasterKeySize = 32 // DEKSize is the size of a per-CA data-encryption key. DEKSize = 32 // NonceSize is the GCM nonce length used everywhere in this package. NonceSize = 12 )
Variables ¶
var ErrInvalidMasterKey = errors.New("master key must be 32 random bytes, base64-encoded")
ErrInvalidMasterKey is returned when the configured master key has the wrong length or fails to base64-decode.
Functions ¶
func OpenWithDEK ¶
func OpenWithDEK(dek []byte, w WrappedBlob) ([]byte, error)
OpenWithDEK decrypts a WrappedBlob using the given DEK.
Types ¶
type Master ¶
type Master struct {
// contains filtered or unexported fields
}
Master wraps the process-wide AEAD instance for the KEK.
func NewMasterFromBase64 ¶
NewMasterFromBase64 builds a Master from a base64-encoded 32-byte key. The decoded bytes are copied into the AEAD key schedule by NewMaster, so the transient plaintext copy is zeroized before returning rather than left on the heap for the GC to reclaim (and possibly reuse).
func (*Master) GenerateDEK ¶
func (m *Master) GenerateDEK() (plaintext []byte, wrapped WrappedKey, err error)
GenerateDEK returns a fresh DEK plus its master-key-wrapped form. Callers MUST zeroise the returned plaintext DEK as soon as it is no longer needed.
type WrappedBlob ¶
WrappedBlob holds an arbitrary payload encrypted under a per-CA DEK.
func SealWithDEK ¶
func SealWithDEK(dek, plaintext []byte) (WrappedBlob, error)
SealWithDEK encrypts a payload under the given DEK using AES-256-GCM.
type WrappedKey ¶
WrappedKey holds a DEK encrypted under the master key.