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

Use sha2-mb-scalar for sha2-streaming #670

Merged
merged 47 commits into from
Nov 14, 2022
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
81232d7
wip
msprotz Nov 2, 2022
d2ae284
sha2-mb: use `max_input_length` instead of `max_size_t` in spec
polubelova Nov 2, 2022
4c45019
lib: relax limit size for `multiseq`
polubelova Nov 2, 2022
f981ca4
sha2-mb: update low-star code, it still uses `max_size_t`
polubelova Nov 2, 2022
2ddaf59
Merge remote-tracking branch 'origin/marina_sha2mb' into protz_sha2mb…
msprotz Nov 2, 2022
f001444
Relax length restriction
msprotz Nov 2, 2022
714e032
wip
msprotz Nov 2, 2022
0c58bd1
Type-checks, but does not verify
msprotz Nov 2, 2022
ecf0cfa
Killed one admit
msprotz Nov 2, 2022
93ec3bf
wip
msprotz Nov 2, 2022
a0e5c0c
Kill some assumes...
msprotz Nov 2, 2022
4c21096
Down to four admits
msprotz Nov 2, 2022
a2b1bbf
Get some proofs working
R1kM Nov 2, 2022
d3e54ab
Hoist lemma statement
msprotz Nov 2, 2022
9094b9a
Merge branch 'protz_sha2mb_streaming' of pro.github.com:project-evere…
msprotz Nov 2, 2022
0df7104
Hoist second lemma
msprotz Nov 2, 2022
1117b58
wip
msprotz Nov 3, 2022
a831648
Almost complete proof for repeati_extensionality
R1kM Nov 3, 2022
927ff5c
dist refresh + noextract to workaround F* issues
msprotz Nov 3, 2022
be33e81
Merge branch 'protz_sha2mb_streaming' of pro.github.com:project-evere…
msprotz Nov 3, 2022
2027bb7
hints
msprotz Nov 3, 2022
07a1ac9
More progress, only missing extensionality of functions
R1kM Nov 3, 2022
78b8296
omg
msprotz Nov 3, 2022
68c8af7
zomg
msprotz Nov 3, 2022
e1ff516
fix mozilla
msprotz Nov 3, 2022
30159ac
missing files
msprotz Nov 3, 2022
4d80e03
wip
polubelova Nov 4, 2022
6421b19
SHA2-224 too
msprotz Nov 4, 2022
1c0261f
Merge branch 'marina_sha2mb_tmp' into protz_sha2mb_streaming
R1kM Nov 4, 2022
1e3fae6
More wip
R1kM Nov 4, 2022
7907b96
More progress in proof
R1kM Nov 4, 2022
dae0ef3
More wip
R1kM Nov 4, 2022
bae93a9
Finish proof
R1kM Nov 4, 2022
f227e94
Merge branch 'main' into protz_sha2mb_streaming
msprotz Nov 4, 2022
abcfba9
hints
msprotz Nov 4, 2022
08222b1
Do SHA2-384/512 and refresh dist
msprotz Nov 4, 2022
d7630a5
Merge remote-tracking branch 'origin/main' into protz_sha2mb_streaming
polubelova Nov 7, 2022
047718a
Prevent excessive inlining
msprotz Nov 7, 2022
5a802c7
Merge remote-tracking branch 'refs/remotes/origin/protz_sha2mb_stream…
msprotz Nov 7, 2022
f24d064
FOrgot to commit Makefile
msprotz Nov 7, 2022
1ddc533
Restructure the code per Marina's suggestion
msprotz Nov 11, 2022
f75ce70
Missing file
msprotz Nov 11, 2022
dae1be0
test
msprotz Nov 11, 2022
2b72aed
Merge branch 'main' into protz_sha2mb_streaming
msprotz Nov 11, 2022
d68d186
Merge remote-tracking branch 'origin/main' into protz_sha2mb_streaming
msprotz Nov 11, 2022
8dcad76
Fix mozilla
msprotz Nov 11, 2022
2d9f507
Merge branch 'protz_sha2mb_streaming' of pro.github.com:project-evere…
msprotz Nov 11, 2022
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
msprotz committed Nov 3, 2022
commit 1117b585d99c3f39fc50b7310f6b1972fa80d424
36 changes: 33 additions & 3 deletions code/streaming/Hacl.Streaming.MD.fst
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ let update_multi_associative (a : alg) () acc (prevlen1 prevlen2 : nat)
Spec.Hash.Lemmas.update_multi_associative a (acc, ()) input1 input2
#pop-options

noextract
let repeati_associative (a : alg { is_mb a }) acc (input1 input2 : S.seq uint8) :
let repeati_associative (a : alg { is_mb a })
(acc: Hacl.Spec.SHA2.Vec.(state_spec a M32))
(input1 input2 : S.seq uint8) :
Lemma
(requires (
S.length input1 + S.length input2 <= Some?.v (Spec.Agile.Hash.max_input_length a) /\
Expand All @@ -262,6 +263,35 @@ let repeati_associative (a : alg { is_mb a }) acc (input1 input2 : S.seq uint8)
update_nblocks #a #M32 (S.length input2) (input2 <: multiseq 1 (S.length input2))
(update_nblocks #a #M32 (S.length input1) (input1 <: multiseq 1 (S.length input1)) acc)))
=
let open Hacl.Spec.SHA2.Vec in
let input = S.append input1 input2 in
FStar.Math.Lemmas.lemma_mod_plus_distr_l (S.length input1) (S.length input2) (Spec.Agile.Hash.block_length a);
assert (S.length input % U32.v (D.block_len a) = 0);

let open Lib.LoopCombinators in
let len = S.length input in
let n_blocks = len / block_length a in
let len1 = S.length input1 in
let n_blocks1 = len1 / block_length a in
let len2 = S.length input2 in
let n_blocks2 = len2 / block_length a in
let input = input <: multiseq 1 (S.length input) in
assert (n_blocks = n_blocks1 + n_blocks2);
calc (==) {
update_nblocks #a #M32 (S.length input) (input <: multiseq 1 (S.length input)) acc;
(==) { (* def *) } (
repeati n_blocks (update_block #a #M32 len input) acc
);
(==) { repeati_def n_blocks (update_block #a #M32 len input) acc } (
repeat_right 0 n_blocks (fixed_a (state_spec a M32)) (update_block #a #M32 len input) acc
);
// Typing error on n_blocks. Need to do a case analysis on whether input2 is
// empty or not. Use eq_repeati0 for that case where the sequence is empty.
(*(==) { repeat_right_plus 0 len1 n_blocks (fixed_a (state_spec a M32)) (update_block #a #M32 len input) acc } (
repeat_right (len1 + 1) n_blocks (fixed_a (state_spec a M32)) (update_block #a #M32 len input)
(repeat_right 0 len1 (fixed_a (state_spec a M32)) (update_block #a #M32 len input) acc)
);*)
};
admit ()

let sha2_mb_is_incremental (a: alg { is_mb a }) (input: S.seq uint8):
Expand All @@ -277,9 +307,9 @@ let sha2_mb_is_incremental (a: alg { is_mb a }) (input: S.seq uint8):
let hash3 = finish hash2 in
agile_of_lib hash3 `S.equal` Spec.Agile.Hash.hash a input))
=
Hacl.Spec.SHA2.EquivScalar.hash_agile_lemma #a (S.length input) input;
admit ()


let live_multi_of_live #len (h:HS.mem) (b:Lib.MultiBuffer.multibuf 1 len): Lemma
(requires (
B.live h (buffer_of_lib #len b)))
Expand Down