(opts unsetOpts)
| 21 | } |
| 22 | |
| 23 | func unset(opts unsetOpts) ([]byte, error) { |
| 24 | // Load the file |
| 25 | tree, err := common.LoadEncryptedFileWithBugFixes(common.GenericDecryptOpts{ |
| 26 | Cipher: opts.Cipher, |
| 27 | InputStore: opts.InputStore, |
| 28 | InputPath: opts.InputPath, |
| 29 | IgnoreMAC: opts.IgnoreMAC, |
| 30 | KeyServices: opts.KeyServices, |
| 31 | }) |
| 32 | if err != nil { |
| 33 | return nil, err |
| 34 | } |
| 35 | |
| 36 | // Decrypt the file |
| 37 | dataKey, err := common.DecryptTree(common.DecryptTreeOpts{ |
| 38 | Cipher: opts.Cipher, |
| 39 | IgnoreMac: opts.IgnoreMAC, |
| 40 | Tree: tree, |
| 41 | KeyServices: opts.KeyServices, |
| 42 | DecryptionOrder: opts.DecryptionOrder, |
| 43 | }) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | |
| 48 | // Unset the value |
| 49 | newBranch, err := tree.Branches[0].Unset(opts.TreePath) |
| 50 | if err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | tree.Branches[0] = newBranch |
| 54 | |
| 55 | err = common.EncryptTree(common.EncryptTreeOpts{ |
| 56 | DataKey: dataKey, Tree: tree, Cipher: opts.Cipher, |
| 57 | }) |
| 58 | if err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | |
| 62 | encryptedFile, err := opts.OutputStore.EmitEncryptedFile(*tree) |
| 63 | if err != nil { |
| 64 | return nil, common.NewExitError(fmt.Sprintf("Could not marshal tree: %s", err), codes.ErrorDumpingTree) |
| 65 | } |
| 66 | return encryptedFile, err |
| 67 | } |
no test coverage detected