in releases/go/encryption-sdk/EncryptDecryptHelpers/EncryptDecryptHelpers.go [780:856]
func (_static *CompanionStruct_Default___) GetDecryptionMaterials(cmm m_AwsCryptographyMaterialProvidersTypes.ICryptographicMaterialsManager, algorithmSuiteId m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteId, headerBody m_HeaderTypes.HeaderBody, reproducedEncryptionContext m_Wrappers.Option, commitmentPolicy m_AwsCryptographyMaterialProvidersTypes.ESDKCommitmentPolicy, mpl *m_MaterialProviders.MaterialProvidersClient) m_Wrappers.Result {
var res m_Wrappers.Result = m_Wrappers.Result{}
_ = res
var _0_encryptionContext _dafny.Map
_ = _0_encryptionContext
_0_encryptionContext = m_EncryptionContext.Companion_Default___.GetEncryptionContext((headerBody).Dtor_encryptionContext())
var _1_decMatRequest m_AwsCryptographyMaterialProvidersTypes.DecryptMaterialsInput
_ = _1_decMatRequest
_1_decMatRequest = m_AwsCryptographyMaterialProvidersTypes.Companion_DecryptMaterialsInput_.Create_DecryptMaterialsInput_(algorithmSuiteId, m_AwsCryptographyMaterialProvidersTypes.Companion_CommitmentPolicy_.Create_ESDK_(commitmentPolicy), (headerBody).Dtor_encryptedDataKeys(), _0_encryptionContext, reproducedEncryptionContext)
var _2_decMatResult m_Wrappers.Result
_ = _2_decMatResult
var _out0 m_Wrappers.Result
_ = _out0
_out0 = (cmm).DecryptMaterials(_1_decMatRequest)
_2_decMatResult = _out0
var _3_valueOrError0 m_Wrappers.Result = m_Wrappers.Result{}
_ = _3_valueOrError0
_3_valueOrError0 = (_2_decMatResult).MapFailure(func(coer25 func(m_AwsCryptographyMaterialProvidersTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error) func(interface{}) interface{} {
return func(arg26 interface{}) interface{} {
return coer25(arg26.(m_AwsCryptographyMaterialProvidersTypes.Error))
}
}(func(_4_e m_AwsCryptographyMaterialProvidersTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error {
return m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsCryptographyMaterialProviders_(_4_e)
}))
if (_3_valueOrError0).IsFailure() {
res = (_3_valueOrError0).PropagateFailure()
return res
}
var _5_output m_AwsCryptographyMaterialProvidersTypes.DecryptMaterialsOutput
_ = _5_output
_5_output = (_3_valueOrError0).Extract().(m_AwsCryptographyMaterialProvidersTypes.DecryptMaterialsOutput)
var _6_materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials
_ = _6_materials
_6_materials = (_5_output).Dtor_decryptionMaterials()
var _7_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf())
_ = _7_valueOrError1
_7_valueOrError1 = ((mpl).ValidateCommitmentPolicyOnDecrypt(m_AwsCryptographyMaterialProvidersTypes.Companion_ValidateCommitmentPolicyOnDecryptInput_.Create_ValidateCommitmentPolicyOnDecryptInput_(((_6_materials).Dtor_algorithmSuite()).Dtor_id(), m_AwsCryptographyMaterialProvidersTypes.Companion_CommitmentPolicy_.Create_ESDK_(commitmentPolicy)))).MapFailure(func(coer26 func(m_AwsCryptographyMaterialProvidersTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error) func(interface{}) interface{} {
return func(arg27 interface{}) interface{} {
return coer26(arg27.(m_AwsCryptographyMaterialProvidersTypes.Error))
}
}(func(_8_e m_AwsCryptographyMaterialProvidersTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error {
return m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsCryptographyMaterialProviders_(_8_e)
}))
if (_7_valueOrError1).IsFailure() {
res = (_7_valueOrError1).PropagateFailure()
return res
}
var _9___v6 _dafny.Tuple
_ = _9___v6
_9___v6 = (_7_valueOrError1).Extract().(_dafny.Tuple)
var _10_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf())
_ = _10_valueOrError2
_10_valueOrError2 = ((mpl).DecryptionMaterialsWithPlaintextDataKey(_6_materials)).MapFailure(func(coer27 func(m_AwsCryptographyMaterialProvidersTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error) func(interface{}) interface{} {
return func(arg28 interface{}) interface{} {
return coer27(arg28.(m_AwsCryptographyMaterialProvidersTypes.Error))
}
}(func(_11_e m_AwsCryptographyMaterialProvidersTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error {
return m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsCryptographyMaterialProviders_(_11_e)
}))
if (_10_valueOrError2).IsFailure() {
res = (_10_valueOrError2).PropagateFailure()
return res
}
var _12___v7 _dafny.Tuple
_ = _12___v7
_12___v7 = (_10_valueOrError2).Extract().(_dafny.Tuple)
var _13_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
_ = _13_valueOrError3
_13_valueOrError3 = m_Wrappers.Companion_Default___.Need(m_SerializableTypes.Companion_Default___.IsESDKEncryptionContext((_6_materials).Dtor_encryptionContext()), m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsEncryptionSdkException_(_dafny.SeqOfString("CMM failed to return serializable encryption materials.")))
if (_13_valueOrError3).IsFailure() {
res = (_13_valueOrError3).PropagateFailure()
return res
}
res = m_Wrappers.Companion_Result_.Create_Success_(_6_materials)
return res
return res
}