11package cmd
22
33import (
4- "bytes"
54 "errors"
65 "fmt"
76 "os"
@@ -14,16 +13,12 @@ import (
1413var TDF = "tdf"
1514
1615func dev_tdfDecryptCmd (cmd * cobra.Command , args []string ) {
17- c := cli .New (cmd , args )
16+ c := cli .New (cmd , args , cli . WithPrintJson () )
1817 h := NewHandler (c )
1918 defer h .Close ()
2019
2120 output := c .Flags .GetOptionalString ("out" )
22- tdfType := c .Flags .GetOptionalString ("tdf-type" )
2321 disableAssertionVerification := c .Flags .GetOptionalBool ("no-verify-assertions" )
24- if tdfType == "" {
25- tdfType = TDF3
26- }
2722
2823 // check for piped input
2924 piped := readPipedStdin ()
@@ -40,16 +35,7 @@ func dev_tdfDecryptCmd(cmd *cobra.Command, args []string) {
4035 cli .ExitWithError ("Must provide ONE of the following to decrypt: [file argument, stdin input]" , errors .New ("no input provided" ))
4136 }
4237
43- var decrypted * bytes.Buffer
44- var err error
45- switch tdfType {
46- case TDF3 :
47- decrypted , err = h .DecryptTDF (bytesToDecrypt , disableAssertionVerification )
48- case NANO :
49- decrypted , err = h .DecryptNanoTDF (bytesToDecrypt )
50- default :
51- cli .ExitWithError ("Failed to decrypt" , fmt .Errorf ("unrecognized tdf-type: %s" , tdfType ))
52- }
38+ decrypted , err := h .DecryptBytes (bytesToDecrypt , disableAssertionVerification )
5339 if err != nil {
5440 cli .ExitWithError ("Failed to decrypt file" , err )
5541 }
@@ -81,6 +67,7 @@ func init() {
8167 decryptCmd .GetDocFlag ("out" ).Default ,
8268 decryptCmd .GetDocFlag ("out" ).Description ,
8369 )
70+ // deprecated flag
8471 decryptCmd .Flags ().StringP (
8572 decryptCmd .GetDocFlag ("tdf-type" ).Name ,
8673 decryptCmd .GetDocFlag ("tdf-type" ).Shorthand ,
0 commit comments