Documentation ¶
Overview ¶
Package ecfg implements the primary interface to interact with ecfg documents and keypairs. The CLI implemented by cmd/ecfg is a fairly thin wrapper around this package.
Index ¶
- Constants
- func DecryptData(data []byte, keypath []string, fileType FileType) ([]byte, error)
- func DecryptFile(filePath string, keypath []string, fileType FileType) ([]byte, error)
- func DefaultKeypath() (keypath []string)
- func EncryptData(data []byte, fileType FileType) ([]byte, error)
- func EncryptFileInPlace(filePath string, fileType FileType) (int, error)
- func GenerateKeypair() (pub string, priv string, err error)
- func SystemKeypath() (keypath []string)
- func UserKeypath() (keypath []string)
- type FileType
Constants ¶
const ( FileTypeJSON = iota FileTypeYAML FileTypeTOML )
Variables ¶
This section is empty.
Functions ¶
func DecryptData ¶
DecryptData takes a an encrypted ecfg document and returns the same document, decrypted. The public key used to encrypt the values is embedded in the document, and the matching private key is searched for in keypath. There must exist a file in at least one of the keypath entries whose name is the public key from the ecfg document, and whose contents are the corresponding private key. See README.md for more details on this.
func DecryptFile ¶
DecryptFile takes a path to an encrypted ecfg file and returns the data decrypted. The public key used to encrypt the values is embedded in the referenced document, and the matching private key is searched for in keypath. There must exist a file in at least one of the keypath entries whose name is the public key from the ecfg document, and whose contents are the corresponding private key. See README.md for more details on this.
func DefaultKeypath ¶
func DefaultKeypath() (keypath []string)
DefaultKeypath is UserKeypath prefixed to SystemKeypath. For root, this will be equal to SystemKeypath, and for other users, this will cause key lookups to first try their own local keys, falling back to system keys if that fails.
func EncryptFileInPlace ¶
EncryptFileInPlace takes a path to a file on disk, which must be a valid ecfg file (see README.md for more on what constitutes a valid ecfg file). Any encryptable-but-unencrypted fields in the file will be encrypted using the public key embdded in the file, and the resulting text will be written over the file present on disk.
func GenerateKeypair ¶
GenerateKeypair is used to create a new ecfg keypair. It returns the keys as hex-encoded strings, suitable for printing to the screen. hex.DecodeString can be used to load the true representation if necessary.
func SystemKeypath ¶
func SystemKeypath() (keypath []string)
SystemKeypath returns the default system-wide locations at which to search for ecfg keys. /opt/ejson/keys is provided for backwards-compatibility with ejson.
func UserKeypath ¶
func UserKeypath() (keypath []string)
UserKeypath returns the user-specific locations at which to search for ecfg keys. In most cases, this is empty for root, and ~/.ecfg/keys in other cases. If XDG_CONFIG_HOME is set, $XDG_CONFIG_HOME/ecfg/keys is highest priority.
Types ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
crypto
Package crypto implements a simple convenience wrapper around golang.org/x/crypto/nacl/box.
|
Package crypto implements a simple convenience wrapper around golang.org/x/crypto/nacl/box. |
json
Package json implements functions to load the Public key data from an ecfg file, and to walk that data file, encrypting or decrypting any keys which, according to the specification, are marked as encryptable (see README.md for details).
|
Package json implements functions to load the Public key data from an ecfg file, and to walk that data file, encrypting or decrypting any keys which, according to the specification, are marked as encryptable (see README.md for details). |
toml
package toml provides facilities for decoding and encoding TOML configuration files via reflection.
|
package toml provides facilities for decoding and encoding TOML configuration files via reflection. |
yaml
Package yaml implements YAML support for the Go language.
|
Package yaml implements YAML support for the Go language. |