EncryptTree encrypts the tree passed in through the EncryptTreeOpts
(opts EncryptTreeOpts)
| 119 | |
| 120 | // EncryptTree encrypts the tree passed in through the EncryptTreeOpts |
| 121 | func 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 |
| 135 | func LoadEncryptedFileEx(loader sops.EncryptedFileLoader, inputPath string, readFromStdin bool) (*sops.Tree, error) { |
no test coverage detected