github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl@v0.2.0/AwsKmsKeyring/AwsKmsKeyring.go (about) 1 // Package AwsKmsKeyring 2 // Dafny module AwsKmsKeyring compiled into Go 3 4 package AwsKmsKeyring 5 6 import ( 7 os "os" 8 9 m_ComAmazonawsDynamodbTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb/ComAmazonawsDynamodbTypes" 10 m_Com_Amazonaws_Dynamodb "github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb/Com_Amazonaws_Dynamodb" 11 m_ComAmazonawsKmsTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms/ComAmazonawsKmsTypes" 12 m_Com_Amazonaws_Kms "github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms/Com_Amazonaws_Kms" 13 m_AlgorithmSuites "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AlgorithmSuites" 14 m_AwsArnParsing "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsArnParsing" 15 m_AwsCryptographyKeyStoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyKeyStoreOperations" 16 m_AwsCryptographyKeyStoreTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyKeyStoreTypes" 17 m_AwsCryptographyMaterialProvidersTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyMaterialProvidersTypes" 18 m_AwsKmsMrkAreUnique "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkAreUnique" 19 m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt" 20 m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils" 21 m_CanonicalEncryptionContext "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CanonicalEncryptionContext" 22 m_Constants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Constants" 23 m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable" 24 m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys" 25 m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations" 26 m_EdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EdkWrapping" 27 m_ErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/ErrorMessages" 28 m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys" 29 m_IntermediateKeyWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/IntermediateKeyWrapping" 30 m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations" 31 m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore" 32 m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages" 33 m_Keyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Keyring" 34 m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn" 35 m_MaterialWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MaterialWrapping" 36 m_Materials "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Materials" 37 m_MultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MultiKeyring" 38 m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure" 39 m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives" 40 m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations" 41 m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes" 42 m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest" 43 m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF" 44 m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr" 45 m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random" 46 m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF" 47 m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC" 48 m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions" 49 m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64" 50 m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas" 51 m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts" 52 m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals" 53 m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear" 54 m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod" 55 m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO" 56 m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare" 57 m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions" 58 m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals" 59 m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt" 60 m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings" 61 m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm" 62 m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_" 63 m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals" 64 m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear" 65 m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul" 66 m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals" 67 m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear" 68 m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power" 69 m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations" 70 m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq" 71 m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort" 72 m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting" 73 m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary" 74 m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop" 75 m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence" 76 m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String" 77 m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt" 78 m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams" 79 m_UTF8 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UTF8" 80 m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings" 81 m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_" 82 m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm" 83 m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm" 84 m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers" 85 m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_" 86 _dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" 87 ) 88 89 var _ = os.Args 90 var _ _dafny.Dummy__ 91 var _ m__System.Dummy__ 92 var _ m_Wrappers.Dummy__ 93 var _ m_BoundedInts.Dummy__ 94 var _ m_StandardLibrary_UInt.Dummy__ 95 var _ m_StandardLibrary_Sequence.Dummy__ 96 var _ m_StandardLibrary_String.Dummy__ 97 var _ m_StandardLibrary.Dummy__ 98 var _ m_AwsCryptographyPrimitivesTypes.Dummy__ 99 var _ m_Random.Dummy__ 100 var _ m_Digest.Dummy__ 101 var _ m_WrappedHMAC.Dummy__ 102 var _ m_HKDF.Dummy__ 103 var _ m_WrappedHKDF.Dummy__ 104 var _ m_KdfCtr.Dummy__ 105 var _ m_AwsCryptographyPrimitivesOperations.Dummy__ 106 var _ m_AtomicPrimitives.Dummy__ 107 var _ m_ComAmazonawsDynamodbTypes.Dummy__ 108 var _ m_ComAmazonawsKmsTypes.Dummy__ 109 var _ m_Relations.Dummy__ 110 var _ m_Seq_MergeSort.Dummy__ 111 var _ m__Math.Dummy__ 112 var _ m_Seq.Dummy__ 113 var _ m__Unicode.Dummy__ 114 var _ m_Functions.Dummy__ 115 var _ m_Utf8EncodingForm.Dummy__ 116 var _ m_Utf16EncodingForm.Dummy__ 117 var _ m_UnicodeStrings.Dummy__ 118 var _ m_FileIO.Dummy__ 119 var _ m_GeneralInternals.Dummy__ 120 var _ m_MulInternalsNonlinear.Dummy__ 121 var _ m_MulInternals.Dummy__ 122 var _ m_Mul.Dummy__ 123 var _ m_ModInternalsNonlinear.Dummy__ 124 var _ m_DivInternalsNonlinear.Dummy__ 125 var _ m_ModInternals.Dummy__ 126 var _ m_DivInternals.Dummy__ 127 var _ m_DivMod.Dummy__ 128 var _ m_Power.Dummy__ 129 var _ m_Logarithm.Dummy__ 130 var _ m_StandardLibraryInterop.Dummy__ 131 var _ m_Streams.Dummy__ 132 var _ m_Sorting.Dummy__ 133 var _ m_HexStrings.Dummy__ 134 var _ m_GetOpt.Dummy__ 135 var _ m_FloatCompare.Dummy__ 136 var _ m_Base64.Dummy__ 137 var _ m_Base64Lemmas.Dummy__ 138 var _ m_Actions.Dummy__ 139 var _ m_AwsCryptographyKeyStoreTypes.Dummy__ 140 var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__ 141 var _ m_AwsArnParsing.Dummy__ 142 var _ m_AwsKmsMrkMatchForDecrypt.Dummy__ 143 var _ m_AwsKmsUtils.Dummy__ 144 var _ m_KeyStoreErrorMessages.Dummy__ 145 var _ m_KmsArn.Dummy__ 146 var _ m_Structure.Dummy__ 147 var _ m_KMSKeystoreOperations.Dummy__ 148 var _ m_DDBKeystoreOperations.Dummy__ 149 var _ m_CreateKeys.Dummy__ 150 var _ m_CreateKeyStoreTable.Dummy__ 151 var _ m_GetKeys.Dummy__ 152 var _ m_AwsCryptographyKeyStoreOperations.Dummy__ 153 var _ m_Com_Amazonaws_Kms.Dummy__ 154 var _ m_Com_Amazonaws_Dynamodb.Dummy__ 155 var _ m_KeyStore.Dummy__ 156 var _ m_AlgorithmSuites.Dummy__ 157 var _ m_Materials.Dummy__ 158 var _ m_Keyring.Dummy__ 159 var _ m_MultiKeyring.Dummy__ 160 var _ m_AwsKmsMrkAreUnique.Dummy__ 161 var _ m_Constants.Dummy__ 162 var _ m_MaterialWrapping.Dummy__ 163 var _ m_CanonicalEncryptionContext.Dummy__ 164 var _ m_IntermediateKeyWrapping.Dummy__ 165 var _ m_EdkWrapping.Dummy__ 166 var _ m_ErrorMessages.Dummy__ 167 168 type Dummy__ struct{} 169 170 // Definition of class AwsKmsKeyring 171 type AwsKmsKeyring struct { 172 _client m_ComAmazonawsKmsTypes.IKMSClient 173 _awsKmsKey _dafny.Sequence 174 _grantTokens _dafny.Sequence 175 _awsKmsArn m_AwsArnParsing.AwsKmsIdentifier 176 } 177 178 func New_AwsKmsKeyring_() *AwsKmsKeyring { 179 _this := AwsKmsKeyring{} 180 181 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 182 _this._awsKmsKey = _dafny.EmptySeq.SetString() 183 _this._grantTokens = _dafny.EmptySeq 184 _this._awsKmsArn = m_AwsArnParsing.AwsKmsIdentifier{} 185 return &_this 186 } 187 188 type CompanionStruct_AwsKmsKeyring_ struct { 189 } 190 191 var Companion_AwsKmsKeyring_ = CompanionStruct_AwsKmsKeyring_{} 192 193 func (_this *AwsKmsKeyring) Equals(other *AwsKmsKeyring) bool { 194 return _this == other 195 } 196 197 func (_this *AwsKmsKeyring) EqualsGeneric(x interface{}) bool { 198 other, ok := x.(*AwsKmsKeyring) 199 return ok && _this.Equals(other) 200 } 201 202 func (*AwsKmsKeyring) String() string { 203 return "AwsKmsKeyring.AwsKmsKeyring" 204 } 205 206 func Type_AwsKmsKeyring_() _dafny.TypeDescriptor { 207 return type_AwsKmsKeyring_{} 208 } 209 210 type type_AwsKmsKeyring_ struct { 211 } 212 213 func (_this type_AwsKmsKeyring_) Default() interface{} { 214 return (*AwsKmsKeyring)(nil) 215 } 216 217 func (_this type_AwsKmsKeyring_) String() string { 218 return "AwsKmsKeyring.AwsKmsKeyring" 219 } 220 func (_this *AwsKmsKeyring) ParentTraits_() []*_dafny.TraitID { 221 return [](*_dafny.TraitID){m_Keyring.Companion_VerifiableInterface_.TraitID_, m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.TraitID_} 222 } 223 224 var _ m_Keyring.VerifiableInterface = &AwsKmsKeyring{} 225 var _ m_AwsCryptographyMaterialProvidersTypes.IKeyring = &AwsKmsKeyring{} 226 var _ _dafny.TraitOffspring = &AwsKmsKeyring{} 227 228 func (_this *AwsKmsKeyring) OnDecrypt(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result { 229 var _out2 m_Wrappers.Result 230 _ = _out2 231 _out2 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnDecrypt(_this, input) 232 return _out2 233 } 234 func (_this *AwsKmsKeyring) OnEncrypt(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result { 235 var _out2 m_Wrappers.Result 236 _ = _out2 237 _out2 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnEncrypt(_this, input) 238 return _out2 239 } 240 func (_this *AwsKmsKeyring) Ctor__(client m_ComAmazonawsKmsTypes.IKMSClient, awsKmsKey _dafny.Sequence, grantTokens _dafny.Sequence) { 241 { 242 var _0_parsedAwsKmsId m_Wrappers.Result 243 _ = _0_parsedAwsKmsId 244 _0_parsedAwsKmsId = m_AwsArnParsing.Companion_Default___.ParseAwsKmsIdentifier(awsKmsKey) 245 (_this)._client = client 246 (_this)._awsKmsKey = awsKmsKey 247 (_this)._awsKmsArn = (_0_parsedAwsKmsId).Dtor_value().(m_AwsArnParsing.AwsKmsIdentifier) 248 (_this)._grantTokens = grantTokens 249 } 250 } 251 func (_this *AwsKmsKeyring) OnEncrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result { 252 { 253 var res m_Wrappers.Result = m_Wrappers.Result{} 254 _ = res 255 var _0_materials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials 256 _ = _0_materials 257 _0_materials = (input).Dtor_materials() 258 var _1_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 259 _ = _1_suite 260 _1_suite = ((input).Dtor_materials()).Dtor_algorithmSuite() 261 var _2_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptyMap) 262 _ = _2_valueOrError0 263 _2_valueOrError0 = m_AwsKmsUtils.Companion_Default___.StringifyEncryptionContext(((input).Dtor_materials()).Dtor_encryptionContext()) 264 if (_2_valueOrError0).IsFailure() { 265 res = (_2_valueOrError0).PropagateFailure() 266 return res 267 } 268 var _3_stringifiedEncCtx _dafny.Map 269 _ = _3_stringifiedEncCtx 270 _3_stringifiedEncCtx = (_2_valueOrError0).Extract().(_dafny.Map) 271 var _4_kmsGenerateAndWrap *KmsGenerateAndWrapKeyMaterial 272 _ = _4_kmsGenerateAndWrap 273 var _nw0 *KmsGenerateAndWrapKeyMaterial = New_KmsGenerateAndWrapKeyMaterial_() 274 _ = _nw0 275 _nw0.Ctor__((_this).Client(), (_this).AwsKmsKey(), (_this).GrantTokens()) 276 _4_kmsGenerateAndWrap = _nw0 277 var _5_kmsWrap *KmsWrapKeyMaterial 278 _ = _5_kmsWrap 279 var _nw1 *KmsWrapKeyMaterial = New_KmsWrapKeyMaterial_() 280 _ = _nw1 281 _nw1.Ctor__((_this).Client(), (_this).AwsKmsKey(), (_this).GrantTokens()) 282 _5_kmsWrap = _nw1 283 var _6_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_EdkWrapping.Companion_WrapEdkMaterialOutput_.Default(Companion_KmsWrapInfo_.Default())) 284 _ = _6_valueOrError1 285 var _out0 m_Wrappers.Result 286 _ = _out0 287 _out0 = m_EdkWrapping.Companion_Default___.WrapEdkMaterial(_0_materials, _5_kmsWrap, _4_kmsGenerateAndWrap) 288 _6_valueOrError1 = _out0 289 if (_6_valueOrError1).IsFailure() { 290 res = (_6_valueOrError1).PropagateFailure() 291 return res 292 } 293 var _7_wrapOutput m_EdkWrapping.WrapEdkMaterialOutput 294 _ = _7_wrapOutput 295 _7_wrapOutput = (_6_valueOrError1).Extract().(m_EdkWrapping.WrapEdkMaterialOutput) 296 var _8_kmsKeyArn _dafny.Sequence 297 _ = _8_kmsKeyArn 298 _8_kmsKeyArn = ((_7_wrapOutput).Dtor_wrapInfo().(KmsWrapInfo)).Dtor_kmsKeyArn() 299 var _9_symmetricSigningKeyList m_Wrappers.Option 300 _ = _9_symmetricSigningKeyList 301 if ((_7_wrapOutput).Dtor_symmetricSigningKey()).Is_Some() { 302 _9_symmetricSigningKeyList = m_Wrappers.Companion_Option_.Create_Some_(_dafny.SeqOf(((_7_wrapOutput).Dtor_symmetricSigningKey()).Dtor_value().(_dafny.Sequence))) 303 } else { 304 _9_symmetricSigningKeyList = m_Wrappers.Companion_Option_.Create_None_() 305 } 306 var _10_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_UTF8.Companion_ValidUTF8Bytes_.Witness()) 307 _ = _10_valueOrError2 308 _10_valueOrError2 = (m_UTF8.Encode(_8_kmsKeyArn)).MapFailure(func(coer52 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 309 return func(arg53 interface{}) interface{} { 310 return coer52(arg53.(_dafny.Sequence)) 311 } 312 }(m_AwsKmsUtils.Companion_Default___.WrapStringToError)) 313 if (_10_valueOrError2).IsFailure() { 314 res = (_10_valueOrError2).PropagateFailure() 315 return res 316 } 317 var _11_providerInfo _dafny.Sequence 318 _ = _11_providerInfo 319 _11_providerInfo = (_10_valueOrError2).Extract().(_dafny.Sequence) 320 var _12_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 321 _ = _12_valueOrError3 322 _12_valueOrError3 = m_Wrappers.Companion_Default___.Need((_dafny.IntOfUint32((_11_providerInfo).Cardinality())).Cmp(m_StandardLibrary_UInt.Companion_Default___.UINT16__LIMIT()) < 0, m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from AWS KMS GenerateDataKey: Key ID too long."))) 323 if (_12_valueOrError3).IsFailure() { 324 res = (_12_valueOrError3).PropagateFailure() 325 return res 326 } 327 var _13_edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey 328 _ = _13_edk 329 _13_edk = m_AwsCryptographyMaterialProvidersTypes.Companion_EncryptedDataKey_.Create_EncryptedDataKey_(m_Constants.Companion_Default___.PROVIDER__ID(), _11_providerInfo, (_7_wrapOutput).Dtor_wrappedMaterial()) 330 if (_7_wrapOutput).Is_GenerateAndWrapEdkMaterialOutput() { 331 var _14_valueOrError4 m_Wrappers.Result = m_Wrappers.Result{} 332 _ = _14_valueOrError4 333 _14_valueOrError4 = m_Materials.Companion_Default___.EncryptionMaterialAddDataKey(_0_materials, (_7_wrapOutput).Dtor_plaintextDataKey(), _dafny.SeqOf(_13_edk), _9_symmetricSigningKeyList) 334 if (_14_valueOrError4).IsFailure() { 335 res = (_14_valueOrError4).PropagateFailure() 336 return res 337 } 338 var _15_result m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials 339 _ = _15_result 340 _15_result = (_14_valueOrError4).Extract().(m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) 341 res = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnEncryptOutput_.Create_OnEncryptOutput_(_15_result)) 342 return res 343 } else if (_7_wrapOutput).Is_WrapOnlyEdkMaterialOutput() { 344 var _16_valueOrError5 m_Wrappers.Result = m_Wrappers.Result{} 345 _ = _16_valueOrError5 346 _16_valueOrError5 = m_Materials.Companion_Default___.EncryptionMaterialAddEncryptedDataKeys(_0_materials, _dafny.SeqOf(_13_edk), _9_symmetricSigningKeyList) 347 if (_16_valueOrError5).IsFailure() { 348 res = (_16_valueOrError5).PropagateFailure() 349 return res 350 } 351 var _17_result m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials 352 _ = _17_result 353 _17_result = (_16_valueOrError5).Extract().(m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) 354 res = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnEncryptOutput_.Create_OnEncryptOutput_(_17_result)) 355 return res 356 } 357 return res 358 } 359 } 360 func (_this *AwsKmsKeyring) OnDecrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result { 361 { 362 var res m_Wrappers.Result = m_Wrappers.Result{} 363 _ = res 364 var _0_materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 365 _ = _0_materials 366 _0_materials = (input).Dtor_materials() 367 var _1_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 368 _ = _1_suite 369 _1_suite = ((input).Dtor_materials()).Dtor_algorithmSuite() 370 var _2_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 371 _ = _2_valueOrError0 372 _2_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_Materials.Companion_Default___.DecryptionMaterialsWithoutPlaintextDataKey(_0_materials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Keyring received decryption materials that already contain a plaintext data key."))) 373 if (_2_valueOrError0).IsFailure() { 374 res = (_2_valueOrError0).PropagateFailure() 375 return res 376 } 377 var _3_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 378 _ = _3_valueOrError1 379 _3_valueOrError1 = m_AwsKmsUtils.Companion_Default___.OkForDecrypt((_this).AwsKmsArn(), (_this).AwsKmsKey()) 380 if (_3_valueOrError1).IsFailure() { 381 res = (_3_valueOrError1).PropagateFailure() 382 return res 383 } 384 var _4_filter *OnDecryptEncryptedDataKeyFilter 385 _ = _4_filter 386 var _nw0 *OnDecryptEncryptedDataKeyFilter = New_OnDecryptEncryptedDataKeyFilter_() 387 _ = _nw0 388 _nw0.Ctor__((_this).AwsKmsKey()) 389 _4_filter = _nw0 390 var _5_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq) 391 _ = _5_valueOrError2 392 var _out0 m_Wrappers.Result 393 _ = _out0 394 _out0 = m_Actions.Companion_Default___.FilterWithResult(_4_filter, (input).Dtor_encryptedDataKeys()) 395 _5_valueOrError2 = _out0 396 if (_5_valueOrError2).IsFailure() { 397 res = (_5_valueOrError2).PropagateFailure() 398 return res 399 } 400 var _6_edksToAttempt _dafny.Sequence 401 _ = _6_edksToAttempt 402 _6_edksToAttempt = (_5_valueOrError2).Extract().(_dafny.Sequence) 403 if (_dafny.IntOfUint32((_6_edksToAttempt).Cardinality())).Sign() == 0 { 404 var _7_valueOrError3 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq.SetString()) 405 _ = _7_valueOrError3 406 _7_valueOrError3 = m_ErrorMessages.Companion_Default___.IncorrectDataKeys((input).Dtor_encryptedDataKeys(), ((input).Dtor_materials()).Dtor_algorithmSuite(), _dafny.SeqOfString("")) 407 if (_7_valueOrError3).IsFailure() { 408 res = (_7_valueOrError3).PropagateFailure() 409 return res 410 } 411 var _8_errorMessage _dafny.Sequence 412 _ = _8_errorMessage 413 _8_errorMessage = (_7_valueOrError3).Extract().(_dafny.Sequence) 414 res = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_8_errorMessage)) 415 return res 416 } 417 var _9_decryptClosure m_Actions.ActionWithResult 418 _ = _9_decryptClosure 419 var _nw1 *DecryptSingleEncryptedDataKey = New_DecryptSingleEncryptedDataKey_() 420 _ = _nw1 421 _nw1.Ctor__(_0_materials, (_this).Client(), (_this).AwsKmsKey(), (_this).GrantTokens()) 422 _9_decryptClosure = _nw1 423 var _10_outcome m_Wrappers.Result 424 _ = _10_outcome 425 var _out1 m_Wrappers.Result 426 _ = _out1 427 _out1 = m_Actions.Companion_Default___.ReduceToSuccess(_9_decryptClosure, _6_edksToAttempt) 428 _10_outcome = _out1 429 var _11_valueOrError4 m_Wrappers.Result = m_Wrappers.Result{} 430 _ = _11_valueOrError4 431 _11_valueOrError4 = (_10_outcome).MapFailure(func(coer53 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 432 return func(arg54 interface{}) interface{} { 433 return coer53(arg54.(_dafny.Sequence)) 434 } 435 }(func(_12_errors _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error { 436 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_CollectionOfErrors_(_12_errors, _dafny.SeqOfString("No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`.")) 437 })) 438 if (_11_valueOrError4).IsFailure() { 439 res = (_11_valueOrError4).PropagateFailure() 440 return res 441 } 442 var _13_SealedDecryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 443 _ = _13_SealedDecryptionMaterials 444 _13_SealedDecryptionMaterials = (_11_valueOrError4).Extract().(m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) 445 res = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnDecryptOutput_.Create_OnDecryptOutput_(_13_SealedDecryptionMaterials)) 446 return res 447 return res 448 } 449 } 450 func (_this *AwsKmsKeyring) Client() m_ComAmazonawsKmsTypes.IKMSClient { 451 { 452 return _this._client 453 } 454 } 455 func (_this *AwsKmsKeyring) AwsKmsKey() _dafny.Sequence { 456 { 457 return _this._awsKmsKey 458 } 459 } 460 func (_this *AwsKmsKeyring) GrantTokens() _dafny.Sequence { 461 { 462 return _this._grantTokens 463 } 464 } 465 func (_this *AwsKmsKeyring) AwsKmsArn() m_AwsArnParsing.AwsKmsIdentifier { 466 { 467 return _this._awsKmsArn 468 } 469 } 470 471 // End of class AwsKmsKeyring 472 473 // Definition of class OnDecryptEncryptedDataKeyFilter 474 type OnDecryptEncryptedDataKeyFilter struct { 475 _awsKmsKey _dafny.Sequence 476 } 477 478 func New_OnDecryptEncryptedDataKeyFilter_() *OnDecryptEncryptedDataKeyFilter { 479 _this := OnDecryptEncryptedDataKeyFilter{} 480 481 _this._awsKmsKey = _dafny.EmptySeq.SetString() 482 return &_this 483 } 484 485 type CompanionStruct_OnDecryptEncryptedDataKeyFilter_ struct { 486 } 487 488 var Companion_OnDecryptEncryptedDataKeyFilter_ = CompanionStruct_OnDecryptEncryptedDataKeyFilter_{} 489 490 func (_this *OnDecryptEncryptedDataKeyFilter) Equals(other *OnDecryptEncryptedDataKeyFilter) bool { 491 return _this == other 492 } 493 494 func (_this *OnDecryptEncryptedDataKeyFilter) EqualsGeneric(x interface{}) bool { 495 other, ok := x.(*OnDecryptEncryptedDataKeyFilter) 496 return ok && _this.Equals(other) 497 } 498 499 func (*OnDecryptEncryptedDataKeyFilter) String() string { 500 return "AwsKmsKeyring.OnDecryptEncryptedDataKeyFilter" 501 } 502 503 func Type_OnDecryptEncryptedDataKeyFilter_() _dafny.TypeDescriptor { 504 return type_OnDecryptEncryptedDataKeyFilter_{} 505 } 506 507 type type_OnDecryptEncryptedDataKeyFilter_ struct { 508 } 509 510 func (_this type_OnDecryptEncryptedDataKeyFilter_) Default() interface{} { 511 return (*OnDecryptEncryptedDataKeyFilter)(nil) 512 } 513 514 func (_this type_OnDecryptEncryptedDataKeyFilter_) String() string { 515 return "AwsKmsKeyring.OnDecryptEncryptedDataKeyFilter" 516 } 517 func (_this *OnDecryptEncryptedDataKeyFilter) ParentTraits_() []*_dafny.TraitID { 518 return [](*_dafny.TraitID){m_Actions.Companion_DeterministicActionWithResult_.TraitID_, m_Actions.Companion_DeterministicAction_.TraitID_} 519 } 520 521 var _ m_Actions.DeterministicActionWithResult = &OnDecryptEncryptedDataKeyFilter{} 522 var _ m_Actions.DeterministicAction = &OnDecryptEncryptedDataKeyFilter{} 523 var _ _dafny.TraitOffspring = &OnDecryptEncryptedDataKeyFilter{} 524 525 func (_this *OnDecryptEncryptedDataKeyFilter) Ctor__(awsKmsKey _dafny.Sequence) { 526 { 527 (_this)._awsKmsKey = awsKmsKey 528 } 529 } 530 func (_this *OnDecryptEncryptedDataKeyFilter) Invoke(edk interface{}) interface{} { 531 { 532 var edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey = edk.(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey) 533 _ = edk 534 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(false) 535 _ = res 536 if !_dafny.Companion_Sequence_.Equal((edk).Dtor_keyProviderId(), m_Constants.Companion_Default___.PROVIDER__ID()) { 537 res = m_Wrappers.Companion_Result_.Create_Success_(false) 538 return res 539 } 540 if !(m_UTF8.Companion_Default___.ValidUTF8Seq((edk).Dtor_keyProviderInfo())) { 541 res = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid AWS KMS encoding, provider info is not UTF8."))) 542 return res 543 } 544 var _0_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq.SetString()) 545 _ = _0_valueOrError0 546 _0_valueOrError0 = (m_UTF8.Decode((edk).Dtor_keyProviderInfo())).MapFailure(func(coer54 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 547 return func(arg55 interface{}) interface{} { 548 return coer54(arg55.(_dafny.Sequence)) 549 } 550 }(m_AwsKmsUtils.Companion_Default___.WrapStringToError)) 551 if (_0_valueOrError0).IsFailure() { 552 res = (_0_valueOrError0).PropagateFailure() 553 return res 554 } 555 var _1_keyId _dafny.Sequence 556 _ = _1_keyId 557 _1_keyId = (_0_valueOrError0).Extract().(_dafny.Sequence) 558 var _2_valueOrError1 m_Wrappers.Result = m_Wrappers.Result{} 559 _ = _2_valueOrError1 560 _2_valueOrError1 = (m_AwsArnParsing.Companion_Default___.ParseAwsKmsArn(_1_keyId)).MapFailure(func(coer55 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 561 return func(arg56 interface{}) interface{} { 562 return coer55(arg56.(_dafny.Sequence)) 563 } 564 }(m_AwsKmsUtils.Companion_Default___.WrapStringToError)) 565 if (_2_valueOrError1).IsFailure() { 566 res = (_2_valueOrError1).PropagateFailure() 567 return res 568 } 569 var _3___v0 m_AwsArnParsing.AwsArn 570 _ = _3___v0 571 _3___v0 = (_2_valueOrError1).Extract().(m_AwsArnParsing.AwsArn) 572 res = m_Wrappers.Companion_Result_.Create_Success_(_dafny.Companion_Sequence_.Equal((_this).AwsKmsKey(), _1_keyId)) 573 return res 574 return res 575 } 576 } 577 func (_this *OnDecryptEncryptedDataKeyFilter) AwsKmsKey() _dafny.Sequence { 578 { 579 return _this._awsKmsKey 580 } 581 } 582 583 // End of class OnDecryptEncryptedDataKeyFilter 584 585 // Definition of class DecryptSingleEncryptedDataKey 586 type DecryptSingleEncryptedDataKey struct { 587 _materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 588 _client m_ComAmazonawsKmsTypes.IKMSClient 589 _awsKmsKey _dafny.Sequence 590 _grantTokens _dafny.Sequence 591 } 592 593 func New_DecryptSingleEncryptedDataKey_() *DecryptSingleEncryptedDataKey { 594 _this := DecryptSingleEncryptedDataKey{} 595 596 _this._materials = m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials{} 597 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 598 _this._awsKmsKey = _dafny.EmptySeq.SetString() 599 _this._grantTokens = _dafny.EmptySeq 600 return &_this 601 } 602 603 type CompanionStruct_DecryptSingleEncryptedDataKey_ struct { 604 } 605 606 var Companion_DecryptSingleEncryptedDataKey_ = CompanionStruct_DecryptSingleEncryptedDataKey_{} 607 608 func (_this *DecryptSingleEncryptedDataKey) Equals(other *DecryptSingleEncryptedDataKey) bool { 609 return _this == other 610 } 611 612 func (_this *DecryptSingleEncryptedDataKey) EqualsGeneric(x interface{}) bool { 613 other, ok := x.(*DecryptSingleEncryptedDataKey) 614 return ok && _this.Equals(other) 615 } 616 617 func (*DecryptSingleEncryptedDataKey) String() string { 618 return "AwsKmsKeyring.DecryptSingleEncryptedDataKey" 619 } 620 621 func Type_DecryptSingleEncryptedDataKey_() _dafny.TypeDescriptor { 622 return type_DecryptSingleEncryptedDataKey_{} 623 } 624 625 type type_DecryptSingleEncryptedDataKey_ struct { 626 } 627 628 func (_this type_DecryptSingleEncryptedDataKey_) Default() interface{} { 629 return (*DecryptSingleEncryptedDataKey)(nil) 630 } 631 632 func (_this type_DecryptSingleEncryptedDataKey_) String() string { 633 return "AwsKmsKeyring.DecryptSingleEncryptedDataKey" 634 } 635 func (_this *DecryptSingleEncryptedDataKey) ParentTraits_() []*_dafny.TraitID { 636 return [](*_dafny.TraitID){m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 637 } 638 639 var _ m_Actions.ActionWithResult = &DecryptSingleEncryptedDataKey{} 640 var _ m_Actions.Action = &DecryptSingleEncryptedDataKey{} 641 var _ _dafny.TraitOffspring = &DecryptSingleEncryptedDataKey{} 642 643 func (_this *DecryptSingleEncryptedDataKey) Ctor__(materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, client m_ComAmazonawsKmsTypes.IKMSClient, awsKmsKey _dafny.Sequence, grantTokens _dafny.Sequence) { 644 { 645 (_this)._materials = materials 646 (_this)._client = client 647 (_this)._awsKmsKey = awsKmsKey 648 (_this)._grantTokens = grantTokens 649 } 650 } 651 func (_this *DecryptSingleEncryptedDataKey) Invoke(edk interface{}) interface{} { 652 { 653 var edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey = edk.(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey) 654 _ = edk 655 var res m_Wrappers.Result = m_Wrappers.Result{} 656 _ = res 657 var _0_kmsUnwrap *KmsUnwrapKeyMaterial 658 _ = _0_kmsUnwrap 659 var _nw0 *KmsUnwrapKeyMaterial = New_KmsUnwrapKeyMaterial_() 660 _ = _nw0 661 _nw0.Ctor__((_this).Client(), (_this).AwsKmsKey(), (_this).GrantTokens()) 662 _0_kmsUnwrap = _nw0 663 var _1_unwrapOutputRes m_Wrappers.Result 664 _ = _1_unwrapOutputRes 665 var _out0 m_Wrappers.Result 666 _ = _out0 667 _out0 = m_EdkWrapping.Companion_Default___.UnwrapEdkMaterial((edk).Dtor_ciphertext(), (_this).Materials(), _0_kmsUnwrap) 668 _1_unwrapOutputRes = _out0 669 var _2_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_EdkWrapping.Companion_UnwrapEdkMaterialOutput_.Default(Companion_KmsUnwrapInfo_.Default())) 670 _ = _2_valueOrError0 671 _2_valueOrError0 = _1_unwrapOutputRes 672 if (_2_valueOrError0).IsFailure() { 673 res = (_2_valueOrError0).PropagateFailure() 674 return res 675 } 676 var _3_unwrapOutput m_EdkWrapping.UnwrapEdkMaterialOutput 677 _ = _3_unwrapOutput 678 _3_unwrapOutput = (_2_valueOrError0).Extract().(m_EdkWrapping.UnwrapEdkMaterialOutput) 679 var _4_valueOrError1 m_Wrappers.Result = m_Wrappers.Result{} 680 _ = _4_valueOrError1 681 _4_valueOrError1 = m_Materials.Companion_Default___.DecryptionMaterialsAddDataKey((_this).Materials(), (_3_unwrapOutput).Dtor_plaintextDataKey(), (_3_unwrapOutput).Dtor_symmetricSigningKey()) 682 if (_4_valueOrError1).IsFailure() { 683 res = (_4_valueOrError1).PropagateFailure() 684 return res 685 } 686 var _5_result m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 687 _ = _5_result 688 _5_result = (_4_valueOrError1).Extract().(m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) 689 res = m_Wrappers.Companion_Result_.Create_Success_(_5_result) 690 return res 691 return res 692 } 693 } 694 func (_this *DecryptSingleEncryptedDataKey) Materials() m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials { 695 { 696 return _this._materials 697 } 698 } 699 func (_this *DecryptSingleEncryptedDataKey) Client() m_ComAmazonawsKmsTypes.IKMSClient { 700 { 701 return _this._client 702 } 703 } 704 func (_this *DecryptSingleEncryptedDataKey) AwsKmsKey() _dafny.Sequence { 705 { 706 return _this._awsKmsKey 707 } 708 } 709 func (_this *DecryptSingleEncryptedDataKey) GrantTokens() _dafny.Sequence { 710 { 711 return _this._grantTokens 712 } 713 } 714 715 // End of class DecryptSingleEncryptedDataKey 716 717 // Definition of datatype KmsUnwrapInfo 718 type KmsUnwrapInfo struct { 719 Data_KmsUnwrapInfo_ 720 } 721 722 func (_this KmsUnwrapInfo) Get_() Data_KmsUnwrapInfo_ { 723 return _this.Data_KmsUnwrapInfo_ 724 } 725 726 type Data_KmsUnwrapInfo_ interface { 727 isKmsUnwrapInfo() 728 } 729 730 type CompanionStruct_KmsUnwrapInfo_ struct { 731 } 732 733 var Companion_KmsUnwrapInfo_ = CompanionStruct_KmsUnwrapInfo_{} 734 735 type KmsUnwrapInfo_KmsUnwrapInfo struct { 736 } 737 738 func (KmsUnwrapInfo_KmsUnwrapInfo) isKmsUnwrapInfo() {} 739 740 func (CompanionStruct_KmsUnwrapInfo_) Create_KmsUnwrapInfo_() KmsUnwrapInfo { 741 return KmsUnwrapInfo{KmsUnwrapInfo_KmsUnwrapInfo{}} 742 } 743 744 func (_this KmsUnwrapInfo) Is_KmsUnwrapInfo() bool { 745 _, ok := _this.Get_().(KmsUnwrapInfo_KmsUnwrapInfo) 746 return ok 747 } 748 749 func (CompanionStruct_KmsUnwrapInfo_) Default() KmsUnwrapInfo { 750 return Companion_KmsUnwrapInfo_.Create_KmsUnwrapInfo_() 751 } 752 753 func (_ CompanionStruct_KmsUnwrapInfo_) AllSingletonConstructors() _dafny.Iterator { 754 i := -1 755 return func() (interface{}, bool) { 756 i++ 757 switch i { 758 case 0: 759 return Companion_KmsUnwrapInfo_.Create_KmsUnwrapInfo_(), true 760 default: 761 return KmsUnwrapInfo{}, false 762 } 763 } 764 } 765 766 func (_this KmsUnwrapInfo) String() string { 767 switch _this.Get_().(type) { 768 case nil: 769 return "null" 770 case KmsUnwrapInfo_KmsUnwrapInfo: 771 { 772 return "AwsKmsKeyring.KmsUnwrapInfo.KmsUnwrapInfo" 773 } 774 default: 775 { 776 return "<unexpected>" 777 } 778 } 779 } 780 781 func (_this KmsUnwrapInfo) Equals(other KmsUnwrapInfo) bool { 782 switch _this.Get_().(type) { 783 case KmsUnwrapInfo_KmsUnwrapInfo: 784 { 785 _, ok := other.Get_().(KmsUnwrapInfo_KmsUnwrapInfo) 786 return ok 787 } 788 default: 789 { 790 return false // unexpected 791 } 792 } 793 } 794 795 func (_this KmsUnwrapInfo) EqualsGeneric(other interface{}) bool { 796 typed, ok := other.(KmsUnwrapInfo) 797 return ok && _this.Equals(typed) 798 } 799 800 func Type_KmsUnwrapInfo_() _dafny.TypeDescriptor { 801 return type_KmsUnwrapInfo_{} 802 } 803 804 type type_KmsUnwrapInfo_ struct { 805 } 806 807 func (_this type_KmsUnwrapInfo_) Default() interface{} { 808 return Companion_KmsUnwrapInfo_.Default() 809 } 810 811 func (_this type_KmsUnwrapInfo_) String() string { 812 return "AwsKmsKeyring.KmsUnwrapInfo" 813 } 814 func (_this KmsUnwrapInfo) ParentTraits_() []*_dafny.TraitID { 815 return [](*_dafny.TraitID){} 816 } 817 818 var _ _dafny.TraitOffspring = KmsUnwrapInfo{} 819 820 // End of datatype KmsUnwrapInfo 821 822 // Definition of datatype KmsWrapInfo 823 type KmsWrapInfo struct { 824 Data_KmsWrapInfo_ 825 } 826 827 func (_this KmsWrapInfo) Get_() Data_KmsWrapInfo_ { 828 return _this.Data_KmsWrapInfo_ 829 } 830 831 type Data_KmsWrapInfo_ interface { 832 isKmsWrapInfo() 833 } 834 835 type CompanionStruct_KmsWrapInfo_ struct { 836 } 837 838 var Companion_KmsWrapInfo_ = CompanionStruct_KmsWrapInfo_{} 839 840 type KmsWrapInfo_KmsWrapInfo struct { 841 KmsKeyArn _dafny.Sequence 842 } 843 844 func (KmsWrapInfo_KmsWrapInfo) isKmsWrapInfo() {} 845 846 func (CompanionStruct_KmsWrapInfo_) Create_KmsWrapInfo_(KmsKeyArn _dafny.Sequence) KmsWrapInfo { 847 return KmsWrapInfo{KmsWrapInfo_KmsWrapInfo{KmsKeyArn}} 848 } 849 850 func (_this KmsWrapInfo) Is_KmsWrapInfo() bool { 851 _, ok := _this.Get_().(KmsWrapInfo_KmsWrapInfo) 852 return ok 853 } 854 855 func (CompanionStruct_KmsWrapInfo_) Default() KmsWrapInfo { 856 return Companion_KmsWrapInfo_.Create_KmsWrapInfo_(_dafny.EmptySeq.SetString()) 857 } 858 859 func (_this KmsWrapInfo) Dtor_kmsKeyArn() _dafny.Sequence { 860 return _this.Get_().(KmsWrapInfo_KmsWrapInfo).KmsKeyArn 861 } 862 863 func (_this KmsWrapInfo) String() string { 864 switch data := _this.Get_().(type) { 865 case nil: 866 return "null" 867 case KmsWrapInfo_KmsWrapInfo: 868 { 869 return "AwsKmsKeyring.KmsWrapInfo.KmsWrapInfo" + "(" + _dafny.String(data.KmsKeyArn) + ")" 870 } 871 default: 872 { 873 return "<unexpected>" 874 } 875 } 876 } 877 878 func (_this KmsWrapInfo) Equals(other KmsWrapInfo) bool { 879 switch data1 := _this.Get_().(type) { 880 case KmsWrapInfo_KmsWrapInfo: 881 { 882 data2, ok := other.Get_().(KmsWrapInfo_KmsWrapInfo) 883 return ok && data1.KmsKeyArn.Equals(data2.KmsKeyArn) 884 } 885 default: 886 { 887 return false // unexpected 888 } 889 } 890 } 891 892 func (_this KmsWrapInfo) EqualsGeneric(other interface{}) bool { 893 typed, ok := other.(KmsWrapInfo) 894 return ok && _this.Equals(typed) 895 } 896 897 func Type_KmsWrapInfo_() _dafny.TypeDescriptor { 898 return type_KmsWrapInfo_{} 899 } 900 901 type type_KmsWrapInfo_ struct { 902 } 903 904 func (_this type_KmsWrapInfo_) Default() interface{} { 905 return Companion_KmsWrapInfo_.Default() 906 } 907 908 func (_this type_KmsWrapInfo_) String() string { 909 return "AwsKmsKeyring.KmsWrapInfo" 910 } 911 func (_this KmsWrapInfo) ParentTraits_() []*_dafny.TraitID { 912 return [](*_dafny.TraitID){} 913 } 914 915 var _ _dafny.TraitOffspring = KmsWrapInfo{} 916 917 // End of datatype KmsWrapInfo 918 919 // Definition of class KmsUnwrapKeyMaterial 920 type KmsUnwrapKeyMaterial struct { 921 _client m_ComAmazonawsKmsTypes.IKMSClient 922 _grantTokens _dafny.Sequence 923 _awsKmsKey _dafny.Sequence 924 } 925 926 func New_KmsUnwrapKeyMaterial_() *KmsUnwrapKeyMaterial { 927 _this := KmsUnwrapKeyMaterial{} 928 929 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 930 _this._grantTokens = _dafny.EmptySeq 931 _this._awsKmsKey = _dafny.EmptySeq.SetString() 932 return &_this 933 } 934 935 type CompanionStruct_KmsUnwrapKeyMaterial_ struct { 936 } 937 938 var Companion_KmsUnwrapKeyMaterial_ = CompanionStruct_KmsUnwrapKeyMaterial_{} 939 940 func (_this *KmsUnwrapKeyMaterial) Equals(other *KmsUnwrapKeyMaterial) bool { 941 return _this == other 942 } 943 944 func (_this *KmsUnwrapKeyMaterial) EqualsGeneric(x interface{}) bool { 945 other, ok := x.(*KmsUnwrapKeyMaterial) 946 return ok && _this.Equals(other) 947 } 948 949 func (*KmsUnwrapKeyMaterial) String() string { 950 return "AwsKmsKeyring.KmsUnwrapKeyMaterial" 951 } 952 953 func Type_KmsUnwrapKeyMaterial_() _dafny.TypeDescriptor { 954 return type_KmsUnwrapKeyMaterial_{} 955 } 956 957 type type_KmsUnwrapKeyMaterial_ struct { 958 } 959 960 func (_this type_KmsUnwrapKeyMaterial_) Default() interface{} { 961 return (*KmsUnwrapKeyMaterial)(nil) 962 } 963 964 func (_this type_KmsUnwrapKeyMaterial_) String() string { 965 return "AwsKmsKeyring.KmsUnwrapKeyMaterial" 966 } 967 func (_this *KmsUnwrapKeyMaterial) ParentTraits_() []*_dafny.TraitID { 968 return [](*_dafny.TraitID){m_MaterialWrapping.Companion_UnwrapMaterial_.TraitID_, m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 969 } 970 971 var _ m_MaterialWrapping.UnwrapMaterial = &KmsUnwrapKeyMaterial{} 972 var _ m_Actions.ActionWithResult = &KmsUnwrapKeyMaterial{} 973 var _ m_Actions.Action = &KmsUnwrapKeyMaterial{} 974 var _ _dafny.TraitOffspring = &KmsUnwrapKeyMaterial{} 975 976 func (_this *KmsUnwrapKeyMaterial) Ctor__(client m_ComAmazonawsKmsTypes.IKMSClient, awsKmsKey _dafny.Sequence, grantTokens _dafny.Sequence) { 977 { 978 (_this)._client = client 979 (_this)._awsKmsKey = awsKmsKey 980 (_this)._grantTokens = grantTokens 981 } 982 } 983 func (_this *KmsUnwrapKeyMaterial) Invoke(input interface{}) interface{} { 984 { 985 var input m_MaterialWrapping.UnwrapInput = input.(m_MaterialWrapping.UnwrapInput) 986 _ = input 987 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_UnwrapOutput_.Default(Companion_KmsUnwrapInfo_.Default())) 988 _ = res 989 var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 990 _ = _0_valueOrError0 991 _0_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_ComAmazonawsKmsTypes.Companion_Default___.IsValid__CiphertextType((input).Dtor_wrappedMaterial()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Ciphertext length invalid"))) 992 if (_0_valueOrError0).IsFailure() { 993 res = (_0_valueOrError0).PropagateFailure() 994 return res 995 } 996 var _1_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptyMap) 997 _ = _1_valueOrError1 998 _1_valueOrError1 = m_AwsKmsUtils.Companion_Default___.StringifyEncryptionContext((input).Dtor_encryptionContext()) 999 if (_1_valueOrError1).IsFailure() { 1000 res = (_1_valueOrError1).PropagateFailure() 1001 return res 1002 } 1003 var _2_stringifiedEncCtx _dafny.Map 1004 _ = _2_stringifiedEncCtx 1005 _2_stringifiedEncCtx = (_1_valueOrError1).Extract().(_dafny.Map) 1006 var _3_decryptRequest m_ComAmazonawsKmsTypes.DecryptRequest 1007 _ = _3_decryptRequest 1008 _3_decryptRequest = m_ComAmazonawsKmsTypes.Companion_DecryptRequest_.Create_DecryptRequest_((input).Dtor_wrappedMaterial(), m_Wrappers.Companion_Option_.Create_Some_(_2_stringifiedEncCtx), m_Wrappers.Companion_Option_.Create_Some_((_this).GrantTokens()), m_Wrappers.Companion_Option_.Create_Some_((_this).AwsKmsKey()), m_Wrappers.Companion_Option_.Create_None_(), m_Wrappers.Companion_Option_.Create_None_(), m_Wrappers.Companion_Option_.Create_None_()) 1009 var _4_maybeDecryptResponse m_Wrappers.Result 1010 _ = _4_maybeDecryptResponse 1011 var _out0 m_Wrappers.Result 1012 _ = _out0 1013 _out0 = ((_this).Client()).Decrypt(_3_decryptRequest) 1014 _4_maybeDecryptResponse = _out0 1015 var _5_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_ComAmazonawsKmsTypes.Companion_DecryptResponse_.Default()) 1016 _ = _5_valueOrError2 1017 _5_valueOrError2 = (_4_maybeDecryptResponse).MapFailure(func(coer56 func(m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 1018 return func(arg57 interface{}) interface{} { 1019 return coer56(arg57.(m_ComAmazonawsKmsTypes.Error)) 1020 } 1021 }(func(_6_e m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error { 1022 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_ComAmazonawsKms_(_6_e) 1023 })) 1024 if (_5_valueOrError2).IsFailure() { 1025 res = (_5_valueOrError2).PropagateFailure() 1026 return res 1027 } 1028 var _7_decryptResponse m_ComAmazonawsKmsTypes.DecryptResponse 1029 _ = _7_decryptResponse 1030 _7_decryptResponse = (_5_valueOrError2).Extract().(m_ComAmazonawsKmsTypes.DecryptResponse) 1031 var _8_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1032 _ = _8_valueOrError3 1033 _8_valueOrError3 = m_Wrappers.Companion_Default___.Need((((((_7_decryptResponse).Dtor_KeyId()).Is_Some()) && (_dafny.Companion_Sequence_.Equal(((_7_decryptResponse).Dtor_KeyId()).Dtor_value().(_dafny.Sequence), (_this).AwsKmsKey()))) && (((_7_decryptResponse).Dtor_Plaintext()).Is_Some())) && ((_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength((input).Dtor_algorithmSuite()))).Cmp(_dafny.IntOfUint32((((_7_decryptResponse).Dtor_Plaintext()).Dtor_value().(_dafny.Sequence)).Cardinality())) == 0), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from KMS Decrypt"))) 1034 if (_8_valueOrError3).IsFailure() { 1035 res = (_8_valueOrError3).PropagateFailure() 1036 return res 1037 } 1038 var _9_output m_MaterialWrapping.UnwrapOutput 1039 _ = _9_output 1040 _9_output = m_MaterialWrapping.Companion_UnwrapOutput_.Create_UnwrapOutput_(((_7_decryptResponse).Dtor_Plaintext()).Dtor_value().(_dafny.Sequence), Companion_KmsUnwrapInfo_.Create_KmsUnwrapInfo_()) 1041 res = m_Wrappers.Companion_Result_.Create_Success_(_9_output) 1042 return res 1043 return res 1044 } 1045 } 1046 func (_this *KmsUnwrapKeyMaterial) Client() m_ComAmazonawsKmsTypes.IKMSClient { 1047 { 1048 return _this._client 1049 } 1050 } 1051 func (_this *KmsUnwrapKeyMaterial) GrantTokens() _dafny.Sequence { 1052 { 1053 return _this._grantTokens 1054 } 1055 } 1056 func (_this *KmsUnwrapKeyMaterial) AwsKmsKey() _dafny.Sequence { 1057 { 1058 return _this._awsKmsKey 1059 } 1060 } 1061 1062 // End of class KmsUnwrapKeyMaterial 1063 1064 // Definition of class KmsGenerateAndWrapKeyMaterial 1065 type KmsGenerateAndWrapKeyMaterial struct { 1066 _client m_ComAmazonawsKmsTypes.IKMSClient 1067 _awsKmsKey _dafny.Sequence 1068 _grantTokens _dafny.Sequence 1069 } 1070 1071 func New_KmsGenerateAndWrapKeyMaterial_() *KmsGenerateAndWrapKeyMaterial { 1072 _this := KmsGenerateAndWrapKeyMaterial{} 1073 1074 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 1075 _this._awsKmsKey = _dafny.EmptySeq.SetString() 1076 _this._grantTokens = _dafny.EmptySeq 1077 return &_this 1078 } 1079 1080 type CompanionStruct_KmsGenerateAndWrapKeyMaterial_ struct { 1081 } 1082 1083 var Companion_KmsGenerateAndWrapKeyMaterial_ = CompanionStruct_KmsGenerateAndWrapKeyMaterial_{} 1084 1085 func (_this *KmsGenerateAndWrapKeyMaterial) Equals(other *KmsGenerateAndWrapKeyMaterial) bool { 1086 return _this == other 1087 } 1088 1089 func (_this *KmsGenerateAndWrapKeyMaterial) EqualsGeneric(x interface{}) bool { 1090 other, ok := x.(*KmsGenerateAndWrapKeyMaterial) 1091 return ok && _this.Equals(other) 1092 } 1093 1094 func (*KmsGenerateAndWrapKeyMaterial) String() string { 1095 return "AwsKmsKeyring.KmsGenerateAndWrapKeyMaterial" 1096 } 1097 1098 func Type_KmsGenerateAndWrapKeyMaterial_() _dafny.TypeDescriptor { 1099 return type_KmsGenerateAndWrapKeyMaterial_{} 1100 } 1101 1102 type type_KmsGenerateAndWrapKeyMaterial_ struct { 1103 } 1104 1105 func (_this type_KmsGenerateAndWrapKeyMaterial_) Default() interface{} { 1106 return (*KmsGenerateAndWrapKeyMaterial)(nil) 1107 } 1108 1109 func (_this type_KmsGenerateAndWrapKeyMaterial_) String() string { 1110 return "AwsKmsKeyring.KmsGenerateAndWrapKeyMaterial" 1111 } 1112 func (_this *KmsGenerateAndWrapKeyMaterial) ParentTraits_() []*_dafny.TraitID { 1113 return [](*_dafny.TraitID){m_MaterialWrapping.Companion_GenerateAndWrapMaterial_.TraitID_, m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 1114 } 1115 1116 var _ m_MaterialWrapping.GenerateAndWrapMaterial = &KmsGenerateAndWrapKeyMaterial{} 1117 var _ m_Actions.ActionWithResult = &KmsGenerateAndWrapKeyMaterial{} 1118 var _ m_Actions.Action = &KmsGenerateAndWrapKeyMaterial{} 1119 var _ _dafny.TraitOffspring = &KmsGenerateAndWrapKeyMaterial{} 1120 1121 func (_this *KmsGenerateAndWrapKeyMaterial) Ctor__(client m_ComAmazonawsKmsTypes.IKMSClient, awsKmsKey _dafny.Sequence, grantTokens _dafny.Sequence) { 1122 { 1123 (_this)._client = client 1124 (_this)._awsKmsKey = awsKmsKey 1125 (_this)._grantTokens = grantTokens 1126 } 1127 } 1128 func (_this *KmsGenerateAndWrapKeyMaterial) Invoke(input interface{}) interface{} { 1129 { 1130 var input m_MaterialWrapping.GenerateAndWrapInput = input.(m_MaterialWrapping.GenerateAndWrapInput) 1131 _ = input 1132 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_GenerateAndWrapOutput_.Default(Companion_KmsWrapInfo_.Default())) 1133 _ = res 1134 var _0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 1135 _ = _0_suite 1136 _0_suite = (input).Dtor_algorithmSuite() 1137 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptyMap) 1138 _ = _1_valueOrError0 1139 _1_valueOrError0 = m_AwsKmsUtils.Companion_Default___.StringifyEncryptionContext((input).Dtor_encryptionContext()) 1140 if (_1_valueOrError0).IsFailure() { 1141 res = (_1_valueOrError0).PropagateFailure() 1142 return res 1143 } 1144 var _2_stringifiedEncCtx _dafny.Map 1145 _ = _2_stringifiedEncCtx 1146 _2_stringifiedEncCtx = (_1_valueOrError0).Extract().(_dafny.Map) 1147 var _3_generatorRequest m_ComAmazonawsKmsTypes.GenerateDataKeyRequest 1148 _ = _3_generatorRequest 1149 _3_generatorRequest = m_ComAmazonawsKmsTypes.Companion_GenerateDataKeyRequest_.Create_GenerateDataKeyRequest_((_this).AwsKmsKey(), m_Wrappers.Companion_Option_.Create_Some_(_2_stringifiedEncCtx), m_Wrappers.Companion_Option_.Create_Some_(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite)), m_Wrappers.Companion_Option_.Create_None_(), m_Wrappers.Companion_Option_.Create_Some_((_this).GrantTokens()), m_Wrappers.Companion_Option_.Create_None_(), m_Wrappers.Companion_Option_.Create_None_()) 1150 var _4_maybeGenerateResponse m_Wrappers.Result 1151 _ = _4_maybeGenerateResponse 1152 var _out0 m_Wrappers.Result 1153 _ = _out0 1154 _out0 = ((_this).Client()).GenerateDataKey(_3_generatorRequest) 1155 _4_maybeGenerateResponse = _out0 1156 var _5_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_ComAmazonawsKmsTypes.Companion_GenerateDataKeyResponse_.Default()) 1157 _ = _5_valueOrError1 1158 _5_valueOrError1 = (_4_maybeGenerateResponse).MapFailure(func(coer57 func(m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 1159 return func(arg58 interface{}) interface{} { 1160 return coer57(arg58.(m_ComAmazonawsKmsTypes.Error)) 1161 } 1162 }(func(_6_e m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error { 1163 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_ComAmazonawsKms_(_6_e) 1164 })) 1165 if (_5_valueOrError1).IsFailure() { 1166 res = (_5_valueOrError1).PropagateFailure() 1167 return res 1168 } 1169 var _7_generateResponse m_ComAmazonawsKmsTypes.GenerateDataKeyResponse 1170 _ = _7_generateResponse 1171 _7_generateResponse = (_5_valueOrError1).Extract().(m_ComAmazonawsKmsTypes.GenerateDataKeyResponse) 1172 var _8_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1173 _ = _8_valueOrError2 1174 _8_valueOrError2 = m_Wrappers.Companion_Default___.Need((((_7_generateResponse).Dtor_KeyId()).Is_Some()) && ((m_AwsArnParsing.Companion_Default___.ParseAwsKmsIdentifier(((_7_generateResponse).Dtor_KeyId()).Dtor_value().(_dafny.Sequence))).Is_Success()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from KMS GenerateDataKey:: Invalid Key Id"))) 1175 if (_8_valueOrError2).IsFailure() { 1176 res = (_8_valueOrError2).PropagateFailure() 1177 return res 1178 } 1179 var _9_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1180 _ = _9_valueOrError3 1181 _9_valueOrError3 = m_Wrappers.Companion_Default___.Need((((_7_generateResponse).Dtor_Plaintext()).Is_Some()) && ((_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite))).Cmp(_dafny.IntOfUint32((((_7_generateResponse).Dtor_Plaintext()).Dtor_value().(_dafny.Sequence)).Cardinality())) == 0), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from AWS KMS GenerateDataKey: Invalid data key"))) 1182 if (_9_valueOrError3).IsFailure() { 1183 res = (_9_valueOrError3).PropagateFailure() 1184 return res 1185 } 1186 var _10_valueOrError4 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1187 _ = _10_valueOrError4 1188 _10_valueOrError4 = m_Wrappers.Companion_Default___.Need((((_7_generateResponse).Dtor_CiphertextBlob()).Is_Some()) && (m_ComAmazonawsKmsTypes.Companion_Default___.IsValid__CiphertextType(((_7_generateResponse).Dtor_CiphertextBlob()).Dtor_value().(_dafny.Sequence))), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from AWS KMS GeneratedDataKey: Invalid ciphertext"))) 1189 if (_10_valueOrError4).IsFailure() { 1190 res = (_10_valueOrError4).PropagateFailure() 1191 return res 1192 } 1193 var _11_valueOrError5 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1194 _ = _11_valueOrError5 1195 _11_valueOrError5 = m_Wrappers.Companion_Default___.Need((true) && (((_7_generateResponse).Dtor_CiphertextForRecipient()).Is_None()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from AWS KMS GeneratedDataKey: Invalid CiphertextForRecipient"))) 1196 if (_11_valueOrError5).IsFailure() { 1197 res = (_11_valueOrError5).PropagateFailure() 1198 return res 1199 } 1200 var _12_output m_MaterialWrapping.GenerateAndWrapOutput 1201 _ = _12_output 1202 _12_output = m_MaterialWrapping.Companion_GenerateAndWrapOutput_.Create_GenerateAndWrapOutput_(((_7_generateResponse).Dtor_Plaintext()).Dtor_value().(_dafny.Sequence), ((_7_generateResponse).Dtor_CiphertextBlob()).Dtor_value().(_dafny.Sequence), Companion_KmsWrapInfo_.Create_KmsWrapInfo_(((_7_generateResponse).Dtor_KeyId()).Dtor_value().(_dafny.Sequence))) 1203 res = m_Wrappers.Companion_Result_.Create_Success_(_12_output) 1204 return res 1205 return res 1206 } 1207 } 1208 func (_this *KmsGenerateAndWrapKeyMaterial) Client() m_ComAmazonawsKmsTypes.IKMSClient { 1209 { 1210 return _this._client 1211 } 1212 } 1213 func (_this *KmsGenerateAndWrapKeyMaterial) AwsKmsKey() _dafny.Sequence { 1214 { 1215 return _this._awsKmsKey 1216 } 1217 } 1218 func (_this *KmsGenerateAndWrapKeyMaterial) GrantTokens() _dafny.Sequence { 1219 { 1220 return _this._grantTokens 1221 } 1222 } 1223 1224 // End of class KmsGenerateAndWrapKeyMaterial 1225 1226 // Definition of class KmsWrapKeyMaterial 1227 type KmsWrapKeyMaterial struct { 1228 _client m_ComAmazonawsKmsTypes.IKMSClient 1229 _awsKmsKey _dafny.Sequence 1230 _grantTokens _dafny.Sequence 1231 } 1232 1233 func New_KmsWrapKeyMaterial_() *KmsWrapKeyMaterial { 1234 _this := KmsWrapKeyMaterial{} 1235 1236 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 1237 _this._awsKmsKey = _dafny.EmptySeq.SetString() 1238 _this._grantTokens = _dafny.EmptySeq 1239 return &_this 1240 } 1241 1242 type CompanionStruct_KmsWrapKeyMaterial_ struct { 1243 } 1244 1245 var Companion_KmsWrapKeyMaterial_ = CompanionStruct_KmsWrapKeyMaterial_{} 1246 1247 func (_this *KmsWrapKeyMaterial) Equals(other *KmsWrapKeyMaterial) bool { 1248 return _this == other 1249 } 1250 1251 func (_this *KmsWrapKeyMaterial) EqualsGeneric(x interface{}) bool { 1252 other, ok := x.(*KmsWrapKeyMaterial) 1253 return ok && _this.Equals(other) 1254 } 1255 1256 func (*KmsWrapKeyMaterial) String() string { 1257 return "AwsKmsKeyring.KmsWrapKeyMaterial" 1258 } 1259 1260 func Type_KmsWrapKeyMaterial_() _dafny.TypeDescriptor { 1261 return type_KmsWrapKeyMaterial_{} 1262 } 1263 1264 type type_KmsWrapKeyMaterial_ struct { 1265 } 1266 1267 func (_this type_KmsWrapKeyMaterial_) Default() interface{} { 1268 return (*KmsWrapKeyMaterial)(nil) 1269 } 1270 1271 func (_this type_KmsWrapKeyMaterial_) String() string { 1272 return "AwsKmsKeyring.KmsWrapKeyMaterial" 1273 } 1274 func (_this *KmsWrapKeyMaterial) ParentTraits_() []*_dafny.TraitID { 1275 return [](*_dafny.TraitID){m_MaterialWrapping.Companion_WrapMaterial_.TraitID_, m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 1276 } 1277 1278 var _ m_MaterialWrapping.WrapMaterial = &KmsWrapKeyMaterial{} 1279 var _ m_Actions.ActionWithResult = &KmsWrapKeyMaterial{} 1280 var _ m_Actions.Action = &KmsWrapKeyMaterial{} 1281 var _ _dafny.TraitOffspring = &KmsWrapKeyMaterial{} 1282 1283 func (_this *KmsWrapKeyMaterial) Ctor__(client m_ComAmazonawsKmsTypes.IKMSClient, awsKmsKey _dafny.Sequence, grantTokens _dafny.Sequence) { 1284 { 1285 (_this)._client = client 1286 (_this)._awsKmsKey = awsKmsKey 1287 (_this)._grantTokens = grantTokens 1288 } 1289 } 1290 func (_this *KmsWrapKeyMaterial) Invoke(input interface{}) interface{} { 1291 { 1292 var input m_MaterialWrapping.WrapInput = input.(m_MaterialWrapping.WrapInput) 1293 _ = input 1294 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_MaterialWrapping.Companion_WrapOutput_.Default(Companion_KmsWrapInfo_.Default())) 1295 _ = res 1296 var _0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 1297 _ = _0_suite 1298 _0_suite = (input).Dtor_algorithmSuite() 1299 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptyMap) 1300 _ = _1_valueOrError0 1301 _1_valueOrError0 = m_AwsKmsUtils.Companion_Default___.StringifyEncryptionContext((input).Dtor_encryptionContext()) 1302 if (_1_valueOrError0).IsFailure() { 1303 res = (_1_valueOrError0).PropagateFailure() 1304 return res 1305 } 1306 var _2_stringifiedEncCtx _dafny.Map 1307 _ = _2_stringifiedEncCtx 1308 _2_stringifiedEncCtx = (_1_valueOrError0).Extract().(_dafny.Map) 1309 var _3_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1310 _ = _3_valueOrError1 1311 _3_valueOrError1 = m_Wrappers.Companion_Default___.Need(m_ComAmazonawsKmsTypes.Companion_Default___.IsValid__PlaintextType((input).Dtor_plaintextMaterial()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid Plaintext on KMS Encrypt"))) 1312 if (_3_valueOrError1).IsFailure() { 1313 res = (_3_valueOrError1).PropagateFailure() 1314 return res 1315 } 1316 var _4_encryptRequest m_ComAmazonawsKmsTypes.EncryptRequest 1317 _ = _4_encryptRequest 1318 _4_encryptRequest = m_ComAmazonawsKmsTypes.Companion_EncryptRequest_.Create_EncryptRequest_((_this).AwsKmsKey(), (input).Dtor_plaintextMaterial(), m_Wrappers.Companion_Option_.Create_Some_(_2_stringifiedEncCtx), m_Wrappers.Companion_Option_.Create_Some_((_this).GrantTokens()), m_Wrappers.Companion_Option_.Create_None_(), m_Wrappers.Companion_Option_.Create_None_()) 1319 var _5_maybeEncryptResponse m_Wrappers.Result 1320 _ = _5_maybeEncryptResponse 1321 var _out0 m_Wrappers.Result 1322 _ = _out0 1323 _out0 = ((_this).Client()).Encrypt(_4_encryptRequest) 1324 _5_maybeEncryptResponse = _out0 1325 var _6_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_ComAmazonawsKmsTypes.Companion_EncryptResponse_.Default()) 1326 _ = _6_valueOrError2 1327 _6_valueOrError2 = (_5_maybeEncryptResponse).MapFailure(func(coer58 func(m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 1328 return func(arg59 interface{}) interface{} { 1329 return coer58(arg59.(m_ComAmazonawsKmsTypes.Error)) 1330 } 1331 }(func(_7_e m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error { 1332 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_ComAmazonawsKms_(_7_e) 1333 })) 1334 if (_6_valueOrError2).IsFailure() { 1335 res = (_6_valueOrError2).PropagateFailure() 1336 return res 1337 } 1338 var _8_encryptResponse m_ComAmazonawsKmsTypes.EncryptResponse 1339 _ = _8_encryptResponse 1340 _8_encryptResponse = (_6_valueOrError2).Extract().(m_ComAmazonawsKmsTypes.EncryptResponse) 1341 var _9_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1342 _ = _9_valueOrError3 1343 _9_valueOrError3 = m_Wrappers.Companion_Default___.Need((((_8_encryptResponse).Dtor_KeyId()).Is_Some()) && ((m_AwsArnParsing.Companion_Default___.ParseAwsKmsIdentifier(((_8_encryptResponse).Dtor_KeyId()).Dtor_value().(_dafny.Sequence))).Is_Success()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from AWS KMS Encrypt:: Invalid Key Id"))) 1344 if (_9_valueOrError3).IsFailure() { 1345 res = (_9_valueOrError3).PropagateFailure() 1346 return res 1347 } 1348 var _10_valueOrError4 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 1349 _ = _10_valueOrError4 1350 _10_valueOrError4 = m_Wrappers.Companion_Default___.Need(((_8_encryptResponse).Dtor_CiphertextBlob()).Is_Some(), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid response from AWS KMS Encrypt: Invalid Ciphertext Blob"))) 1351 if (_10_valueOrError4).IsFailure() { 1352 res = (_10_valueOrError4).PropagateFailure() 1353 return res 1354 } 1355 var _11_output m_MaterialWrapping.WrapOutput 1356 _ = _11_output 1357 _11_output = m_MaterialWrapping.Companion_WrapOutput_.Create_WrapOutput_(((_8_encryptResponse).Dtor_CiphertextBlob()).Dtor_value().(_dafny.Sequence), Companion_KmsWrapInfo_.Create_KmsWrapInfo_(((_8_encryptResponse).Dtor_KeyId()).Dtor_value().(_dafny.Sequence))) 1358 res = m_Wrappers.Companion_Result_.Create_Success_(_11_output) 1359 return res 1360 return res 1361 } 1362 } 1363 func (_this *KmsWrapKeyMaterial) Client() m_ComAmazonawsKmsTypes.IKMSClient { 1364 { 1365 return _this._client 1366 } 1367 } 1368 func (_this *KmsWrapKeyMaterial) AwsKmsKey() _dafny.Sequence { 1369 { 1370 return _this._awsKmsKey 1371 } 1372 } 1373 func (_this *KmsWrapKeyMaterial) GrantTokens() _dafny.Sequence { 1374 { 1375 return _this._grantTokens 1376 } 1377 } 1378 1379 // End of class KmsWrapKeyMaterial