github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl@v0.2.0/LocalCMC/LocalCMC.go (about) 1 // Package LocalCMC 2 // Dafny module LocalCMC compiled into Go 3 4 package LocalCMC 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_AwsKmsMrkDiscoveryKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkDiscoveryKeyring" 22 m_AwsKmsMrkKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkKeyring" 23 m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt" 24 m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils" 25 m_CanonicalEncryptionContext "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CanonicalEncryptionContext" 26 m_Constants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Constants" 27 m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable" 28 m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys" 29 m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations" 30 m_DiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DiscoveryMultiKeyring" 31 m_EdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EdkWrapping" 32 m_ErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/ErrorMessages" 33 m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys" 34 m_IntermediateKeyWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/IntermediateKeyWrapping" 35 m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations" 36 m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore" 37 m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages" 38 m_Keyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Keyring" 39 m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn" 40 m_MaterialWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MaterialWrapping" 41 m_Materials "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Materials" 42 m_MrkAwareDiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MrkAwareDiscoveryMultiKeyring" 43 m_MrkAwareStrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MrkAwareStrictMultiKeyring" 44 m_MultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MultiKeyring" 45 m_StrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StrictMultiKeyring" 46 m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure" 47 m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives" 48 m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations" 49 m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes" 50 m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest" 51 m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF" 52 m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr" 53 m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random" 54 m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF" 55 m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC" 56 m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions" 57 m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64" 58 m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas" 59 m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts" 60 m_DafnyLibraries "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DafnyLibraries" 61 m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals" 62 m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear" 63 m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod" 64 m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO" 65 m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare" 66 m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions" 67 m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals" 68 m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt" 69 m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings" 70 m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm" 71 m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_" 72 m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals" 73 m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear" 74 m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul" 75 m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals" 76 m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear" 77 m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power" 78 m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations" 79 m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq" 80 m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort" 81 m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting" 82 m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary" 83 m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop" 84 m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence" 85 m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String" 86 m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt" 87 m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams" 88 m__Time "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Time_" 89 m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings" 90 m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_" 91 m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm" 92 m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm" 93 m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers" 94 m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_" 95 _dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" 96 ) 97 98 var _ = os.Args 99 var _ _dafny.Dummy__ 100 var _ m__System.Dummy__ 101 var _ m_Wrappers.Dummy__ 102 var _ m_BoundedInts.Dummy__ 103 var _ m_StandardLibrary_UInt.Dummy__ 104 var _ m_StandardLibrary_Sequence.Dummy__ 105 var _ m_StandardLibrary_String.Dummy__ 106 var _ m_StandardLibrary.Dummy__ 107 var _ m_AwsCryptographyPrimitivesTypes.Dummy__ 108 var _ m_Random.Dummy__ 109 var _ m_Digest.Dummy__ 110 var _ m_WrappedHMAC.Dummy__ 111 var _ m_HKDF.Dummy__ 112 var _ m_WrappedHKDF.Dummy__ 113 var _ m_KdfCtr.Dummy__ 114 var _ m_AwsCryptographyPrimitivesOperations.Dummy__ 115 var _ m_AtomicPrimitives.Dummy__ 116 var _ m_ComAmazonawsDynamodbTypes.Dummy__ 117 var _ m_ComAmazonawsKmsTypes.Dummy__ 118 var _ m_Relations.Dummy__ 119 var _ m_Seq_MergeSort.Dummy__ 120 var _ m__Math.Dummy__ 121 var _ m_Seq.Dummy__ 122 var _ m__Unicode.Dummy__ 123 var _ m_Functions.Dummy__ 124 var _ m_Utf8EncodingForm.Dummy__ 125 var _ m_Utf16EncodingForm.Dummy__ 126 var _ m_UnicodeStrings.Dummy__ 127 var _ m_FileIO.Dummy__ 128 var _ m_GeneralInternals.Dummy__ 129 var _ m_MulInternalsNonlinear.Dummy__ 130 var _ m_MulInternals.Dummy__ 131 var _ m_Mul.Dummy__ 132 var _ m_ModInternalsNonlinear.Dummy__ 133 var _ m_DivInternalsNonlinear.Dummy__ 134 var _ m_ModInternals.Dummy__ 135 var _ m_DivInternals.Dummy__ 136 var _ m_DivMod.Dummy__ 137 var _ m_Power.Dummy__ 138 var _ m_Logarithm.Dummy__ 139 var _ m_StandardLibraryInterop.Dummy__ 140 var _ m_Streams.Dummy__ 141 var _ m_Sorting.Dummy__ 142 var _ m_HexStrings.Dummy__ 143 var _ m_GetOpt.Dummy__ 144 var _ m_FloatCompare.Dummy__ 145 var _ m_Base64.Dummy__ 146 var _ m_Base64Lemmas.Dummy__ 147 var _ m_Actions.Dummy__ 148 var _ m_AwsCryptographyKeyStoreTypes.Dummy__ 149 var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__ 150 var _ m_AwsArnParsing.Dummy__ 151 var _ m_AwsKmsMrkMatchForDecrypt.Dummy__ 152 var _ m_AwsKmsUtils.Dummy__ 153 var _ m_KeyStoreErrorMessages.Dummy__ 154 var _ m_KmsArn.Dummy__ 155 var _ m_Structure.Dummy__ 156 var _ m_KMSKeystoreOperations.Dummy__ 157 var _ m_DDBKeystoreOperations.Dummy__ 158 var _ m_CreateKeys.Dummy__ 159 var _ m_CreateKeyStoreTable.Dummy__ 160 var _ m_GetKeys.Dummy__ 161 var _ m_AwsCryptographyKeyStoreOperations.Dummy__ 162 var _ m_Com_Amazonaws_Kms.Dummy__ 163 var _ m_Com_Amazonaws_Dynamodb.Dummy__ 164 var _ m_KeyStore.Dummy__ 165 var _ m_AlgorithmSuites.Dummy__ 166 var _ m_Materials.Dummy__ 167 var _ m_Keyring.Dummy__ 168 var _ m_MultiKeyring.Dummy__ 169 var _ m_AwsKmsMrkAreUnique.Dummy__ 170 var _ m_Constants.Dummy__ 171 var _ m_MaterialWrapping.Dummy__ 172 var _ m_CanonicalEncryptionContext.Dummy__ 173 var _ m_IntermediateKeyWrapping.Dummy__ 174 var _ m_EdkWrapping.Dummy__ 175 var _ m_ErrorMessages.Dummy__ 176 var _ m_AwsKmsKeyring.Dummy__ 177 var _ m_StrictMultiKeyring.Dummy__ 178 var _ m_AwsKmsDiscoveryKeyring.Dummy__ 179 var _ m_DiscoveryMultiKeyring.Dummy__ 180 var _ m_AwsKmsMrkDiscoveryKeyring.Dummy__ 181 var _ m_MrkAwareDiscoveryMultiKeyring.Dummy__ 182 var _ m_AwsKmsMrkKeyring.Dummy__ 183 var _ m_MrkAwareStrictMultiKeyring.Dummy__ 184 185 type Dummy__ struct{} 186 187 // Definition of class Default__ 188 type Default__ struct { 189 dummy byte 190 } 191 192 func New_Default___() *Default__ { 193 _this := Default__{} 194 195 return &_this 196 } 197 198 type CompanionStruct_Default___ struct { 199 } 200 201 var Companion_Default___ = CompanionStruct_Default___{} 202 203 func (_this *Default__) Equals(other *Default__) bool { 204 return _this == other 205 } 206 207 func (_this *Default__) EqualsGeneric(x interface{}) bool { 208 other, ok := x.(*Default__) 209 return ok && _this.Equals(other) 210 } 211 212 func (*Default__) String() string { 213 return "LocalCMC.Default__" 214 } 215 func (_this *Default__) ParentTraits_() []*_dafny.TraitID { 216 return [](*_dafny.TraitID){} 217 } 218 219 var _ _dafny.TraitOffspring = &Default__{} 220 221 func (_static *CompanionStruct_Default___) RemoveValue(k0 interface{}, m _dafny.Map) { 222 var _0_m_k _dafny.Map 223 _ = _0_m_k 224 _0_m_k = (m).Subtract(_dafny.SetOf(k0)) 225 } 226 func (_static *CompanionStruct_Default___) NULL() Ref { 227 return Companion_Ref_.Create_Null_() 228 } 229 func (_static *CompanionStruct_Default___) INT32__MAX__VALUE() int32 { 230 return int32(2040109465) 231 } 232 func (_static *CompanionStruct_Default___) INT64__MAX__VALUE() int64 { 233 return int64(8762203435012037017) 234 } 235 236 // End of class Default__ 237 238 // Definition of datatype Ref 239 type Ref struct { 240 Data_Ref_ 241 } 242 243 func (_this Ref) Get_() Data_Ref_ { 244 return _this.Data_Ref_ 245 } 246 247 type Data_Ref_ interface { 248 isRef() 249 } 250 251 type CompanionStruct_Ref_ struct { 252 } 253 254 var Companion_Ref_ = CompanionStruct_Ref_{} 255 256 type Ref_Ptr struct { 257 Deref interface{} 258 } 259 260 func (Ref_Ptr) isRef() {} 261 262 func (CompanionStruct_Ref_) Create_Ptr_(Deref interface{}) Ref { 263 return Ref{Ref_Ptr{Deref}} 264 } 265 266 func (_this Ref) Is_Ptr() bool { 267 _, ok := _this.Get_().(Ref_Ptr) 268 return ok 269 } 270 271 type Ref_Null struct { 272 } 273 274 func (Ref_Null) isRef() {} 275 276 func (CompanionStruct_Ref_) Create_Null_() Ref { 277 return Ref{Ref_Null{}} 278 } 279 280 func (_this Ref) Is_Null() bool { 281 _, ok := _this.Get_().(Ref_Null) 282 return ok 283 } 284 285 func (CompanionStruct_Ref_) Default() Ref { 286 return Companion_Ref_.Create_Null_() 287 } 288 289 func (_this Ref) Dtor_deref() interface{} { 290 return _this.Get_().(Ref_Ptr).Deref 291 } 292 293 func (_this Ref) String() string { 294 switch data := _this.Get_().(type) { 295 case nil: 296 return "null" 297 case Ref_Ptr: 298 { 299 return "LocalCMC.Ref.Ptr" + "(" + _dafny.String(data.Deref) + ")" 300 } 301 case Ref_Null: 302 { 303 return "LocalCMC.Ref.Null" 304 } 305 default: 306 { 307 return "<unexpected>" 308 } 309 } 310 } 311 312 func (_this Ref) Equals(other Ref) bool { 313 switch data1 := _this.Get_().(type) { 314 case Ref_Ptr: 315 { 316 data2, ok := other.Get_().(Ref_Ptr) 317 return ok && _dafny.AreEqual(data1.Deref, data2.Deref) 318 } 319 case Ref_Null: 320 { 321 _, ok := other.Get_().(Ref_Null) 322 return ok 323 } 324 default: 325 { 326 return false // unexpected 327 } 328 } 329 } 330 331 func (_this Ref) EqualsGeneric(other interface{}) bool { 332 typed, ok := other.(Ref) 333 return ok && _this.Equals(typed) 334 } 335 336 func Type_Ref_() _dafny.TypeDescriptor { 337 return type_Ref_{} 338 } 339 340 type type_Ref_ struct { 341 } 342 343 func (_this type_Ref_) Default() interface{} { 344 return Companion_Ref_.Default() 345 } 346 347 func (_this type_Ref_) String() string { 348 return "LocalCMC.Ref" 349 } 350 func (_this Ref) ParentTraits_() []*_dafny.TraitID { 351 return [](*_dafny.TraitID){} 352 } 353 354 var _ _dafny.TraitOffspring = Ref{} 355 356 // End of datatype Ref 357 358 // Definition of class CacheEntry 359 type CacheEntry struct { 360 Prev Ref 361 Next Ref 362 MessagesUsed int32 363 BytesUsed int32 364 _identifier _dafny.Sequence 365 _materials m_AwsCryptographyMaterialProvidersTypes.Materials 366 _creationTime int64 367 _expiryTime int64 368 } 369 370 func New_CacheEntry_() *CacheEntry { 371 _this := CacheEntry{} 372 373 _this.Prev = Companion_Ref_.Default() 374 _this.Next = Companion_Ref_.Default() 375 _this.MessagesUsed = int32(0) 376 _this.BytesUsed = int32(0) 377 _this._identifier = _dafny.EmptySeq 378 _this._materials = m_AwsCryptographyMaterialProvidersTypes.Materials{} 379 _this._creationTime = int64(0) 380 _this._expiryTime = int64(0) 381 return &_this 382 } 383 384 type CompanionStruct_CacheEntry_ struct { 385 } 386 387 var Companion_CacheEntry_ = CompanionStruct_CacheEntry_{} 388 389 func (_this *CacheEntry) Equals(other *CacheEntry) bool { 390 return _this == other 391 } 392 393 func (_this *CacheEntry) EqualsGeneric(x interface{}) bool { 394 other, ok := x.(*CacheEntry) 395 return ok && _this.Equals(other) 396 } 397 398 func (*CacheEntry) String() string { 399 return "LocalCMC.CacheEntry" 400 } 401 402 func Type_CacheEntry_() _dafny.TypeDescriptor { 403 return type_CacheEntry_{} 404 } 405 406 type type_CacheEntry_ struct { 407 } 408 409 func (_this type_CacheEntry_) Default() interface{} { 410 return (*CacheEntry)(nil) 411 } 412 413 func (_this type_CacheEntry_) String() string { 414 return "LocalCMC.CacheEntry" 415 } 416 func (_this *CacheEntry) ParentTraits_() []*_dafny.TraitID { 417 return [](*_dafny.TraitID){} 418 } 419 420 var _ _dafny.TraitOffspring = &CacheEntry{} 421 422 func (_this *CacheEntry) Ctor__(materials_k m_AwsCryptographyMaterialProvidersTypes.Materials, identifier_k _dafny.Sequence, creationTime_k int64, expiryTime_k int64, messagesUsed_k int32, bytesUsed_k int32) { 423 { 424 (_this)._materials = materials_k 425 (_this)._identifier = identifier_k 426 (_this)._creationTime = creationTime_k 427 (_this)._expiryTime = expiryTime_k 428 (_this).MessagesUsed = messagesUsed_k 429 (_this).BytesUsed = bytesUsed_k 430 (_this).Prev = Companion_Default___.NULL() 431 (_this).Next = Companion_Default___.NULL() 432 } 433 } 434 func (_this *CacheEntry) Identifier() _dafny.Sequence { 435 { 436 return _this._identifier 437 } 438 } 439 func (_this *CacheEntry) Materials() m_AwsCryptographyMaterialProvidersTypes.Materials { 440 { 441 return _this._materials 442 } 443 } 444 func (_this *CacheEntry) CreationTime() int64 { 445 { 446 return _this._creationTime 447 } 448 } 449 func (_this *CacheEntry) ExpiryTime() int64 { 450 { 451 return _this._expiryTime 452 } 453 } 454 455 // End of class CacheEntry 456 457 // Definition of class DoublyLinkedCacheEntryList 458 type DoublyLinkedCacheEntryList struct { 459 Head Ref 460 Tail Ref 461 } 462 463 func New_DoublyLinkedCacheEntryList_() *DoublyLinkedCacheEntryList { 464 _this := DoublyLinkedCacheEntryList{} 465 466 _this.Head = Companion_Ref_.Default() 467 _this.Tail = Companion_Ref_.Default() 468 return &_this 469 } 470 471 type CompanionStruct_DoublyLinkedCacheEntryList_ struct { 472 } 473 474 var Companion_DoublyLinkedCacheEntryList_ = CompanionStruct_DoublyLinkedCacheEntryList_{} 475 476 func (_this *DoublyLinkedCacheEntryList) Equals(other *DoublyLinkedCacheEntryList) bool { 477 return _this == other 478 } 479 480 func (_this *DoublyLinkedCacheEntryList) EqualsGeneric(x interface{}) bool { 481 other, ok := x.(*DoublyLinkedCacheEntryList) 482 return ok && _this.Equals(other) 483 } 484 485 func (*DoublyLinkedCacheEntryList) String() string { 486 return "LocalCMC.DoublyLinkedCacheEntryList" 487 } 488 489 func Type_DoublyLinkedCacheEntryList_() _dafny.TypeDescriptor { 490 return type_DoublyLinkedCacheEntryList_{} 491 } 492 493 type type_DoublyLinkedCacheEntryList_ struct { 494 } 495 496 func (_this type_DoublyLinkedCacheEntryList_) Default() interface{} { 497 return (*DoublyLinkedCacheEntryList)(nil) 498 } 499 500 func (_this type_DoublyLinkedCacheEntryList_) String() string { 501 return "LocalCMC.DoublyLinkedCacheEntryList" 502 } 503 func (_this *DoublyLinkedCacheEntryList) ParentTraits_() []*_dafny.TraitID { 504 return [](*_dafny.TraitID){} 505 } 506 507 var _ _dafny.TraitOffspring = &DoublyLinkedCacheEntryList{} 508 509 func (_this *DoublyLinkedCacheEntryList) Ctor__() { 510 { 511 (_this).Head = Companion_Ref_.Create_Null_() 512 (_this).Tail = Companion_Ref_.Create_Null_() 513 } 514 } 515 func (_this *DoublyLinkedCacheEntryList) PushCell(toPush *CacheEntry) { 516 { 517 var _0_cRef Ref 518 _ = _0_cRef 519 _0_cRef = Companion_Ref_.Create_Ptr_(toPush) 520 if (_this.Head).Is_Ptr() { 521 var _obj0 *CacheEntry = (_this.Head).Dtor_deref().(*CacheEntry) 522 _ = _obj0 523 _obj0.Prev = _0_cRef 524 (toPush).Next = _this.Head 525 (_this).Head = _0_cRef 526 } else { 527 (_this).Head = _0_cRef 528 (_this).Tail = _this.Head 529 } 530 } 531 } 532 func (_this *DoublyLinkedCacheEntryList) MoveToFront(c *CacheEntry) { 533 { 534 if ((_this.Head).Dtor_deref().(*CacheEntry)) != (c) /* dircomp */ { 535 var _0_toPush Ref 536 _ = _0_toPush 537 _0_toPush = Companion_Ref_.Create_Ptr_(c) 538 (_this).Remove(c) 539 if (_this.Head).Is_Ptr() { 540 var _obj0 *CacheEntry = (_this.Head).Dtor_deref().(*CacheEntry) 541 _ = _obj0 542 _obj0.Prev = _0_toPush 543 var _obj1 *CacheEntry = (_0_toPush).Dtor_deref().(*CacheEntry) 544 _ = _obj1 545 _obj1.Next = _this.Head 546 (_this).Head = _0_toPush 547 } else { 548 (_this).Head = _0_toPush 549 (_this).Tail = _this.Head 550 } 551 } 552 } 553 } 554 func (_this *DoublyLinkedCacheEntryList) Remove(toRemove *CacheEntry) { 555 { 556 if (toRemove.Prev).Is_Null() { 557 (_this).Head = toRemove.Next 558 } else { 559 var _obj0 *CacheEntry = (toRemove.Prev).Dtor_deref().(*CacheEntry) 560 _ = _obj0 561 _obj0.Next = toRemove.Next 562 } 563 if (toRemove.Next).Is_Null() { 564 (_this).Tail = toRemove.Prev 565 } else { 566 var _obj1 *CacheEntry = (toRemove.Next).Dtor_deref().(*CacheEntry) 567 _ = _obj1 568 _obj1.Prev = toRemove.Prev 569 } 570 { 571 goto L0 572 } 573 L0: 574 (toRemove).Next = Companion_Default___.NULL() 575 (toRemove).Prev = Companion_Default___.NULL() 576 } 577 } 578 579 // End of class DoublyLinkedCacheEntryList 580 581 // Definition of class LocalCMC 582 type LocalCMC struct { 583 Queue *DoublyLinkedCacheEntryList 584 Cache *m_DafnyLibraries.MutableMap 585 _entryCapacity _dafny.Int 586 _entryPruningTailSize _dafny.Int 587 } 588 589 func New_LocalCMC_() *LocalCMC { 590 _this := LocalCMC{} 591 592 _this.Queue = (*DoublyLinkedCacheEntryList)(nil) 593 _this.Cache = (*m_DafnyLibraries.MutableMap)(nil) 594 _this._entryCapacity = _dafny.Zero 595 _this._entryPruningTailSize = _dafny.Zero 596 return &_this 597 } 598 599 type CompanionStruct_LocalCMC_ struct { 600 } 601 602 var Companion_LocalCMC_ = CompanionStruct_LocalCMC_{} 603 604 func (_this *LocalCMC) Equals(other *LocalCMC) bool { 605 return _this == other 606 } 607 608 func (_this *LocalCMC) EqualsGeneric(x interface{}) bool { 609 other, ok := x.(*LocalCMC) 610 return ok && _this.Equals(other) 611 } 612 613 func (*LocalCMC) String() string { 614 return "LocalCMC.LocalCMC" 615 } 616 617 func Type_LocalCMC_() _dafny.TypeDescriptor { 618 return type_LocalCMC_{} 619 } 620 621 type type_LocalCMC_ struct { 622 } 623 624 func (_this type_LocalCMC_) Default() interface{} { 625 return (*LocalCMC)(nil) 626 } 627 628 func (_this type_LocalCMC_) String() string { 629 return "LocalCMC.LocalCMC" 630 } 631 func (_this *LocalCMC) ParentTraits_() []*_dafny.TraitID { 632 return [](*_dafny.TraitID){m_AwsCryptographyMaterialProvidersTypes.Companion_ICryptographicMaterialsCache_.TraitID_} 633 } 634 635 var _ m_AwsCryptographyMaterialProvidersTypes.ICryptographicMaterialsCache = &LocalCMC{} 636 var _ _dafny.TraitOffspring = &LocalCMC{} 637 638 func (_this *LocalCMC) DeleteCacheEntry(input m_AwsCryptographyMaterialProvidersTypes.DeleteCacheEntryInput) m_Wrappers.Result { 639 var _out1 m_Wrappers.Result 640 _ = _out1 641 _out1 = m_AwsCryptographyMaterialProvidersTypes.Companion_ICryptographicMaterialsCache_.DeleteCacheEntry(_this, input) 642 return _out1 643 } 644 func (_this *LocalCMC) GetCacheEntry(input m_AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) m_Wrappers.Result { 645 var _out1 m_Wrappers.Result 646 _ = _out1 647 _out1 = m_AwsCryptographyMaterialProvidersTypes.Companion_ICryptographicMaterialsCache_.GetCacheEntry(_this, input) 648 return _out1 649 } 650 func (_this *LocalCMC) PutCacheEntry(input m_AwsCryptographyMaterialProvidersTypes.PutCacheEntryInput) m_Wrappers.Result { 651 var _out1 m_Wrappers.Result 652 _ = _out1 653 _out1 = m_AwsCryptographyMaterialProvidersTypes.Companion_ICryptographicMaterialsCache_.PutCacheEntry(_this, input) 654 return _out1 655 } 656 func (_this *LocalCMC) UpdateUsageMetadata(input m_AwsCryptographyMaterialProvidersTypes.UpdateUsageMetadataInput) m_Wrappers.Result { 657 var _out1 m_Wrappers.Result 658 _ = _out1 659 _out1 = m_AwsCryptographyMaterialProvidersTypes.Companion_ICryptographicMaterialsCache_.UpdateUsageMetadata(_this, input) 660 return _out1 661 } 662 func (_this *LocalCMC) Ctor__(entryCapacity_k _dafny.Int, entryPruningTailSize_k _dafny.Int) { 663 { 664 (_this)._entryCapacity = entryCapacity_k 665 (_this)._entryPruningTailSize = entryPruningTailSize_k 666 var _nw0 *m_DafnyLibraries.MutableMap = m_DafnyLibraries.New_MutableMap_() 667 _ = _nw0 668 (_this).Cache = _nw0 669 var _nw1 *DoublyLinkedCacheEntryList = New_DoublyLinkedCacheEntryList_() 670 _ = _nw1 671 _nw1.Ctor__() 672 (_this).Queue = _nw1 673 } 674 } 675 func (_this *LocalCMC) GetCacheEntry_k(input m_AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) m_Wrappers.Result { 676 { 677 var output m_Wrappers.Result = m_Wrappers.Result{} 678 _ = output 679 var _0_now int64 680 _ = _0_now 681 var _out0 int64 682 _ = _out0 683 _out0 = m__Time.CurrentRelativeTime() 684 _0_now = _out0 685 var _out1 m_Wrappers.Result 686 _ = _out1 687 _out1 = (_this).GetCacheEntryWithTime(input, _0_now) 688 output = _out1 689 return output 690 } 691 } 692 func (_this *LocalCMC) GetCacheEntryWithTime(input m_AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput, now int64) m_Wrappers.Result { 693 { 694 var output m_Wrappers.Result = m_Wrappers.Result{} 695 _ = output 696 if (_this.Cache).HasKey((input).Dtor_identifier()) { 697 var _0_entry *CacheEntry 698 _ = _0_entry 699 _0_entry = (_this.Cache).Select((input).Dtor_identifier()).(*CacheEntry) 700 if (now) <= ((_0_entry).ExpiryTime()) { 701 (_this.Queue).MoveToFront(_0_entry) 702 output = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_GetCacheEntryOutput_.Create_GetCacheEntryOutput_((_0_entry).Materials(), (_0_entry).CreationTime(), (_0_entry).ExpiryTime(), _0_entry.MessagesUsed, _0_entry.BytesUsed)) 703 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 704 _ = _1_valueOrError0 705 var _out0 m_Wrappers.Result 706 _ = _out0 707 _out0 = (_this).Pruning(now) 708 _1_valueOrError0 = _out0 709 if (_1_valueOrError0).IsFailure() { 710 output = (_1_valueOrError0).PropagateFailure() 711 return output 712 } 713 var _2___v0 _dafny.Tuple 714 _ = _2___v0 715 _2___v0 = (_1_valueOrError0).Extract().(_dafny.Tuple) 716 } else { 717 var _3_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 718 _ = _3_valueOrError1 719 var _out1 m_Wrappers.Result 720 _ = _out1 721 _out1 = (_this).DeleteCacheEntry_k(m_AwsCryptographyMaterialProvidersTypes.Companion_DeleteCacheEntryInput_.Create_DeleteCacheEntryInput_((input).Dtor_identifier())) 722 _3_valueOrError1 = _out1 723 if (_3_valueOrError1).IsFailure() { 724 output = (_3_valueOrError1).PropagateFailure() 725 return output 726 } 727 var _4___v1 _dafny.Tuple 728 _ = _4___v1 729 _4___v1 = (_3_valueOrError1).Extract().(_dafny.Tuple) 730 output = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_EntryDoesNotExist_(_dafny.SeqOfString("Entry past TTL"))) 731 } 732 } else { 733 output = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_EntryDoesNotExist_(_dafny.SeqOfString("Entry does not exist"))) 734 } 735 return output 736 } 737 } 738 func (_this *LocalCMC) PutCacheEntry_k(input m_AwsCryptographyMaterialProvidersTypes.PutCacheEntryInput) m_Wrappers.Result { 739 { 740 var output m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 741 _ = output 742 if ((_this).EntryCapacity()).Sign() == 0 { 743 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 744 return output 745 } 746 if (_this.Cache).HasKey((input).Dtor_identifier()) { 747 var _0_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 748 _ = _0_valueOrError0 749 var _out0 m_Wrappers.Result 750 _ = _out0 751 _out0 = (_this).DeleteCacheEntry_k(m_AwsCryptographyMaterialProvidersTypes.Companion_DeleteCacheEntryInput_.Create_DeleteCacheEntryInput_((input).Dtor_identifier())) 752 _0_valueOrError0 = _out0 753 if (_0_valueOrError0).IsFailure() { 754 output = (_0_valueOrError0).PropagateFailure() 755 return output 756 } 757 var _1___v2 _dafny.Tuple 758 _ = _1___v2 759 _1___v2 = (_0_valueOrError0).Extract().(_dafny.Tuple) 760 } 761 if ((_this).EntryCapacity()).Cmp((_this.Cache).Size()) == 0 { 762 var _2_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 763 _ = _2_valueOrError1 764 var _out1 m_Wrappers.Result 765 _ = _out1 766 _out1 = (_this).DeleteCacheEntry_k(m_AwsCryptographyMaterialProvidersTypes.Companion_DeleteCacheEntryInput_.Create_DeleteCacheEntryInput_(((_this.Queue.Tail).Dtor_deref().(*CacheEntry)).Identifier())) 767 _2_valueOrError1 = _out1 768 if (_2_valueOrError1).IsFailure() { 769 output = (_2_valueOrError1).PropagateFailure() 770 return output 771 } 772 var _3___v3 _dafny.Tuple 773 _ = _3___v3 774 _3___v3 = (_2_valueOrError1).Extract().(_dafny.Tuple) 775 } 776 var _4_cell *CacheEntry 777 _ = _4_cell 778 var _nw0 *CacheEntry = New_CacheEntry_() 779 _ = _nw0 780 _nw0.Ctor__((input).Dtor_materials(), (input).Dtor_identifier(), (input).Dtor_creationTime(), (input).Dtor_expiryTime(), ((input).Dtor_messagesUsed()).UnwrapOr(int32(0)).(int32), ((input).Dtor_bytesUsed()).UnwrapOr(int32(0)).(int32)) 781 _4_cell = _nw0 782 (_this.Queue).PushCell(_4_cell) 783 (_this.Cache).Put((input).Dtor_identifier(), _4_cell) 784 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 785 return output 786 } 787 } 788 func (_this *LocalCMC) DeleteCacheEntry_k(input m_AwsCryptographyMaterialProvidersTypes.DeleteCacheEntryInput) m_Wrappers.Result { 789 { 790 var output m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 791 _ = output 792 if (_this.Cache).HasKey((input).Dtor_identifier()) { 793 var _0_cell *CacheEntry 794 _ = _0_cell 795 _0_cell = (_this.Cache).Select((input).Dtor_identifier()).(*CacheEntry) 796 { 797 (_this.Cache).Remove((input).Dtor_identifier()) 798 goto L1 799 } 800 L1: 801 (_this.Queue).Remove(_0_cell) 802 } 803 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 804 return output 805 } 806 } 807 func (_this *LocalCMC) UpdateUsageMetadata_k(input m_AwsCryptographyMaterialProvidersTypes.UpdateUsageMetadataInput) m_Wrappers.Result { 808 { 809 var output m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 810 _ = output 811 if (_this.Cache).HasKey((input).Dtor_identifier()) { 812 var _0_cell *CacheEntry 813 _ = _0_cell 814 _0_cell = (_this.Cache).Select((input).Dtor_identifier()).(*CacheEntry) 815 if ((_0_cell.MessagesUsed) <= ((Companion_Default___.INT32__MAX__VALUE()) - (int32(1)))) && ((_0_cell.BytesUsed) <= ((Companion_Default___.INT32__MAX__VALUE()) - ((input).Dtor_bytesUsed()))) { 816 var _rhs0 int32 = (_0_cell.MessagesUsed) + (int32(1)) 817 _ = _rhs0 818 var _rhs1 int32 = (_0_cell.BytesUsed) + ((input).Dtor_bytesUsed()) 819 _ = _rhs1 820 var _lhs0 *CacheEntry = _0_cell 821 _ = _lhs0 822 var _lhs1 *CacheEntry = _0_cell 823 _ = _lhs1 824 _lhs0.MessagesUsed = _rhs0 825 _lhs1.BytesUsed = _rhs1 826 } else { 827 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 828 _ = _1_valueOrError0 829 var _out0 m_Wrappers.Result 830 _ = _out0 831 _out0 = (_this).DeleteCacheEntry_k(m_AwsCryptographyMaterialProvidersTypes.Companion_DeleteCacheEntryInput_.Create_DeleteCacheEntryInput_((input).Dtor_identifier())) 832 _1_valueOrError0 = _out0 833 if (_1_valueOrError0).IsFailure() { 834 output = (_1_valueOrError0).PropagateFailure() 835 return output 836 } 837 var _2___v4 _dafny.Tuple 838 _ = _2___v4 839 _2___v4 = (_1_valueOrError0).Extract().(_dafny.Tuple) 840 } 841 } 842 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 843 return output 844 return output 845 } 846 } 847 func (_this *LocalCMC) Pruning(now int64) m_Wrappers.Result { 848 { 849 var output m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 850 _ = output 851 var _hi0 _dafny.Int = (_this).EntryPruningTailSize() 852 _ = _hi0 853 for _0_i := _dafny.Zero; _0_i.Cmp(_hi0) < 0; _0_i = _0_i.Plus(_dafny.One) { 854 if (_this.Queue.Tail).Is_Ptr() { 855 if (((_this.Queue.Tail).Dtor_deref().(*CacheEntry)).ExpiryTime()) < (now) { 856 var _1_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf()) 857 _ = _1_valueOrError0 858 var _out0 m_Wrappers.Result 859 _ = _out0 860 _out0 = (_this).DeleteCacheEntry_k(m_AwsCryptographyMaterialProvidersTypes.Companion_DeleteCacheEntryInput_.Create_DeleteCacheEntryInput_(((_this.Queue.Tail).Dtor_deref().(*CacheEntry)).Identifier())) 861 _1_valueOrError0 = _out0 862 if (_1_valueOrError0).IsFailure() { 863 output = (_1_valueOrError0).PropagateFailure() 864 return output 865 } 866 var _2___v5 _dafny.Tuple 867 _ = _2___v5 868 _2___v5 = (_1_valueOrError0).Extract().(_dafny.Tuple) 869 } else { 870 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 871 return output 872 } 873 } else { 874 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 875 return output 876 } 877 } 878 output = m_Wrappers.Companion_Result_.Create_Success_(_dafny.TupleOf()) 879 return output 880 return output 881 } 882 } 883 func (_this *LocalCMC) EntryCapacity() _dafny.Int { 884 { 885 return _this._entryCapacity 886 } 887 } 888 func (_this *LocalCMC) EntryPruningTailSize() _dafny.Int { 889 { 890 return _this._entryPruningTailSize 891 } 892 } 893 894 // End of class LocalCMC