@@ -72,6 +72,8 @@ type DecryptTreeOpts struct {
7272 Tree * sops.Tree
7373 // KeyServices are the key services to be used for decryption of the data key
7474 KeyServices []keyservice.KeyServiceClient
75+ // DecryptionOrder is the order in which available decryption methods are tried
76+ DecryptionOrder []string
7577 // IgnoreMac is whether or not to ignore the Message Authentication Code included in the SOPS tree
7678 IgnoreMac bool
7779 // Cipher is the cryptographic cipher to use to decrypt the values inside the tree
@@ -80,7 +82,7 @@ type DecryptTreeOpts struct {
8082
8183// DecryptTree decrypts the tree passed in through the DecryptTreeOpts and additionally returns the decrypted data key
8284func DecryptTree (opts DecryptTreeOpts ) (dataKey []byte , err error ) {
83- dataKey , err = opts .Tree .Metadata .GetDataKeyWithKeyServices (opts .KeyServices )
85+ dataKey , err = opts .Tree .Metadata .GetDataKeyWithKeyServices (opts .KeyServices , opts . DecryptionOrder )
8486 if err != nil {
8587 return nil , NewExitError (err , codes .CouldNotRetrieveKey )
8688 }
@@ -222,11 +224,12 @@ func GetKMSKeyWithEncryptionCtx(tree *sops.Tree) (keyGroupIndex int, keyIndex in
222224
223225// GenericDecryptOpts represents decryption options and config
224226type GenericDecryptOpts struct {
225- Cipher sops.Cipher
226- InputStore sops.Store
227- InputPath string
228- IgnoreMAC bool
229- KeyServices []keyservice.KeyServiceClient
227+ Cipher sops.Cipher
228+ InputStore sops.Store
229+ InputPath string
230+ IgnoreMAC bool
231+ KeyServices []keyservice.KeyServiceClient
232+ DecryptionOrder []string
230233}
231234
232235// LoadEncryptedFileWithBugFixes is a wrapper around LoadEncryptedFile which includes
0 commit comments