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
- type ParsedIdentities
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MasterKey ¶
type MasterKey struct { // Identities contains the set of Bench32-encoded age identities used to // Decrypt. // They are lazy-loaded using MasterKeyFromIdentities, or on first // Decrypt(). // In addition to using this field, ParsedIdentities.ApplyToMasterKey() can // be used to parse and lazy-load identities. Identities []string // Recipient contains the Bench32-encoded age public key used to Encrypt. Recipient string // EncryptedKey contains the SOPS data key encrypted with age. EncryptedKey string // contains filtered or unexported fields }
MasterKey is an age key used to Encrypt and Decrypt SOPS' data key.
Adapted from https://github.com/mozilla/sops/blob/v3.7.2/age/keysource.go to be able to have fine-grain control over the used decryption keys without relying on the existence of file(path)s.
func MasterKeyFromIdentities ¶
MasterKeyFromIdentities takes a set if Bech32-encoded age identities, parses them, and returns a new MasterKey.
func MasterKeyFromRecipient ¶
MasterKeyFromRecipient takes a Bech32-encoded age public key, parses it, and returns a new MasterKey.
func (*MasterKey) Decrypt ¶
Decrypt decrypts the EncryptedKey with the (parsed) Identities and returns the result.
func (*MasterKey) Encrypt ¶
Encrypt takes a SOPS data key, encrypts it with the Recipient, and stores the result in the EncryptedKey field.
func (*MasterKey) EncryptIfNeeded ¶
EncryptIfNeeded encrypts the provided SOPS data key, if it has not been encrypted yet.
func (*MasterKey) EncryptedDataKey ¶
EncryptedDataKey returns the encrypted SOPS 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 SOPS data key for this master key.
type ParsedIdentities ¶
ParsedIdentities contains a set of parsed age identities. It allows for creating a (local) keyservice.KeyServiceServer which parses identities only once, to then inject them using ApplyToMasterKey() for all requests.
func (ParsedIdentities) ApplyToMasterKey ¶
func (i ParsedIdentities) ApplyToMasterKey(key *MasterKey)
ApplyToMasterKey configures the ParsedIdentities on the provided key.
func (*ParsedIdentities) Import ¶
func (i *ParsedIdentities) Import(identity ...string) error
Import attempts to parse the given identities, to then add them to itself. It returns any parsing error. A single identity argument is allowed to be a multiline string containing multiple identities. Empty lines and lines starting with "#" are ignored. It is not thread safe, and parallel importing would better be done by parsing (using age.ParseIdentities) and appending to the slice yourself, in combination with e.g. a sync.Mutex.