Documentation
¶
Index ¶
- type MasterKey
- func (key *MasterKey) Decrypt() ([]byte, error)
- func (key *MasterKey) Encrypt(dataKey []byte) error
- func (key *MasterKey) EncryptIfNeeded(dataKey []byte) error
- func (key *MasterKey) EncryptedDataKey() []byte
- func (key *MasterKey) NeedsRotation() bool
- func (key *MasterKey) SetEncryptedDataKey(enc []byte)
- func (key MasterKey) ToMap() map[string]interface{}
- func (key *MasterKey) ToString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MasterKey ¶
type MasterKey struct {
Fingerprint string
EncryptedKey string
CreationDate time.Time
// contains filtered or unexported fields
}
MasterKey is a PGP key used to securely store sops' data key by encrypting it and decrypting it.
Adapted from https://github.com/mozilla/sops/blob/v3.7.0/pgp/keysource.go to be able to control the GPG home directory and have a "contained" environment.
We are unable to drop the dependency on the GPG binary (although we wish!) because the builtin GPG support in Go is limited, it does for example not offer support for FIPS: * https://github.com/golang/go/issues/11658#issuecomment-120448974 * https://github.com/golang/go/issues/45188
func NewMasterKeyFromFingerprint ¶
NewMasterKeyFromFingerprint takes a PGP fingerprint and returns a new MasterKey with that fingerprint.
func (*MasterKey) Decrypt ¶
Decrypt uses PGP to obtain the data key from the EncryptedKey store in the MasterKey and returns it.
func (*MasterKey) Encrypt ¶
Encrypt encrypts the data key with the PGP key with the same fingerprint as the MasterKey. It first looks for PGP public keys in MasterKey.homeDir, and falls back to $GNUPGHOME/pubring.gpg.
func (*MasterKey) EncryptIfNeeded ¶
EncryptIfNeeded encrypts the data key with PGP only if it's needed, that is, if it hasn't been encrypted already.
func (*MasterKey) EncryptedDataKey ¶
EncryptedDataKey returns the encrypted data key this master key holds.
func (*MasterKey) NeedsRotation ¶
NeedsRotation returns whether the data key needs to be rotated or not.
func (*MasterKey) SetEncryptedDataKey ¶
SetEncryptedDataKey sets the encrypted data key for this master key.