Documentation
¶
Overview ¶
Package config handles reading and writing cryptkey profile files.
Profiles live at ~/.config/cryptkey/<name>.toml and contain only encrypted shares, credential IDs, salts, and provider metadata — never raw secret material. An HMAC derived from the master key protects the config against tampering.
Index ¶
- Constants
- Variables
- func Backup(name string) (backupPath string, restore func() error, err error)
- func BackupPath(name string) (string, error)
- func Dir() (string, error)
- func Exists(name string) (bool, error)
- func List() ([]string, error)
- func Path(name string) (string, error)
- func Save(p *Profile) error
- type Profile
- type ProviderConfig
Constants ¶
const DefaultProfile = "default"
DefaultProfile is the profile name used when the user omits one on the CLI.
const ProfileVersion = 1
ProfileVersion is the current profile format version.
Variables ¶
var CustomDir string
CustomDir allows overriding the default config directory. When empty, Dir() falls back to ~/.config/cryptkey.
Functions ¶
func Backup ¶
Backup copies the existing profile file to <profile>.toml.bak. It overwrites any existing backup. Returns the backup path and a no-op restore function the caller can defer; calling restore renames the .bak back over the profile, useful when a partially-completed rekey needs to be rolled back.
func BackupPath ¶
BackupPath returns the path of the rolling backup file for a profile.
func Dir ¶
Dir returns the cryptkey config directory. If CustomDir is set (via --config-dir or CRYPTKEY_CONFIG_DIR), it is used directly. Otherwise defaults to ~/.config/cryptkey.
Types ¶
type Profile ¶
type Profile struct {
Version int `toml:"version"`
Name string `toml:"name"`
Threshold int `toml:"threshold"`
OutputSalt string `toml:"output_salt"` // hex-encoded random salt for HKDF output key derivation
Integrity string `toml:"integrity"` // hex-encoded HMAC-SHA256 of provider data
Providers []ProviderConfig `toml:"providers"`
}
Profile is the top-level config for one cryptkey identity.
func (*Profile) IntegrityDigest ¶
IntegrityDigest computes a deterministic hash over all provider config data. This is the payload that gets HMAC'd with the master key.
func (*Profile) OutputSaltBytes ¶
OutputSaltBytes returns the profile's output_salt as raw bytes.
func (*Profile) SetIntegrity ¶
SetIntegrity computes and stores the integrity HMAC using the master key.
type ProviderConfig ¶
type ProviderConfig struct {
Type string `toml:"type"`
ID string `toml:"id"`
Nonce string `toml:"nonce"` // hex-encoded GCM nonce
Params map[string]string `toml:"params"` // provider-specific metadata
}
ProviderConfig stores the encrypted share and metadata for one provider.
func (*ProviderConfig) EncryptedShareData ¶
func (pc *ProviderConfig) EncryptedShareData() (*crypto.EncryptedShare, error)
EncryptedShareData converts the hex-encoded fields back to an EncryptedShare.