github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl@v0.2.0/AwsKmsMrkDiscoveryKeyring/AwsKmsMrkDiscoveryKeyring.go (about) 1 // Package AwsKmsMrkDiscoveryKeyring 2 // Dafny module AwsKmsMrkDiscoveryKeyring compiled into Go 3 4 package AwsKmsMrkDiscoveryKeyring 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_AwsKmsDiscoveryKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsDiscoveryKeyring" 19 m_AwsKmsKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsKeyring" 20 m_AwsKmsMrkAreUnique "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkAreUnique" 21 m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt" 22 m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils" 23 m_CanonicalEncryptionContext "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CanonicalEncryptionContext" 24 m_Constants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Constants" 25 m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable" 26 m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys" 27 m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations" 28 m_DiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DiscoveryMultiKeyring" 29 m_EdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EdkWrapping" 30 m_ErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/ErrorMessages" 31 m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys" 32 m_IntermediateKeyWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/IntermediateKeyWrapping" 33 m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations" 34 m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore" 35 m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages" 36 m_Keyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Keyring" 37 m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn" 38 m_MaterialWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MaterialWrapping" 39 m_Materials "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Materials" 40 m_MultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MultiKeyring" 41 m_StrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StrictMultiKeyring" 42 m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure" 43 m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives" 44 m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations" 45 m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes" 46 m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest" 47 m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF" 48 m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr" 49 m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random" 50 m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF" 51 m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC" 52 m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions" 53 m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64" 54 m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas" 55 m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts" 56 m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals" 57 m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear" 58 m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod" 59 m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO" 60 m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare" 61 m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions" 62 m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals" 63 m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt" 64 m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings" 65 m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm" 66 m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_" 67 m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals" 68 m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear" 69 m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul" 70 m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals" 71 m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear" 72 m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power" 73 m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations" 74 m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq" 75 m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort" 76 m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting" 77 m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary" 78 m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop" 79 m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence" 80 m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String" 81 m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt" 82 m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams" 83 m_UTF8 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UTF8" 84 m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings" 85 m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_" 86 m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm" 87 m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm" 88 m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers" 89 m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_" 90 _dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" 91 ) 92 93 var _ = os.Args 94 var _ _dafny.Dummy__ 95 var _ m__System.Dummy__ 96 var _ m_Wrappers.Dummy__ 97 var _ m_BoundedInts.Dummy__ 98 var _ m_StandardLibrary_UInt.Dummy__ 99 var _ m_StandardLibrary_Sequence.Dummy__ 100 var _ m_StandardLibrary_String.Dummy__ 101 var _ m_StandardLibrary.Dummy__ 102 var _ m_AwsCryptographyPrimitivesTypes.Dummy__ 103 var _ m_Random.Dummy__ 104 var _ m_Digest.Dummy__ 105 var _ m_WrappedHMAC.Dummy__ 106 var _ m_HKDF.Dummy__ 107 var _ m_WrappedHKDF.Dummy__ 108 var _ m_KdfCtr.Dummy__ 109 var _ m_AwsCryptographyPrimitivesOperations.Dummy__ 110 var _ m_AtomicPrimitives.Dummy__ 111 var _ m_ComAmazonawsDynamodbTypes.Dummy__ 112 var _ m_ComAmazonawsKmsTypes.Dummy__ 113 var _ m_Relations.Dummy__ 114 var _ m_Seq_MergeSort.Dummy__ 115 var _ m__Math.Dummy__ 116 var _ m_Seq.Dummy__ 117 var _ m__Unicode.Dummy__ 118 var _ m_Functions.Dummy__ 119 var _ m_Utf8EncodingForm.Dummy__ 120 var _ m_Utf16EncodingForm.Dummy__ 121 var _ m_UnicodeStrings.Dummy__ 122 var _ m_FileIO.Dummy__ 123 var _ m_GeneralInternals.Dummy__ 124 var _ m_MulInternalsNonlinear.Dummy__ 125 var _ m_MulInternals.Dummy__ 126 var _ m_Mul.Dummy__ 127 var _ m_ModInternalsNonlinear.Dummy__ 128 var _ m_DivInternalsNonlinear.Dummy__ 129 var _ m_ModInternals.Dummy__ 130 var _ m_DivInternals.Dummy__ 131 var _ m_DivMod.Dummy__ 132 var _ m_Power.Dummy__ 133 var _ m_Logarithm.Dummy__ 134 var _ m_StandardLibraryInterop.Dummy__ 135 var _ m_Streams.Dummy__ 136 var _ m_Sorting.Dummy__ 137 var _ m_HexStrings.Dummy__ 138 var _ m_GetOpt.Dummy__ 139 var _ m_FloatCompare.Dummy__ 140 var _ m_Base64.Dummy__ 141 var _ m_Base64Lemmas.Dummy__ 142 var _ m_Actions.Dummy__ 143 var _ m_AwsCryptographyKeyStoreTypes.Dummy__ 144 var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__ 145 var _ m_AwsArnParsing.Dummy__ 146 var _ m_AwsKmsMrkMatchForDecrypt.Dummy__ 147 var _ m_AwsKmsUtils.Dummy__ 148 var _ m_KeyStoreErrorMessages.Dummy__ 149 var _ m_KmsArn.Dummy__ 150 var _ m_Structure.Dummy__ 151 var _ m_KMSKeystoreOperations.Dummy__ 152 var _ m_DDBKeystoreOperations.Dummy__ 153 var _ m_CreateKeys.Dummy__ 154 var _ m_CreateKeyStoreTable.Dummy__ 155 var _ m_GetKeys.Dummy__ 156 var _ m_AwsCryptographyKeyStoreOperations.Dummy__ 157 var _ m_Com_Amazonaws_Kms.Dummy__ 158 var _ m_Com_Amazonaws_Dynamodb.Dummy__ 159 var _ m_KeyStore.Dummy__ 160 var _ m_AlgorithmSuites.Dummy__ 161 var _ m_Materials.Dummy__ 162 var _ m_Keyring.Dummy__ 163 var _ m_MultiKeyring.Dummy__ 164 var _ m_AwsKmsMrkAreUnique.Dummy__ 165 var _ m_Constants.Dummy__ 166 var _ m_MaterialWrapping.Dummy__ 167 var _ m_CanonicalEncryptionContext.Dummy__ 168 var _ m_IntermediateKeyWrapping.Dummy__ 169 var _ m_EdkWrapping.Dummy__ 170 var _ m_ErrorMessages.Dummy__ 171 var _ m_AwsKmsKeyring.Dummy__ 172 var _ m_StrictMultiKeyring.Dummy__ 173 var _ m_AwsKmsDiscoveryKeyring.Dummy__ 174 var _ m_DiscoveryMultiKeyring.Dummy__ 175 176 type Dummy__ struct{} 177 178 // Definition of class Default__ 179 type Default__ struct { 180 dummy byte 181 } 182 183 func New_Default___() *Default__ { 184 _this := Default__{} 185 186 return &_this 187 } 188 189 type CompanionStruct_Default___ struct { 190 } 191 192 var Companion_Default___ = CompanionStruct_Default___{} 193 194 func (_this *Default__) Equals(other *Default__) bool { 195 return _this == other 196 } 197 198 func (_this *Default__) EqualsGeneric(x interface{}) bool { 199 other, ok := x.(*Default__) 200 return ok && _this.Equals(other) 201 } 202 203 func (*Default__) String() string { 204 return "AwsKmsMrkDiscoveryKeyring.Default__" 205 } 206 func (_this *Default__) ParentTraits_() []*_dafny.TraitID { 207 return [](*_dafny.TraitID){} 208 } 209 210 var _ _dafny.TraitOffspring = &Default__{} 211 212 func (_static *CompanionStruct_Default___) ToStringForRegion(arn m_AwsArnParsing.AwsArn, region _dafny.Sequence) _dafny.Sequence { 213 if m_AwsArnParsing.Companion_Default___.IsMultiRegionAwsKmsArn(arn) { 214 return (arn).ToArnString(m_Wrappers.Companion_Option_.Create_Some_(region)) 215 } else { 216 return (arn).ToString() 217 } 218 } 219 func (_static *CompanionStruct_Default___) DiscoveryMatch(arn m_AwsArnParsing.AwsArn, discoveryFilter m_Wrappers.Option, region _dafny.Sequence) bool { 220 return (func() bool { 221 var _source0 m_Wrappers.Option = discoveryFilter 222 _ = _source0 223 { 224 if _source0.Is_Some() { 225 var _0_filter m_AwsCryptographyMaterialProvidersTypes.DiscoveryFilter = _source0.Get_().(m_Wrappers.Option_Some).Value.(m_AwsCryptographyMaterialProvidersTypes.DiscoveryFilter) 226 _ = _0_filter 227 return (_dafny.Companion_Sequence_.Equal((_0_filter).Dtor_partition(), (arn).Dtor_partition())) && (_dafny.Companion_Sequence_.Contains((_0_filter).Dtor_accountIds(), (arn).Dtor_account())) 228 } 229 } 230 { 231 return true 232 } 233 }()) && ((func() bool { 234 if !(m_AwsArnParsing.Companion_Default___.IsMultiRegionAwsKmsArn(arn)) { 235 return _dafny.Companion_Sequence_.Equal(region, (arn).Dtor_region()) 236 } 237 return true 238 })()) 239 } 240 241 // End of class Default__ 242 243 // Definition of class AwsKmsMrkDiscoveryKeyring 244 type AwsKmsMrkDiscoveryKeyring struct { 245 _client m_ComAmazonawsKmsTypes.IKMSClient 246 _region _dafny.Sequence 247 _discoveryFilter m_Wrappers.Option 248 _grantTokens _dafny.Sequence 249 } 250 251 func New_AwsKmsMrkDiscoveryKeyring_() *AwsKmsMrkDiscoveryKeyring { 252 _this := AwsKmsMrkDiscoveryKeyring{} 253 254 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 255 _this._region = _dafny.EmptySeq.SetString() 256 _this._discoveryFilter = m_Wrappers.Companion_Option_.Default() 257 _this._grantTokens = _dafny.EmptySeq 258 return &_this 259 } 260 261 type CompanionStruct_AwsKmsMrkDiscoveryKeyring_ struct { 262 } 263 264 var Companion_AwsKmsMrkDiscoveryKeyring_ = CompanionStruct_AwsKmsMrkDiscoveryKeyring_{} 265 266 func (_this *AwsKmsMrkDiscoveryKeyring) Equals(other *AwsKmsMrkDiscoveryKeyring) bool { 267 return _this == other 268 } 269 270 func (_this *AwsKmsMrkDiscoveryKeyring) EqualsGeneric(x interface{}) bool { 271 other, ok := x.(*AwsKmsMrkDiscoveryKeyring) 272 return ok && _this.Equals(other) 273 } 274 275 func (*AwsKmsMrkDiscoveryKeyring) String() string { 276 return "AwsKmsMrkDiscoveryKeyring.AwsKmsMrkDiscoveryKeyring" 277 } 278 279 func Type_AwsKmsMrkDiscoveryKeyring_() _dafny.TypeDescriptor { 280 return type_AwsKmsMrkDiscoveryKeyring_{} 281 } 282 283 type type_AwsKmsMrkDiscoveryKeyring_ struct { 284 } 285 286 func (_this type_AwsKmsMrkDiscoveryKeyring_) Default() interface{} { 287 return (*AwsKmsMrkDiscoveryKeyring)(nil) 288 } 289 290 func (_this type_AwsKmsMrkDiscoveryKeyring_) String() string { 291 return "AwsKmsMrkDiscoveryKeyring.AwsKmsMrkDiscoveryKeyring" 292 } 293 func (_this *AwsKmsMrkDiscoveryKeyring) ParentTraits_() []*_dafny.TraitID { 294 return [](*_dafny.TraitID){m_Keyring.Companion_VerifiableInterface_.TraitID_, m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.TraitID_} 295 } 296 297 var _ m_Keyring.VerifiableInterface = &AwsKmsMrkDiscoveryKeyring{} 298 var _ m_AwsCryptographyMaterialProvidersTypes.IKeyring = &AwsKmsMrkDiscoveryKeyring{} 299 var _ _dafny.TraitOffspring = &AwsKmsMrkDiscoveryKeyring{} 300 301 func (_this *AwsKmsMrkDiscoveryKeyring) OnDecrypt(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result { 302 var _out4 m_Wrappers.Result 303 _ = _out4 304 _out4 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnDecrypt(_this, input) 305 return _out4 306 } 307 func (_this *AwsKmsMrkDiscoveryKeyring) OnEncrypt(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result { 308 var _out4 m_Wrappers.Result 309 _ = _out4 310 _out4 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnEncrypt(_this, input) 311 return _out4 312 } 313 func (_this *AwsKmsMrkDiscoveryKeyring) Ctor__(client m_ComAmazonawsKmsTypes.IKMSClient, region _dafny.Sequence, discoveryFilter m_Wrappers.Option, grantTokens _dafny.Sequence) { 314 { 315 (_this)._client = client 316 (_this)._region = region 317 (_this)._discoveryFilter = discoveryFilter 318 (_this)._grantTokens = grantTokens 319 } 320 } 321 func (_this *AwsKmsMrkDiscoveryKeyring) OnEncrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result { 322 { 323 var output m_Wrappers.Result = m_Wrappers.Result{} 324 _ = output 325 output = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Encryption is not supported with a Discovery Keyring."))) 326 return output 327 return output 328 } 329 } 330 func (_this *AwsKmsMrkDiscoveryKeyring) OnDecrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result { 331 { 332 var output m_Wrappers.Result = m_Wrappers.Result{} 333 _ = output 334 var _0_materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 335 _ = _0_materials 336 _0_materials = (input).Dtor_materials() 337 var _1_encryptedDataKeys _dafny.Sequence 338 _ = _1_encryptedDataKeys 339 _1_encryptedDataKeys = (input).Dtor_encryptedDataKeys() 340 var _2_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo 341 _ = _2_suite 342 _2_suite = ((input).Dtor_materials()).Dtor_algorithmSuite() 343 var _3_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 344 _ = _3_valueOrError0 345 _3_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."))) 346 if (_3_valueOrError0).IsFailure() { 347 output = (_3_valueOrError0).PropagateFailure() 348 return output 349 } 350 var _4_edkFilterTransform *AwsKmsEncryptedDataKeyFilterTransform 351 _ = _4_edkFilterTransform 352 var _nw0 *AwsKmsEncryptedDataKeyFilterTransform = New_AwsKmsEncryptedDataKeyFilterTransform_() 353 _ = _nw0 354 _nw0.Ctor__((_this).Region(), (_this).DiscoveryFilter()) 355 _4_edkFilterTransform = _nw0 356 var _5_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq) 357 _ = _5_valueOrError1 358 var _out0 m_Wrappers.Result 359 _ = _out0 360 _out0 = m_Actions.Companion_Default___.DeterministicFlatMapWithResult(_4_edkFilterTransform, _1_encryptedDataKeys) 361 _5_valueOrError1 = _out0 362 if (_5_valueOrError1).IsFailure() { 363 output = (_5_valueOrError1).PropagateFailure() 364 return output 365 } 366 var _6_edksToAttempt _dafny.Sequence 367 _ = _6_edksToAttempt 368 _6_edksToAttempt = (_5_valueOrError1).Extract().(_dafny.Sequence) 369 if (_dafny.IntOfUint32((_6_edksToAttempt).Cardinality())).Sign() == 0 { 370 var _7_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq.SetString()) 371 _ = _7_valueOrError2 372 _7_valueOrError2 = m_ErrorMessages.Companion_Default___.IncorrectDataKeys((input).Dtor_encryptedDataKeys(), ((input).Dtor_materials()).Dtor_algorithmSuite(), _dafny.SeqOfString("")) 373 if (_7_valueOrError2).IsFailure() { 374 output = (_7_valueOrError2).PropagateFailure() 375 return output 376 } 377 var _8_errorMessage _dafny.Sequence 378 _ = _8_errorMessage 379 _8_errorMessage = (_7_valueOrError2).Extract().(_dafny.Sequence) 380 output = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_8_errorMessage)) 381 return output 382 } 383 var _9_decryptAction *AwsKmsEncryptedDataKeyDecryptor 384 _ = _9_decryptAction 385 var _nw1 *AwsKmsEncryptedDataKeyDecryptor = New_AwsKmsEncryptedDataKeyDecryptor_() 386 _ = _nw1 387 _nw1.Ctor__(_0_materials, (_this).Client(), (_this).Region(), (_this).GrantTokens()) 388 _9_decryptAction = _nw1 389 var _10_outcome m_Wrappers.Result 390 _ = _10_outcome 391 var _out1 m_Wrappers.Result 392 _ = _out1 393 _out1 = m_Actions.Companion_Default___.ReduceToSuccess(_9_decryptAction, _6_edksToAttempt) 394 _10_outcome = _out1 395 var _source0 m_Wrappers.Result = _10_outcome 396 _ = _source0 397 { 398 { 399 if _source0.Is_Success() { 400 var _11_mat m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials = _source0.Get_().(m_Wrappers.Result_Success).Value.(m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) 401 _ = _11_mat 402 output = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnDecryptOutput_.Create_OnDecryptOutput_(_11_mat)) 403 goto Lmatch0 404 } 405 } 406 { 407 var _12_errors _dafny.Sequence = _source0.Get_().(m_Wrappers.Result_Failure).Error.(_dafny.Sequence) 408 _ = _12_errors 409 output = m_Wrappers.Companion_Result_.Create_Failure_(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`."))) 410 } 411 goto Lmatch0 412 } 413 Lmatch0: 414 return output 415 return output 416 } 417 } 418 func (_this *AwsKmsMrkDiscoveryKeyring) Client() m_ComAmazonawsKmsTypes.IKMSClient { 419 { 420 return _this._client 421 } 422 } 423 func (_this *AwsKmsMrkDiscoveryKeyring) Region() _dafny.Sequence { 424 { 425 return _this._region 426 } 427 } 428 func (_this *AwsKmsMrkDiscoveryKeyring) DiscoveryFilter() m_Wrappers.Option { 429 { 430 return _this._discoveryFilter 431 } 432 } 433 func (_this *AwsKmsMrkDiscoveryKeyring) GrantTokens() _dafny.Sequence { 434 { 435 return _this._grantTokens 436 } 437 } 438 439 // End of class AwsKmsMrkDiscoveryKeyring 440 441 // Definition of class AwsKmsEncryptedDataKeyFilterTransform 442 type AwsKmsEncryptedDataKeyFilterTransform struct { 443 _region _dafny.Sequence 444 _discoveryFilter m_Wrappers.Option 445 } 446 447 func New_AwsKmsEncryptedDataKeyFilterTransform_() *AwsKmsEncryptedDataKeyFilterTransform { 448 _this := AwsKmsEncryptedDataKeyFilterTransform{} 449 450 _this._region = _dafny.EmptySeq.SetString() 451 _this._discoveryFilter = m_Wrappers.Companion_Option_.Default() 452 return &_this 453 } 454 455 type CompanionStruct_AwsKmsEncryptedDataKeyFilterTransform_ struct { 456 } 457 458 var Companion_AwsKmsEncryptedDataKeyFilterTransform_ = CompanionStruct_AwsKmsEncryptedDataKeyFilterTransform_{} 459 460 func (_this *AwsKmsEncryptedDataKeyFilterTransform) Equals(other *AwsKmsEncryptedDataKeyFilterTransform) bool { 461 return _this == other 462 } 463 464 func (_this *AwsKmsEncryptedDataKeyFilterTransform) EqualsGeneric(x interface{}) bool { 465 other, ok := x.(*AwsKmsEncryptedDataKeyFilterTransform) 466 return ok && _this.Equals(other) 467 } 468 469 func (*AwsKmsEncryptedDataKeyFilterTransform) String() string { 470 return "AwsKmsMrkDiscoveryKeyring.AwsKmsEncryptedDataKeyFilterTransform" 471 } 472 473 func Type_AwsKmsEncryptedDataKeyFilterTransform_() _dafny.TypeDescriptor { 474 return type_AwsKmsEncryptedDataKeyFilterTransform_{} 475 } 476 477 type type_AwsKmsEncryptedDataKeyFilterTransform_ struct { 478 } 479 480 func (_this type_AwsKmsEncryptedDataKeyFilterTransform_) Default() interface{} { 481 return (*AwsKmsEncryptedDataKeyFilterTransform)(nil) 482 } 483 484 func (_this type_AwsKmsEncryptedDataKeyFilterTransform_) String() string { 485 return "AwsKmsMrkDiscoveryKeyring.AwsKmsEncryptedDataKeyFilterTransform" 486 } 487 func (_this *AwsKmsEncryptedDataKeyFilterTransform) ParentTraits_() []*_dafny.TraitID { 488 return [](*_dafny.TraitID){m_Actions.Companion_DeterministicActionWithResult_.TraitID_, m_Actions.Companion_DeterministicAction_.TraitID_} 489 } 490 491 var _ m_Actions.DeterministicActionWithResult = &AwsKmsEncryptedDataKeyFilterTransform{} 492 var _ m_Actions.DeterministicAction = &AwsKmsEncryptedDataKeyFilterTransform{} 493 var _ _dafny.TraitOffspring = &AwsKmsEncryptedDataKeyFilterTransform{} 494 495 func (_this *AwsKmsEncryptedDataKeyFilterTransform) Ctor__(region _dafny.Sequence, discoveryFilter m_Wrappers.Option) { 496 { 497 (_this)._region = region 498 (_this)._discoveryFilter = discoveryFilter 499 } 500 } 501 func (_this *AwsKmsEncryptedDataKeyFilterTransform) Invoke(edk interface{}) interface{} { 502 { 503 var edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey = edk.(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey) 504 _ = edk 505 var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq) 506 _ = res 507 if !_dafny.Companion_Sequence_.Equal((edk).Dtor_keyProviderId(), m_Constants.Companion_Default___.PROVIDER__ID()) { 508 res = m_Wrappers.Companion_Result_.Create_Success_(_dafny.SeqOf()) 509 return res 510 } 511 var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 512 _ = _0_valueOrError0 513 _0_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_UTF8.Companion_Default___.ValidUTF8Seq((edk).Dtor_keyProviderInfo()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Invalid AWS KMS encoding, provider info is not UTF8."))) 514 if (_0_valueOrError0).IsFailure() { 515 res = (_0_valueOrError0).PropagateFailure() 516 return res 517 } 518 var _1_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq.SetString()) 519 _ = _1_valueOrError1 520 _1_valueOrError1 = (m_UTF8.Decode((edk).Dtor_keyProviderInfo())).MapFailure(func(coer67 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 521 return func(arg68 interface{}) interface{} { 522 return coer67(arg68.(_dafny.Sequence)) 523 } 524 }(func(_2_e _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error { 525 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_2_e) 526 })) 527 if (_1_valueOrError1).IsFailure() { 528 res = (_1_valueOrError1).PropagateFailure() 529 return res 530 } 531 var _3_keyId _dafny.Sequence 532 _ = _3_keyId 533 _3_keyId = (_1_valueOrError1).Extract().(_dafny.Sequence) 534 var _4_valueOrError2 m_Wrappers.Result = m_Wrappers.Result{} 535 _ = _4_valueOrError2 536 _4_valueOrError2 = (m_AwsArnParsing.Companion_Default___.ParseAwsKmsArn(_3_keyId)).MapFailure(func(coer68 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} { 537 return func(arg69 interface{}) interface{} { 538 return coer68(arg69.(_dafny.Sequence)) 539 } 540 }(func(_5_e _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error { 541 return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_5_e) 542 })) 543 if (_4_valueOrError2).IsFailure() { 544 res = (_4_valueOrError2).PropagateFailure() 545 return res 546 } 547 var _6_arn m_AwsArnParsing.AwsArn 548 _ = _6_arn 549 _6_arn = (_4_valueOrError2).Extract().(m_AwsArnParsing.AwsArn) 550 var _7_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default() 551 _ = _7_valueOrError3 552 _7_valueOrError3 = m_Wrappers.Companion_Default___.Need(_dafny.Companion_Sequence_.Equal(((_6_arn).Dtor_resource()).Dtor_resourceType(), _dafny.SeqOfString("key")), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Only AWS KMS Keys supported"))) 553 if (_7_valueOrError3).IsFailure() { 554 res = (_7_valueOrError3).PropagateFailure() 555 return res 556 } 557 if !(Companion_Default___.DiscoveryMatch(_6_arn, (_this).DiscoveryFilter(), (_this).Region())) { 558 res = m_Wrappers.Companion_Result_.Create_Success_(_dafny.SeqOf()) 559 return res 560 } 561 res = m_Wrappers.Companion_Result_.Create_Success_(_dafny.SeqOf(m_Constants.Companion_AwsKmsEdkHelper_.Create_AwsKmsEdkHelper_(edk, _6_arn))) 562 return res 563 return res 564 } 565 } 566 func (_this *AwsKmsEncryptedDataKeyFilterTransform) Region() _dafny.Sequence { 567 { 568 return _this._region 569 } 570 } 571 func (_this *AwsKmsEncryptedDataKeyFilterTransform) DiscoveryFilter() m_Wrappers.Option { 572 { 573 return _this._discoveryFilter 574 } 575 } 576 577 // End of class AwsKmsEncryptedDataKeyFilterTransform 578 579 // Definition of class AwsKmsEncryptedDataKeyDecryptor 580 type AwsKmsEncryptedDataKeyDecryptor struct { 581 _materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials 582 _client m_ComAmazonawsKmsTypes.IKMSClient 583 _region _dafny.Sequence 584 _grantTokens _dafny.Sequence 585 } 586 587 func New_AwsKmsEncryptedDataKeyDecryptor_() *AwsKmsEncryptedDataKeyDecryptor { 588 _this := AwsKmsEncryptedDataKeyDecryptor{} 589 590 _this._materials = m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials{} 591 _this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil) 592 _this._region = _dafny.EmptySeq.SetString() 593 _this._grantTokens = _dafny.EmptySeq 594 return &_this 595 } 596 597 type CompanionStruct_AwsKmsEncryptedDataKeyDecryptor_ struct { 598 } 599 600 var Companion_AwsKmsEncryptedDataKeyDecryptor_ = CompanionStruct_AwsKmsEncryptedDataKeyDecryptor_{} 601 602 func (_this *AwsKmsEncryptedDataKeyDecryptor) Equals(other *AwsKmsEncryptedDataKeyDecryptor) bool { 603 return _this == other 604 } 605 606 func (_this *AwsKmsEncryptedDataKeyDecryptor) EqualsGeneric(x interface{}) bool { 607 other, ok := x.(*AwsKmsEncryptedDataKeyDecryptor) 608 return ok && _this.Equals(other) 609 } 610 611 func (*AwsKmsEncryptedDataKeyDecryptor) String() string { 612 return "AwsKmsMrkDiscoveryKeyring.AwsKmsEncryptedDataKeyDecryptor" 613 } 614 615 func Type_AwsKmsEncryptedDataKeyDecryptor_() _dafny.TypeDescriptor { 616 return type_AwsKmsEncryptedDataKeyDecryptor_{} 617 } 618 619 type type_AwsKmsEncryptedDataKeyDecryptor_ struct { 620 } 621 622 func (_this type_AwsKmsEncryptedDataKeyDecryptor_) Default() interface{} { 623 return (*AwsKmsEncryptedDataKeyDecryptor)(nil) 624 } 625 626 func (_this type_AwsKmsEncryptedDataKeyDecryptor_) String() string { 627 return "AwsKmsMrkDiscoveryKeyring.AwsKmsEncryptedDataKeyDecryptor" 628 } 629 func (_this *AwsKmsEncryptedDataKeyDecryptor) ParentTraits_() []*_dafny.TraitID { 630 return [](*_dafny.TraitID){m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_} 631 } 632 633 var _ m_Actions.ActionWithResult = &AwsKmsEncryptedDataKeyDecryptor{} 634 var _ m_Actions.Action = &AwsKmsEncryptedDataKeyDecryptor{} 635 var _ _dafny.TraitOffspring = &AwsKmsEncryptedDataKeyDecryptor{} 636 637 func (_this *AwsKmsEncryptedDataKeyDecryptor) Ctor__(materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, client m_ComAmazonawsKmsTypes.IKMSClient, region _dafny.Sequence, grantTokens _dafny.Sequence) { 638 { 639 (_this)._materials = materials 640 (_this)._client = client 641 (_this)._region = region 642 (_this)._grantTokens = grantTokens 643 } 644 } 645 func (_this *AwsKmsEncryptedDataKeyDecryptor) Invoke(helper interface{}) interface{} { 646 { 647 var helper m_Constants.AwsKmsEdkHelper = helper.(m_Constants.AwsKmsEdkHelper) 648 _ = helper 649 var res m_Wrappers.Result = m_Wrappers.Result{} 650 _ = res 651 var _0_awsKmsKey _dafny.Sequence 652 _ = _0_awsKmsKey 653 _0_awsKmsKey = Companion_Default___.ToStringForRegion((helper).Dtor_arn(), (_this).Region()) 654 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 655 _ = _1_valueOrError0 656 _1_valueOrError0 = m_AwsKmsUtils.Companion_Default___.ValidateKmsKeyId(_0_awsKmsKey) 657 if (_1_valueOrError0).IsFailure() { 658 res = (_1_valueOrError0).PropagateFailure() 659 return res 660 } 661 var _2___v0 _dafny.Tuple 662 _ = _2___v0 663 _2___v0 = (_1_valueOrError0).Extract().(_dafny.Tuple) 664 var _3_kmsUnwrap *m_AwsKmsKeyring.KmsUnwrapKeyMaterial 665 _ = _3_kmsUnwrap 666 var _nw0 *m_AwsKmsKeyring.KmsUnwrapKeyMaterial = m_AwsKmsKeyring.New_KmsUnwrapKeyMaterial_() 667 _ = _nw0 668 _nw0.Ctor__((_this).Client(), _0_awsKmsKey, (_this).GrantTokens()) 669 _3_kmsUnwrap = _nw0 670 var _4_unwrapOutputRes m_Wrappers.Result 671 _ = _4_unwrapOutputRes 672 var _out0 m_Wrappers.Result 673 _ = _out0 674 _out0 = m_EdkWrapping.Companion_Default___.UnwrapEdkMaterial(((helper).Dtor_edk()).Dtor_ciphertext(), (_this).Materials(), _3_kmsUnwrap) 675 _4_unwrapOutputRes = _out0 676 var _5_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_EdkWrapping.Companion_UnwrapEdkMaterialOutput_.Default(m_AwsKmsKeyring.Companion_KmsUnwrapInfo_.Default())) 677 _ = _5_valueOrError1 678 _5_valueOrError1 = _4_unwrapOutputRes 679 if (_5_valueOrError1).IsFailure() { 680 res = (_5_valueOrError1).PropagateFailure() 681 return res 682 } 683 var _6_unwrapOutput m_EdkWrapping.UnwrapEdkMaterialOutput 684 _ = _6_unwrapOutput 685 _6_unwrapOutput = (_5_valueOrError1).Extract().(m_EdkWrapping.UnwrapEdkMaterialOutput) 686 res = m_Materials.Companion_Default___.DecryptionMaterialsAddDataKey((_this).Materials(), (_6_unwrapOutput).Dtor_plaintextDataKey(), (_6_unwrapOutput).Dtor_symmetricSigningKey()) 687 return res 688 } 689 } 690 func (_this *AwsKmsEncryptedDataKeyDecryptor) Materials() m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials { 691 { 692 return _this._materials 693 } 694 } 695 func (_this *AwsKmsEncryptedDataKeyDecryptor) Client() m_ComAmazonawsKmsTypes.IKMSClient { 696 { 697 return _this._client 698 } 699 } 700 func (_this *AwsKmsEncryptedDataKeyDecryptor) Region() _dafny.Sequence { 701 { 702 return _this._region 703 } 704 } 705 func (_this *AwsKmsEncryptedDataKeyDecryptor) GrantTokens() _dafny.Sequence { 706 { 707 return _this._grantTokens 708 } 709 } 710 711 // End of class AwsKmsEncryptedDataKeyDecryptor