MCPcopy
hub / github.com/getsops/sops / EncryptTree

Function EncryptTree

cmd/sops/common/common.go:121–132  ·  view source on GitHub ↗

EncryptTree encrypts the tree passed in through the EncryptTreeOpts

(opts EncryptTreeOpts)

Source from the content-addressed store, hash-verified

119
120// EncryptTree encrypts the tree passed in through the EncryptTreeOpts
121func EncryptTree(opts EncryptTreeOpts) error {
122 unencryptedMac, err := opts.Tree.Encrypt(opts.DataKey, opts.Cipher)
123 if err != nil {
124 return NewExitError(fmt.Sprintf("Error encrypting tree: %s", err), codes.ErrorEncryptingTree)
125 }
126 opts.Tree.Metadata.LastModified = time.Now().UTC()
127 opts.Tree.Metadata.MessageAuthenticationCode, err = opts.Cipher.Encrypt(unencryptedMac, opts.DataKey, opts.Tree.Metadata.LastModified.Format(time.RFC3339))
128 if err != nil {
129 return NewExitError(fmt.Sprintf("Could not encrypt MAC: %s", err), codes.ErrorEncryptingMac)
130 }
131 return nil
132}
133
134// LoadEncryptedFileEx loads an encrypted SOPS file from a file or stdin, returning a SOPS tree
135func LoadEncryptedFileEx(loader sops.EncryptedFileLoader, inputPath string, readFromStdin bool) (*sops.Tree, error) {

Callers 7

setFunction · 0.92
encryptFunction · 0.92
unsetFunction · 0.92
editTreeImplFunction · 0.92
rotateFunction · 0.92
RunFunction · 0.92

Calls 3

NewExitErrorFunction · 0.85
FormatMethod · 0.80
EncryptMethod · 0.65

Tested by

no test coverage detected