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

Leakage traces #431

Open
wants to merge 97 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
339340e
add LS.v
OwenConoly Sep 6, 2024
3a533e6
modify LS.v
OwenConoly Sep 6, 2024
dc9a34e
prettify MetricSemantics eval_expr
OwenConoly Aug 28, 2024
4dd8ea4
add MetricLeakageSemantics
OwenConoly Aug 28, 2024
8befdf5
organize semantics-relation lemmas in MetricLeakageSemantics
OwenConoly Aug 28, 2024
cd93eec
remove unneeded direction of eval_expr equivalence
OwenConoly Aug 28, 2024
adbf224
all the desired relations between semantics
OwenConoly Aug 28, 2024
7f405f4
make build less noisy
OwenConoly Aug 28, 2024
e888a14
create LWP
OwenConoly Sep 6, 2024
3cb00f8
modify LeakageWeakestPrecondition.v
OwenConoly Sep 6, 2024
dab765a
add LWPP
OwenConoly Sep 6, 2024
4275fbb
modify LWPP.v
OwenConoly Sep 6, 2024
371d3d4
add LL.v
OwenConoly Sep 24, 2024
75ee742
edit LL.v
OwenConoly Sep 24, 2024
efacffd
add LPL
OwenConoly Sep 27, 2024
e7041cc
first pass on editing LPL
OwenConoly Sep 30, 2024
bfd3805
add kyber file. doesn't work, since straightline needs fixes
OwenConoly Sep 30, 2024
990cae9
make kyberslash work
OwenConoly Sep 30, 2024
142f538
remove garbage (Search commands, etc) from kyberslash proof
OwenConoly Sep 30, 2024
ebde2c7
update FlatImp to use MetricLeakageSemantics
OwenConoly Sep 30, 2024
897e4e7
add 'custom fixpoint' stuff. add comparison of Fix_eq and Fix_eq'.
OwenConoly Sep 30, 2024
5140237
add leakage function to DCEDef
OwenConoly Sep 30, 2024
a27dae1
switch to using Fix instead of my_Fix.
OwenConoly Sep 30, 2024
5b8edc8
switch to using Fix_eq' and get unstuck
OwenConoly Sep 30, 2024
9f5f927
start on DCE proof
OwenConoly Sep 30, 2024
7aa6ee9
progress on DCE phase
OwenConoly Sep 30, 2024
9bac048
add pick_sp stuff to DCE trace transformation function
OwenConoly Sep 30, 2024
577d5d5
finish updating DCE function
OwenConoly Oct 1, 2024
3729b9c
had an idea about how to simplify function
OwenConoly Oct 1, 2024
b51a8de
DCE progress
OwenConoly Oct 1, 2024
5b82fd2
up to loop case
OwenConoly Oct 1, 2024
aaf754f
get stuck in sequence (and while) case. IH is no good!
OwenConoly Oct 1, 2024
b024527
rewrite DCE function in CPS. need to decide how to prove fixpoint eq…
OwenConoly Oct 2, 2024
16a43d3
new version of Fix with dependent types as well as arbitrary equivale…
OwenConoly Oct 2, 2024
68b8b54
all the variants of Fix_eq i could imagine wanting
OwenConoly Oct 2, 2024
04256d8
prove DCE leakage fixpoint equation
OwenConoly Oct 7, 2024
08f64db
write DCE proof with leakage (it works now, since leakage function is…
OwenConoly Oct 19, 2024
37cc6df
start adapting spilling phase to leakage
OwenConoly Oct 26, 2024
d4034b0
fix align_trace tactic and move it to LeakageSemantics
OwenConoly Oct 26, 2024
f630db2
finish adapting spilling proof to leakage traces
OwenConoly Oct 28, 2024
0e371a9
switch from mit-plv riscv-coq to my fork, and then to the leakage tra…
OwenConoly Oct 29, 2024
93680e0
adapt FlattenExpr to leakage traces
OwenConoly Oct 29, 2024
477301b
add leakage traces to GoFlatToRiscv
OwenConoly Oct 29, 2024
44448b0
add leakage traces to ForeverSafe, RunInstruction
OwenConoly Oct 29, 2024
99133e2
add leakage to RiscvEventLoop
OwenConoly Oct 29, 2024
3d44761
start on FlatToRiscvCommon
OwenConoly Oct 29, 2024
9ff2e39
add leakage transformation function for FlatToRiscv.
OwenConoly Oct 29, 2024
ed564c6
rewrite leakage functions in FlatToRiscvDef to return list LeakageEvent
OwenConoly Oct 30, 2024
9fe5eff
add leakage traces to FlatToRiscvCommon
OwenConoly Oct 30, 2024
9eccddb
add leakage to FlatToRiscvLiterals
OwenConoly Oct 30, 2024
d26160c
add leakage to load_save_regs_correct
OwenConoly Oct 30, 2024
289394d
add leakage traces to FlatToRiscvFunctions
OwenConoly Nov 12, 2024
e18a7f2
leakage in UseImmediate
OwenConoly Nov 12, 2024
350dff3
leakage in regalloc
OwenConoly Nov 12, 2024
a5c185d
add leakage to lower pipeline
OwenConoly Nov 13, 2024
e119bf4
some pipeline
OwenConoly Nov 13, 2024
e4eb150
get to dce_correct in pipeline...
OwenConoly Nov 13, 2024
2bc2b13
composed_compiler_correct
OwenConoly Nov 13, 2024
ad0d845
compiler_correct
OwenConoly Nov 13, 2024
d0104d2
memequal source level leakage prooof
OwenConoly Nov 13, 2024
91b24cd
hacky compiler_correct_wp
OwenConoly Nov 13, 2024
f942a84
MMIO compiler stuff
OwenConoly Nov 13, 2024
d08e20b
add memequal compiler example
OwenConoly Nov 13, 2024
9f08fd8
add ct.v
OwenConoly Nov 15, 2024
c46659d
clean up most of pipeline.v
OwenConoly Dec 17, 2024
3a95c81
get rid of WeakenCall in Pipeline; use func/prop ext instead
OwenConoly Dec 17, 2024
26b2c41
more cleaning up pipeline. up to spilling_correct
OwenConoly Dec 17, 2024
8bd27c3
trying riscv_phase_correct
OwenConoly Dec 17, 2024
10d67f7
hooray Pipeline compiles now
OwenConoly Dec 19, 2024
3f3db1c
remove test_itauto (sam says it is not needed anymore)
OwenConoly Dec 19, 2024
b3fc55c
get rid of option_map lemmas
OwenConoly Dec 19, 2024
44265eb
FE310 leakage comment
OwenConoly Dec 19, 2024
bb9ab6c
make some fixpoints local
OwenConoly Dec 19, 2024
9de1beb
make ct.v use FE310CSemantics instead of BasicC32Semantics
OwenConoly Dec 19, 2024
5cb3ee0
revert BasicC32Semantics to have no leakage traces
OwenConoly Dec 19, 2024
0f3c7b7
make leakage straightline work way better
OwenConoly Dec 19, 2024
b266837
fix straightline in a different way (still using letexists instead of…
OwenConoly Dec 19, 2024
073d181
improve leakage straightline.
OwenConoly Dec 20, 2024
8f74745
fnspec notations
OwenConoly Dec 20, 2024
dc7a6be
add fnspec_ex! notations for specifying constant-time
OwenConoly Dec 20, 2024
9b5bab5
work on bedrock2Examples involving leakage (including using the
OwenConoly Dec 20, 2024
2dc013b
make fnspec! exists notation more intuitive
OwenConoly Dec 20, 2024
bbfe067
fix kyberslash proof
OwenConoly Jan 2, 2025
f6526fe
work on swap and stackalloc
OwenConoly Jan 2, 2025
4e9c3a9
trying to fix function calls and things... swap_swap proof mysterious…
OwenConoly Jan 3, 2025
5a8a974
fix mysterious problem with swap_swap---special_intro was unfolding t…
OwenConoly Jan 5, 2025
2d249fb
change proofs to deal with "enter" in straightline working properly
OwenConoly Jan 5, 2025
fac42da
fix enter better this time
OwenConoly Jan 5, 2025
9bb6d06
work on top level loop
OwenConoly Jan 5, 2025
34373d4
fix event loop
OwenConoly Jan 6, 2025
463eef2
add leakage stuff to memory_mapped_ext_calls_compiler.v
OwenConoly Jan 6, 2025
d4fca34
make "make" work in compiler subdirectory
OwenConoly Jan 6, 2025
5f974ea
fix KamiRiscvStep (it broke because leakage stuff was added to run1)
OwenConoly Jan 7, 2025
46f2f3b
make end2endpipeline go through... can't get end2endlightbulb to work,
OwenConoly Jan 9, 2025
bbac468
add non-leakage ext_specs to FE310CSemantics and memory_mapped_ext_spec
OwenConoly Jan 9, 2025
7d40f6c
make end2end compile
OwenConoly Jan 9, 2025
8f1f5ee
various cleanup: typos, whitespace, comments, etc
OwenConoly Jan 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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "deps/riscv-coq"]
path = deps/riscv-coq
url = https://github.com/mit-plv/riscv-coq.git
url = https://github.com/OwenConoly/riscv-coq.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This git-config change should not be merged, instead the relevant riscv-coq changes should be merged to its upstream.

[submodule "deps/coqutil"]
path = deps/coqutil
url = https://github.com/mit-plv/coqutil.git
Expand Down
24 changes: 16 additions & 8 deletions bedrock2/src/bedrock2/FE310CSemantics.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.ZArith.ZArith.
Require Import bedrock2.Syntax bedrock2.Semantics.
Require Import bedrock2.Syntax bedrock2.Semantics bedrock2.LeakageSemantics bedrock2.MetricLeakageSemantics.
Require coqutil.Datatypes.String coqutil.Map.SortedList coqutil.Map.SortedListString.
Require Import coqutil.Word.Interface.
Require Export coqutil.Word.Bitwidth32.
Expand Down Expand Up @@ -27,24 +27,25 @@ Section WithParameters.
Definition isMMIOAligned (n : nat) (addr : word) :=
n = 4%nat /\ word.unsigned addr mod 4 = 0.

Global Instance ext_spec: ExtSpec :=
fun (t : trace) (mGive : mem) a (args: list word) (post: mem -> list word -> Prop) =>
(* FE310 is a simple enough processor that our leakage assumptions are likely to hold. There is no official documentation of whether multiply always takes the maximum time or not, but both https://eprint.iacr.org/2019/794.pdf and https://pure.tue.nl/ws/portalfiles/portal/169647601/Berg_S._ES_CSE.pdf quote a fixed number of cycles for FE310 multiplication in the context of cryptography. *)
Global Instance leakage_ext_spec: LeakageSemantics.ExtSpec :=
fun (t : trace) (mGive : mem) a (args: list word) (post: mem -> list word -> list word -> Prop) =>
if String.eqb "MMIOWRITE" a then
exists addr val,
args = [addr; val] /\
(mGive = Interface.map.empty /\ isMMIOAddr addr /\ word.unsigned addr mod 4 = 0) /\
post Interface.map.empty nil
post Interface.map.empty nil [addr]
else if String.eqb "MMIOREAD" a then
exists addr,
args = [addr] /\
(mGive = Interface.map.empty /\ isMMIOAddr addr /\ word.unsigned addr mod 4 = 0) /\
forall val, post Interface.map.empty [val]
forall val, post Interface.map.empty [val] [addr]
else False.

Global Instance ext_spec_ok : ext_spec.ok ext_spec.
Global Instance leakage_ext_spec_ok : ext_spec.ok leakage_ext_spec.
Proof.
split;
cbv [ext_spec Morphisms.Proper Morphisms.respectful Morphisms.pointwise_relation Basics.impl];
cbv [leakage_ext_spec Morphisms.Proper Morphisms.respectful Morphisms.pointwise_relation Basics.impl];
intros.
all :
repeat match goal with
Expand All @@ -53,9 +54,16 @@ Section WithParameters.
| H: exists _, _ |- _ => destruct H
| H: _ /\ _ |- _ => destruct H
| H: False |- _ => destruct H
end; subst; eauto 8 using Properties.map.same_domain_refl.
end; subst;
repeat match goal with
| H: _ :: _ = _ :: _ |- _ => injection H; intros; subst; clear H
end;
eauto 8 using Properties.map.same_domain_refl.
Qed.

Global Instance ext_spec : Semantics.ExtSpec := deleakaged_ext_spec.
Global Instance ext_spec_ok : Semantics.ext_spec.ok ext_spec := deleakaged_ext_spec_ok.

Global Instance locals: Interface.map.map String.string word := SortedListString.map _.
Global Instance env: Interface.map.map String.string (list String.string * list String.string * cmd) :=
SortedListString.map _.
Expand Down
Loading