Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
477b58f
chore: add performance measurement infrastructure
ajewellamz Mar 14, 2025
43c074b
chore: improve performance
ajewellamz Mar 14, 2025
31ed3ae
m
ajewellamz Mar 17, 2025
7f379b1
m
ajewellamz Mar 17, 2025
4cc35bd
m
ajewellamz Mar 17, 2025
eff99eb
m
ajewellamz Mar 19, 2025
c34eac0
m
ajewellamz Mar 20, 2025
3ee9d7c
m
ajewellamz Mar 20, 2025
5d8bfaf
m
ajewellamz Mar 20, 2025
6a4404c
m
ajewellamz Mar 20, 2025
16b57d4
m
ajewellamz Mar 20, 2025
6fe374e
Merge branch 'ajewell/measure' into ajewell/optimize
ajewellamz Mar 20, 2025
5819fc8
m
ajewellamz Mar 20, 2025
4cd4714
m
ajewellamz Mar 20, 2025
fde4eab
m
ajewellamz Mar 22, 2025
cc737f3
m
ajewellamz Mar 22, 2025
8b5b9a9
Merge branch 'mainline' into ajewell/measure
ajewellamz Mar 22, 2025
fb8949b
m
ajewellamz Mar 22, 2025
d73e2bf
m
ajewellamz Mar 23, 2025
c9e358f
m
ajewellamz Mar 23, 2025
bd94648
m
ajewellamz Mar 23, 2025
df91f52
m
ajewellamz Mar 24, 2025
cb4e1ca
Merge branch 'ajewell/measure' into ajewell/optimize
ajewellamz Mar 24, 2025
79889ad
Merge branch 'mainline' into ajewell/measure
ajewellamz Mar 25, 2025
8d0bb2e
Merge branch 'ajewell/measure' into ajewell/optimize
ajewellamz Mar 25, 2025
a490d22
m
ajewellamz Mar 25, 2025
ae27406
Merge branch 'mainline' into ajewell/measure
ajewellamz Mar 28, 2025
11c6547
Merge branch 'ajewell/measure' into ajewell/optimize
ajewellamz Mar 28, 2025
e012d6f
m
ajewellamz Mar 28, 2025
0247004
m
ajewellamz Mar 28, 2025
eff1895
m
ajewellamz Apr 3, 2025
b98d046
m
ajewellamz Apr 3, 2025
184fa26
m
ajewellamz Apr 3, 2025
85ac6d0
m
ajewellamz Apr 3, 2025
f3b7a01
m
ajewellamz Apr 8, 2025
e5bcfce
Merge branch 'mainline' into ajewell/measure
ajewellamz Apr 8, 2025
b8c974d
m
ajewellamz Apr 9, 2025
42c6dc2
m
ajewellamz Apr 9, 2025
21a2af8
Merge branch 'ajewell/measure' into ajewell/optimize
ajewellamz Apr 9, 2025
5b30125
m
ajewellamz Apr 9, 2025
0203211
m
ajewellamz Apr 9, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/library_rust_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ jobs:
unzip valid-Net-4.0.0.zip -d valid-Net-4.0.0

- name: Test Rust
working-directory: ${{ matrix.library }}
working-directory: ${{ matrix.library }}/runtimes/rust
shell: bash
run: |
# Without this, running test vectors fails due to `fatal runtime error: stack overflow`
export RUST_MIN_STACK=104857600
make test_rust
cargo test --release -- --test-threads 1 --nocapture
45 changes: 44 additions & 1 deletion AwsEncryptionSDK/dafny/AwsEncryptionSdk/src/MessageBody.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ module MessageBody {
&& MessageFramesAreForTheSameMessage(regularFrames)
}

lemma IsMessageRegularFramesCanBeSplit(
regularFrames: seq<Frames.RegularFrame>
)
requires IsMessageRegularFrames(regularFrames)
ensures forall accumulator
| accumulator <= regularFrames
::
&& IsMessageRegularFrames(accumulator)
{
forall accumulator
| accumulator <= regularFrames
ensures
&& IsMessageRegularFrames(accumulator)
{
assert |accumulator| <= |regularFrames|;
assert 0 <= |accumulator| < ENDFRAME_SEQUENCE_NUMBER as nat;
assume {:axiom} MessageFramesAreMonotonic(accumulator);
assert MessageFramesAreForTheSameMessage(accumulator);
}
}

type NonFramedMessage = Frames.NonFramed

datatype FramedMessageBody = FramedMessageBody(
Expand Down Expand Up @@ -939,7 +960,7 @@ module MessageBody {
WriteMessageRegularFrames(body.regularFrames) + Frames.WriteFinalFrame(body.finalFrame)
}

function method WriteMessageRegularFrames(
function WriteMessageRegularFrames(
frames: MessageRegularFrames
)
:(ret: seq<uint8>)
Expand All @@ -954,6 +975,28 @@ module MessageBody {
WriteMessageRegularFrames(Seq.DropLast(frames))
+ Frames.WriteRegularFrame(Seq.Last(frames))
}
by method { // because Seq.DropLast makes a full copy
var result : seq<uint8> := [];
for i := 0 to |frames|
invariant IsMessageRegularFrames(frames)
invariant IsMessageRegularFrames(frames[..i])
invariant result == WriteMessageRegularFrames(frames[..i])
{
result := result + Frames.WriteRegularFrame(frames[i]);
assert result == WriteMessageRegularFrames(frames[..i]) + Frames.WriteRegularFrame(frames[i]);
assert Seq.DropLast(frames[..i+1]) == frames[..i];
assert result == WriteMessageRegularFrames(Seq.DropLast(frames[..i+1])) + Frames.WriteRegularFrame(Seq.Last(frames[..i+1]));
IsMessageRegularFramesCanBeSplit(frames);
assert IsMessageRegularFrames(frames[..i]);
assert IsMessageRegularFrames(frames[..i+1]);
assert result == WriteMessageRegularFrames(frames[..i+1]);

}
assert result == WriteMessageRegularFrames(frames[..|frames|]);
assert frames == frames[..|frames|];
assert result == WriteMessageRegularFrames(frames);
return result;
}

function method {:recursive} {:vcs_split_on_every_assert} ReadFramedMessageBody(
buffer: ReadableBuffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module {:options "/functionSyntax:4" } EncryptedDataKeys {
+ WriteShortLengthSeq(edk.ciphertext)
}

// Seq.DropLast makes a full copy, but we seldom have more than one or two data keys,
// so no point in optimizing away the copy.
function {:tailrecursion} WriteEncryptedDataKeys(
edks: ESDKEncryptedDataKeys
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ module {:options "/functionSyntax:4" } EncryptionContext {
WriteUint16(|ec| as uint16) + WriteAADPairs(ec)
}

function {:tailrecursion} WriteAADPairs(
function WriteAADPairs(
ec: ESDKCanonicalEncryptionContext
):
(ret: seq<uint8>)
Expand All @@ -406,6 +406,28 @@ module {:options "/functionSyntax:4" } EncryptionContext {
assert LinearLength(Seq.DropLast(ec)) < LinearLength(ec);
WriteAADPairs(Seq.DropLast(ec)) + WriteAADPair(Seq.Last(ec))
}
by method { // because Seq.DropLast makes a full copy
var result : seq<uint8> := [];
for i := 0 to |ec|
invariant ESDKCanonicalEncryptionContext?(ec)
invariant ESDKCanonicalEncryptionContext?(ec[..i])
invariant result == WriteAADPairs(ec[..i])
{
result := result + WriteAADPair(ec[i]);
ESDKCanonicalEncryptionContextCanBeSplit(ec);
assert result == WriteAADPairs(ec[..i]) + WriteAADPair(ec[i]);
assert Seq.DropLast(ec[..i+1]) == ec[..i];
assert result == WriteAADPairs(Seq.DropLast(ec[..i+1])) + WriteAADPair(Seq.Last(ec[..i+1]));
assert ESDKCanonicalEncryptionContext?(ec[..i]);
assert ESDKCanonicalEncryptionContext?(ec[..i+1]);
assert result == WriteAADPairs(ec[..i+1]);

}
assert result == WriteAADPairs(ec[..|ec|]);
assert ec == ec[..|ec|];
assert result == WriteAADPairs(ec);
return result;
}

//= compliance/data-format/message-header.txt#2.5.1.7.2.2
//# The following table describes the fields that form each key value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ module SerializableTypes {
==> pairs[i].key != pairs[j].key)
}

function method {:tailrecursion} LinearLength(
function LinearLength(
pairs: Linear<UTF8.ValidUTF8Bytes, UTF8.ValidUTF8Bytes>
):
(ret: nat)
Expand All @@ -162,6 +162,24 @@ module SerializableTypes {
else
LinearLength(Seq.DropLast(pairs)) + PairLength(Seq.Last(pairs))
}
by method { // because Seq.DropLast makes a full copy
var result : nat := 0;
for i := 0 to |pairs|
invariant result == LinearLength(pairs[..i])
{
result := result + PairLength(pairs[i]);
assert result == LinearLength(pairs[..i]) + PairLength(pairs[i]);
assert Seq.DropLast(pairs[..i+1]) == pairs[..i];
assert result == LinearLength(Seq.DropLast(pairs[..i+1])) + PairLength(Seq.Last(pairs[..i+1]));
assert result == LinearLength(pairs[..i+1]);

}
assert result == LinearLength(pairs[..|pairs|]);
assert pairs == pairs[..|pairs|];
assert result == LinearLength(pairs);
return result;
}


function method PairLength(
pair: Pair<UTF8.ValidUTF8Bytes, UTF8.ValidUTF8Bytes>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading