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

fix assumed termination measure #329

Merged
merged 1 commit into from
Apr 19, 2024
Merged
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
4 changes: 3 additions & 1 deletion pkg/slayers/scion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,11 @@ func (s *SCION) upperLayerChecksum(upperLayer []byte, csum uint32) uint32 {

// (VerifiedSCION) The following function terminates but Gobra can't
// deduce that because of limited support of bitwise operations.
// @ decreases _
// @ decreases
func (s *SCION) foldChecksum(csum uint32) (res uint16) {
// @ decreases csum
for csum > 0xffff {
// @ b.FoldChecksumLemma(csum)
csum = (csum >> 16) + (csum & 0xffff)
}
return ^uint16(csum)
Expand Down
6 changes: 6 additions & 0 deletions verification/utils/bitwise/bitwise-eqs.gobra
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ ensures 3 & 1 == 1
ensures 3 & 2 == 2
decreases
pure func InfoFieldFirstByteSerializationLemmas() bool

ensures csum > 0xffff ==>
let newCsum := (csum >> 16) + (csum & 0xffff) in
newCsum < csum
decreases
pure func FoldChecksumLemma(csum uint32) struct{}
6 changes: 6 additions & 0 deletions verification/utils/bitwise/proofs.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,10 @@ lemma FUint32AfterFPutUint32(v: bv32)
lemma FPutUint32AfterFUint32(b0: bv8, b1: bv8, b2: bv8, b3: bv8)
ensures var v := FUint32Spec(b0, b1, b2, b3);
FPutUint32Spec(v) == (b0, b1, b2, b3)
{}

lemma FoldChecksumLemma(csum: bv32)
ensures csum > 0xffff ==>
var newCsum := (csum >> 16) + (csum & 0xffff);
newCsum < csum
{}
Loading