-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: mpl externs #1105
Merged
Merged
feat: mpl externs #1105
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bcd56e0
Merge branch 'Golang/kms' into Golang/mpl
b0f7133
Merge branch 'Golang/ddb' into Golang/mpl
1ddb66d
Merge branch 'Golang/Primitives' into Golang/mpl
0022844
feat: mpl externs
fcf2ec3
fix: formatting
6fbde1d
feat: CI
21fa245
Merge branch 'main' into Golang/mpl
ShubhamChaturvedi7 7418345
fix: CI
31bc5e1
Merge branch 'Golang/Primitives' into Golang/mpl
8569aae
Merge branch 'main' into Golang/mpl
32d88cd
fix: Bugs
feacccb
Merge branch 'main' into Golang/mpl
116cf10
Merge branch 'main' into Golang/mpl
96191cf
fix: Linear Map for cache
13a8267
fix: libraries submodule commit
ca240d6
fix: PR comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...aphicMaterialProviders/runtimes/go/ImplementationFromDafny-go/StormTrackingCMC/externs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package StormTrackingCMC | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
|
||
"github.com/aws/aws-cryptographic-material-providers-library/mpl/AwsCryptographyMaterialProvidersTypes" | ||
"github.com/aws/aws-cryptographic-material-providers-library/mpl/StormTracker" | ||
_dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny" | ||
"github.com/dafny-lang/DafnyStandardLibGo/Wrappers" | ||
) | ||
|
||
type StormTrackingCMC struct { | ||
stormTracker *StormTracker.StormTracker | ||
//The Lock contention is not tested. | ||
sync.Mutex | ||
} | ||
|
||
func New_StormTrackingCMC_(stormTracker *StormTracker.StormTracker) *StormTrackingCMC { | ||
return &StormTrackingCMC{stormTracker: stormTracker} | ||
} | ||
|
||
func (cmc *StormTrackingCMC) PutCacheEntry(input AwsCryptographyMaterialProvidersTypes.PutCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.PutCacheEntry(input) | ||
} | ||
func (cmc *StormTrackingCMC) PutCacheEntry_k(input AwsCryptographyMaterialProvidersTypes.PutCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.PutCacheEntry(input) | ||
} | ||
func (cmc *StormTrackingCMC) UpdateUsageMetadata(input AwsCryptographyMaterialProvidersTypes.UpdateUsageMetadataInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.UpdateUsageMetadata(input) | ||
} | ||
func (cmc *StormTrackingCMC) UpdateUsageMetadata_k(input AwsCryptographyMaterialProvidersTypes.UpdateUsageMetadataInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.UpdateUsageMetadata(input) | ||
} | ||
func (cmc *StormTrackingCMC) GetCacheEntry(input AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) Wrappers.Result { | ||
return cmc.GetCacheEntry_k(input) | ||
} | ||
func (cmc *StormTrackingCMC) GetCacheEntry_k(input AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) Wrappers.Result { | ||
for { | ||
res := cmc.GetFromInner(input) | ||
if res.IsFailure() { | ||
return Companion_Default___.CreateGetCacheEntryFailure(res.Dtor_error().(AwsCryptographyMaterialProvidersTypes.Error)) | ||
} else if res.Dtor_value().(StormTracker.CacheState).Is_Full() { | ||
return Companion_Default___.CreateGetCacheEntrySuccess(res.Dtor_value().(StormTracker.CacheState).Dtor_data()) | ||
} else if res.Dtor_value().(StormTracker.CacheState).Is_EmptyFetch() { | ||
return Companion_Default___.CreateGetCacheEntryFailure(AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_EntryDoesNotExist_(_dafny.SeqOfChars([]_dafny.Char("Entry doesn't exists")...))) | ||
} else { | ||
time.Sleep(time.Duration(cmc.stormTracker.SleepMilli)) | ||
} | ||
} | ||
} | ||
func (cmc *StormTrackingCMC) DeleteCacheEntry(input AwsCryptographyMaterialProvidersTypes.DeleteCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.DeleteCacheEntry(input) | ||
|
||
} | ||
func (cmc *StormTrackingCMC) DeleteCacheEntry_k(input AwsCryptographyMaterialProvidersTypes.DeleteCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.DeleteCacheEntry(input) | ||
} | ||
|
||
func (cmc *StormTrackingCMC) String() string { | ||
return "StormTrackerCMC" | ||
} | ||
|
||
func (cmc *StormTrackingCMC) GetFromInner(input AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.stormTracker.GetFromCache(input) | ||
} |
63 changes: 63 additions & 0 deletions
63
...cMaterialProviders/runtimes/go/ImplementationFromDafny-go/SynchronizedLocalCMC/externs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package SynchronizedLocalCMC | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/aws/aws-cryptographic-material-providers-library/mpl/AwsCryptographyMaterialProvidersTypes" | ||
"github.com/aws/aws-cryptographic-material-providers-library/mpl/LocalCMC" | ||
"github.com/dafny-lang/DafnyStandardLibGo/Wrappers" | ||
) | ||
|
||
type SynchronizedLocalCMC struct { | ||
localCMC *LocalCMC.LocalCMC | ||
sync.Mutex | ||
} | ||
|
||
func New_SynchronizedLocalCMC_(localCMC *LocalCMC.LocalCMC) *SynchronizedLocalCMC { | ||
return &SynchronizedLocalCMC{localCMC: localCMC} | ||
} | ||
|
||
func (cmc *SynchronizedLocalCMC) PutCacheEntry(input AwsCryptographyMaterialProvidersTypes.PutCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.PutCacheEntry(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) PutCacheEntry_k(input AwsCryptographyMaterialProvidersTypes.PutCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.PutCacheEntry_k(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) UpdateUsageMetadata(input AwsCryptographyMaterialProvidersTypes.UpdateUsageMetadataInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.UpdateUsageMetadata(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) UpdateUsageMetadata_k(input AwsCryptographyMaterialProvidersTypes.UpdateUsageMetadataInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.UpdateUsageMetadata_k(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) GetCacheEntry(input AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.GetCacheEntry(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) GetCacheEntry_k(input AwsCryptographyMaterialProvidersTypes.GetCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.GetCacheEntry_k(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) DeleteCacheEntry(input AwsCryptographyMaterialProvidersTypes.DeleteCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.DeleteCacheEntry(input) | ||
} | ||
func (cmc *SynchronizedLocalCMC) DeleteCacheEntry_k(input AwsCryptographyMaterialProvidersTypes.DeleteCacheEntryInput) Wrappers.Result { | ||
cmc.Lock() | ||
defer cmc.Unlock() | ||
return cmc.localCMC.DeleteCacheEntry_k(input) | ||
} | ||
|
||
func (*SynchronizedLocalCMC) String() string { | ||
return "SynchronizedLocalCMC" | ||
} |
43 changes: 43 additions & 0 deletions
43
AwsCryptographicMaterialProviders/runtimes/go/ImplementationFromDafny-go/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module github.com/aws/aws-cryptographic-material-providers-library/mpl | ||
|
||
go 1.23.0 | ||
|
||
require github.com/dafny-lang/DafnyStandardLibGo v0.0.0 | ||
|
||
require ( | ||
github.com/aws/aws-cryptographic-material-providers-library/dynamodb v0.0.0 | ||
github.com/aws/aws-cryptographic-material-providers-library/kms v0.0.0 | ||
github.com/aws/aws-cryptographic-material-providers-library/primitives v0.0.0 | ||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.35.1 | ||
github.com/aws/aws-sdk-go-v2/service/kms v1.36.0 | ||
github.com/aws/smithy-go v1.21.0 | ||
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.1 | ||
|
||
) | ||
|
||
require ( | ||
github.com/aws/aws-sdk-go-v2 v1.31.0 // indirect | ||
github.com/aws/aws-sdk-go-v2/config v1.27.37 // indirect | ||
github.com/aws/aws-sdk-go-v2/credentials v1.17.35 // indirect | ||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.19 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/sso v1.23.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/sts v1.31.1 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
) | ||
|
||
replace ( | ||
github.com/aws/aws-cryptographic-material-providers-library/dynamodb v0.0.0 => ../../../../ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/ | ||
github.com/aws/aws-cryptographic-material-providers-library/kms v0.0.0 => ../../../../ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/ | ||
github.com/aws/aws-cryptographic-material-providers-library/primitives v0.0.0 => ../../../../AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ | ||
|
||
) | ||
|
||
replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../StandardLibrary/runtimes/go/ImplementationFromDafny-go/ |
44 changes: 44 additions & 0 deletions
44
AwsCryptographicMaterialProviders/runtimes/go/TestsFromDafny-go/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module github.com/aws/aws-cryptographic-material-providers-library/mpl/test | ||
|
||
go 1.23.0 | ||
|
||
replace github.com/aws/aws-cryptographic-material-providers-library/mpl v0.0.0 => ../ImplementationFromDafny-go | ||
|
||
replace ( | ||
github.com/aws/aws-cryptographic-material-providers-library/dynamodb v0.0.0 => ../../../../ComAmazonawsDynamodb/runtimes/go/ImplementationFromDafny-go/ | ||
github.com/aws/aws-cryptographic-material-providers-library/kms v0.0.0 => ../../../../ComAmazonawsKms/runtimes/go/ImplementationFromDafny-go/ | ||
github.com/aws/aws-cryptographic-material-providers-library/primitives v0.0.0 => ../../../../AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/ | ||
|
||
) | ||
|
||
replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../StandardLibrary/runtimes/go/ImplementationFromDafny-go/ | ||
|
||
require ( | ||
github.com/aws/aws-cryptographic-material-providers-library/dynamodb v0.0.0 | ||
github.com/aws/aws-cryptographic-material-providers-library/kms v0.0.0 | ||
github.com/aws/aws-cryptographic-material-providers-library/mpl v0.0.0 | ||
github.com/aws/aws-cryptographic-material-providers-library/primitives v0.0.0 | ||
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.9.2 | ||
github.com/dafny-lang/DafnyStandardLibGo v0.0.0 | ||
) | ||
|
||
require ( | ||
github.com/aws/aws-sdk-go-v2 v1.31.0 // indirect | ||
github.com/aws/aws-sdk-go-v2/config v1.27.37 // indirect | ||
github.com/aws/aws-sdk-go-v2/credentials v1.17.35 // indirect | ||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect | ||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.35.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.19 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/kms v1.36.0 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/sso v1.23.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.1 // indirect | ||
github.com/aws/aws-sdk-go-v2/service/sts v1.31.1 // indirect | ||
github.com/aws/smithy-go v1.21.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see: https://github.com/aws/aws-cryptographic-material-providers-library/blob/main/AwsCryptographicMaterialProviders/runtimes/java/src/main/java/software/amazon/cryptography/internaldafny/StormTrackingCMC/StormTrackingCMC.java#L112-L132
This needs to keep track of how long it is sleeping. At a minimum, it can be an unbounded wait :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.