Skip to content
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: Simplify error when decrypting a single EDK #1022

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,14 @@ module {:options "/functionSyntax:4" } AwsKmsEcdhKeyring {
//# If OnDecrypt fails to successfully decrypt any encrypted data key,
//# then it MUST yield an error that includes all the collected errors.
var SealedDecryptionMaterials :- outcome
.MapFailure(errors => Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."
)
.MapFailure(errors =>
if |errors| == 1 then
errors[0]
else
Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."
)
);

assert decryptClosure.Ensures(Last(attempts).input, Success(SealedDecryptionMaterials), DropLast(attempts));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,14 @@ module AwsKmsHierarchicalKeyring {
//# If OnDecrypt fails to successfully decrypt any [encrypted data key]
//# (../structures.md#encrypted-data-key), then it MUST yield an error
//# that includes all the collected errors.
.MapFailure(errors => Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."
)
.MapFailure(errors =>
if |errors| == 1 then
errors[0]
else
Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."
)
);

assert decryptClosure.Ensures(Last(attempts).input, Success(SealedDecryptionMaterials), DropLast(attempts));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,13 @@ module AwsKmsKeyring {
//# If OnDecrypt fails to successfully decrypt any [encrypted data key]
//# (../structures.md#encrypted-data-key), then it MUST yield an error
//# that includes all the collected errors.
.MapFailure(errors => Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."));
.MapFailure(errors =>
if |errors| == 1 then
errors[0]
else
Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."));

assert decryptClosure.Ensures(Last(attempts).input, Success(SealedDecryptionMaterials), DropLast(attempts));
return Success(Types.OnDecryptOutput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,13 @@ module AwsKmsMrkKeyring {
);

var SealedDecryptionMaterials :- outcome
.MapFailure(errors => Types.CollectionOfErrors( list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."));
.MapFailure(errors =>
if |errors| == 1 then
errors[0]
else
Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."));

assert decryptClosure.Ensures(Last(attempts).input, Success(SealedDecryptionMaterials), DropLast(attempts));
assert Last(attempts).input in input.encryptedDataKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,13 @@ module AwsKmsRsaKeyring {
);

var SealedDecryptionMaterials :- outcome
.MapFailure(errors => Types.CollectionOfErrors(list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."));
.MapFailure(errors =>
if |errors| == 1 then
errors[0]
else
Types.CollectionOfErrors(
list := errors,
message := "No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."));

assert decryptClosure.Ensures(Seq.Last(attempts).input, Success(SealedDecryptionMaterials), Seq.DropLast(attempts));
return Success(Types.OnDecryptOutput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,14 @@ module {:options "/functionSyntax:4" } RawECDHKeyring {
//# If OnDecrypt fails to successfully decrypt any encrypted data key,
//# then it MUST yield an error that includes all the collected errors.
var SealedDecryptionMaterials :- outcome
.MapFailure(errors => Types.CollectionOfErrors(
list := errors,
message := "No Configured Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."
)
.MapFailure(errors =>
if |errors| == 1 then
errors[0]
else
Types.CollectionOfErrors(
list := errors,
message := "No Configured Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."
)
);

assert decryptClosure.Ensures(Last(attempts).input, Success(SealedDecryptionMaterials), DropLast(attempts));
Expand Down
Loading