Documentation ¶
Index ¶
- Constants
- type GnuPGHome
- 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 ¶
const ( // SopsGpgExecEnv can be set as an environment variable to overwrite the // GnuPG binary used. SopsGpgExecEnv = "FLUX_SOPS_GPG_EXEC" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GnuPGHome ¶
type GnuPGHome string
GnuPGHome is the absolute path to a GnuPG home directory. A new keyring can be constructed by combining the use of NewGnuPGHome() and Import() or ImportFile().
func NewGnuPGHome ¶
NewGnuPGHome initializes a new GnuPGHome in a temporary directory. The caller is expected to handle the garbage collection of the created directory.
func (GnuPGHome) ApplyToMasterKey ¶
ApplyToMasterKey configures the GnuPGHome on the provided key if it passes Validate.
func (GnuPGHome) Import ¶
Import attempts to import the armored key bytes into the GnuPGHome keyring. It returns an error if the GnuPGHome does not pass Validate, or if the import failed.
func (GnuPGHome) ImportFile ¶
ImportFile attempts to import the armored key file into the GnuPGHome keyring. It returns an error if the GnuPGHome does not pass Validate, or if the import failed.
type MasterKey ¶
type MasterKey struct { // Fingerprint contains the fingerprint of the PGP key used to Encrypt // or Decrypt the data key with. Fingerprint string // EncryptedKey contains the SOPS data key encrypted with PGP. EncryptedKey string // CreationDate of the MasterKey, used to determine if the EncryptedKey // needs rotation. 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.2/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 MasterKeyFromFingerprint ¶
MasterKeyFromFingerprint 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.
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.