Skip to content

Commit 2c5e165

Browse files
authored
chore: Use latest Dafny version (#302)
* chore: Use latest Dafny version * chore: Update Boogie version to 2.4.21. Note, Boogie versions 2.5 and later want Z3 4.8.7, which Dafny doesn't yet support. * chore: Update/speed up some proofs.
1 parent 0a7b6bd commit 2c5e165

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

buildspec.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ phases:
1010
- mozroots --import --sync
1111
# Get Boogie
1212
# Multiple Boogie commits have broken our build or test cases. Locking down Boogie.
13-
- git clone --branch v2.4.2 https://github.com/boogie-org/boogie.git
13+
- git clone --branch v2.4.21 https://github.com/boogie-org/boogie.git
1414
- nuget restore boogie/Source/Boogie.sln
1515
- msbuild boogie/Source/Boogie.sln
1616
# Get Dafny
1717
- git clone https://github.com/microsoft/dafny.git
1818
# Although Dafny does have releases, we often need a newer hash than the latest release, while still needing the
1919
# the security of reproducible builds.
2020
- cd dafny
21-
- git reset --hard 5ca6ef8347c9675b6824e987967925b1208ca47c
21+
- git reset --hard df707bc07e3c39390286dfd0c1576d0a3f556f8b
2222
- cd ..
2323
- nuget restore dafny/Source/Dafny.sln
2424
- msbuild dafny/Source/Dafny.sln

src/KMS/KMSUtils.dfy

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module {:extern "KMSUtils"} KMSUtils {
1313

1414
const MAX_GRANT_TOKENS := 10
1515

16-
type CustomerMasterKey = s: string | ValidFormatCMK(s) witness "alias/ExampleAlias"
16+
type CustomerMasterKey = s: string | ValidFormatCMK(s)
17+
witness (ValidCMKAliasFromSuffix("ExampleAlias"); "alias/ExampleAlias")
1718

1819
predicate method ValidFormatCMK(cmk: string) {
1920
ValidFormatCMKKeyARN(cmk) || ValidFormatCMKAlias(cmk) || ValidFormatCMKAliasARN(cmk)
@@ -29,6 +30,32 @@ module {:extern "KMSUtils"} KMSUtils {
2930
UTF8.IsASCIIString(cmk) && 0 < |cmk| <= 2048 && |components| == 2 && components[0] == "alias"
3031
}
3132

33+
lemma ValidCMKAliasFromSuffix(suffix: string)
34+
requires UTF8.IsASCIIString(suffix) && |suffix| < 2042 && '/' !in suffix
35+
ensures var cmk := "alias/" + suffix;
36+
ValidFormatCMKAlias(cmk)
37+
{
38+
var alias := "alias";
39+
assert UTF8.IsASCIIString(alias);
40+
var cmk := alias + "/" + suffix;
41+
assert UTF8.IsASCIIString(cmk);
42+
43+
var components := Split(cmk, '/');
44+
calc {
45+
components;
46+
==
47+
Split(alias + "/" + suffix, '/');
48+
== { WillSplitOnDelim(cmk, '/', alias); }
49+
[alias] + Split(cmk[|alias| + 1..], '/');
50+
== { assert cmk[|alias| + 1..] == suffix; }
51+
[alias] + Split(suffix, '/');
52+
== { WillNotSplitWithOutDelim(suffix, '/'); }
53+
[alias] + [suffix];
54+
==
55+
[alias, suffix];
56+
}
57+
}
58+
3259
predicate method ValidFormatCMKAliasARN(cmk: string) {
3360
var components := Split(cmk, ':');
3461
UTF8.IsASCIIString(cmk) && 0 < |cmk| <= 2048 && |components| == 6 && components[0] == "arn" && components[2] == "kms" && Split(components[5], '/')[0] == "alias"

0 commit comments

Comments
 (0)