Documentation
¶
Overview ¶
Package secrets encrypts values at rest with the controller's master key (AES-256-GCM, §14). The key file is protected by permissions; a copy wrapped by the recovery key goes into backups (§5.0.1).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrWrongRecoveryKey = errors.New("the recovery key does not match this backup")
ErrWrongRecoveryKey means the key does not unwrap this master key.
Functions ¶
func NewRecoveryKey ¶
func NewRecoveryKey() string
NewRecoveryKey returns a 200-bit key like SYNRK-ABCDE-FGHIJ-… (8 groups).
func RecoveryKeySuffix ¶
RecoveryKeySuffix is what the setup wizard asks the user to type back: the key's last 6 characters, dashes and spaces not counted. Applied to the user's answer too, so "2-IRWKX", "2IRWKX" or the whole key all match.
func Restore ¶
Restore writes a master key (unwrapped from a backup) and its wrapped copy into dataDir.
Types ¶
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
func Load ¶ added in v0.5.2
Load reads an existing master key and its wrapped copy from dataDir; it never creates them (host tools that run beside the controller).
func LoadOrCreate ¶
LoadOrCreate reads <dataDir>/master.key, creating it (0600) on first start, and makes sure a wrapped copy exists. When it creates a new recovery key (first start, or an install from before recovery keys), it returns it so the caller can show it once; otherwise recoveryKey is "".
func (*Box) RecoveryKeySetAt ¶ added in v0.5.2
RecoveryKeySetAt is when the recovery key was last set (created or rotated); zero when unknown. It never reveals the key.
func (*Box) Rewrap ¶ added in v0.2.0
Rewrap wraps the master key with recoveryKey and makes it the copy that is stored and put into backups (recovery key rotation, Phase 19b). The master key, and so everything sealed with it, is unchanged.
func (*Box) Seal ¶
Seal encrypts plaintext. aad binds the ciphertext to its context (e.g. the row ID) so it can't be copied to another row.