in releases/go/encryption-sdk/EncryptDecryptHelpers/EncryptDecryptHelpers.go [634:687]
func (_static *CompanionStruct_Default___) BuildHeaderAuthTag(suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo, dataKey _dafny.Sequence, rawHeader _dafny.Sequence, serializedReqEncryptionContext _dafny.Sequence, crypto *m_AtomicPrimitives.AtomicPrimitivesClient) m_Wrappers.Result {
var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_HeaderTypes.Companion_HeaderAuth_.Default())
_ = res
var _0_keyLength _dafny.Int
_ = _0_keyLength
_0_keyLength = _dafny.IntOfInt32(m_SerializableTypes.Companion_Default___.GetEncryptKeyLength(suite))
var _1_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
_ = _1_valueOrError0
_1_valueOrError0 = m_Wrappers.Companion_Default___.Need((_dafny.IntOfUint32((dataKey).Cardinality())).Cmp(_0_keyLength) == 0, m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsEncryptionSdkException_(_dafny.SeqOfString("Incorrect data key length")))
if (_1_valueOrError0).IsFailure() {
res = (_1_valueOrError0).PropagateFailure()
return res
}
var _2_ivLength uint8
_ = _2_ivLength
_2_ivLength = m_SerializableTypes.Companion_Default___.GetIvLength(suite)
var _3_iv _dafny.Sequence
_ = _3_iv
_3_iv = _dafny.SeqCreate(uint32(_2_ivLength), func(coer20 func(_dafny.Int) uint8) func(_dafny.Int) interface{} {
return func(arg21 _dafny.Int) interface{} {
return coer20(arg21)
}
}(func(_4___v3 _dafny.Int) uint8 {
return uint8(0)
}))
var _5_maybeEncryptionOutput m_Wrappers.Result
_ = _5_maybeEncryptionOutput
var _out0 m_Wrappers.Result
_ = _out0
_out0 = (crypto).AESEncrypt(m_AwsCryptographyPrimitivesTypes.Companion_AESEncryptInput_.Create_AESEncryptInput_(((suite).Dtor_encrypt()).Dtor_AES__GCM(), _3_iv, dataKey, _dafny.SeqOf(), _dafny.Companion_Sequence_.Concatenate(rawHeader, serializedReqEncryptionContext)))
_5_maybeEncryptionOutput = _out0
var _6_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_AwsCryptographyPrimitivesTypes.Companion_AESEncryptOutput_.Default())
_ = _6_valueOrError1
_6_valueOrError1 = (_5_maybeEncryptionOutput).MapFailure(func(coer21 func(m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error) func(interface{}) interface{} {
return func(arg22 interface{}) interface{} {
return coer21(arg22.(m_AwsCryptographyPrimitivesTypes.Error))
}
}(func(_7_e m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error {
return m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsCryptographyPrimitives_(_7_e)
}))
if (_6_valueOrError1).IsFailure() {
res = (_6_valueOrError1).PropagateFailure()
return res
}
var _8_encryptionOutput m_AwsCryptographyPrimitivesTypes.AESEncryptOutput
_ = _8_encryptionOutput
_8_encryptionOutput = (_6_valueOrError1).Extract().(m_AwsCryptographyPrimitivesTypes.AESEncryptOutput)
var _9_headerAuth m_HeaderTypes.HeaderAuth
_ = _9_headerAuth
_9_headerAuth = m_HeaderTypes.Companion_HeaderAuth_.Create_AESMac_(_3_iv, (_8_encryptionOutput).Dtor_authTag())
res = m_Wrappers.Companion_Result_.Create_Success_(_9_headerAuth)
return res
return res
}