Debian Codegraph @

crt/s2n/tests/saw/HMAC/spec/HMAC_append_correct.saw

raw
1 ////////////////////////////////////////////////////////////////
2 // Copyright 2016 Galois, Inc. All Rights Reserved
3 //
4 // Authors:
5 // Aaron Tomb : [email protected]
6 // Nathan Collins : [email protected]
7 // Joey Dodds : [email protected]
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License").
10 // You may not use this file except in compliance with the License.
11 // A copy of the License is located at
12 //
13 // http://aws.amazon.com/apache2.0
14 //
15 // or in the "license" file accompanying this file. This file is distributed
16 // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
17 // express or implied. See the License for the specific language governing
18 // permissions and limitations under the License.
19 //
20 ////////////////////////////////////////////////////////////////
21
22 import "HMAC_properties.cry";
23 import "modthm.cry";
24
25 let hash_lemma1 =
26 rewrite (cryptol_ss ()) (unfold_term ["hash_update_append"] {{ hash_update_append }});
27
28 let hash_lemma2 =
29 rewrite (cryptol_ss ()) (unfold_term ["hash_update_empty"] {{ hash_update_empty }});
30
31 let mod_lemma = rewrite (cryptol_ss ()) (unfold_term ["modthm"] {{ modthm }});
32
33 let tuple_lemma = rewrite (cryptol_ss ()) (unfold_term ["modthm"] {{ modthm }});
34
35 let tuple_lemma = rewrite (cryptol_ss ()) {{
36 \a1 b1 c1 d1 a2 b2 c2 d2 ->
37 ((a1,b1,c1,d1) == (a2,b2,c2,d2)) == (a1 == a2 /\ b1 == b2 /\ c1 == c2 /\ d1 == d2)
38 }};
39
40 let eq_lemma = rewrite (cryptol_ss ()) {{
41 \a -> (a == a) == True
42 }};
43
44 let and_true1 = rewrite (cryptol_ss ()) {{
45 \a -> (a /\ True) == a
46 }};
47
48 let and_true2 = rewrite (cryptol_ss ()) {{
49 \a -> (True /\ a) == a
50 }};
51
52 let {{
53 type_add_lemma : {a,b} (fin a, fin b, 32 >= width a, 32 >= width b, 32 >= width (a + b)) => Bit
54 type_add_lemma = (`(a + b) : [32]) == ((`b : [32]) + (`a : [32]))
55 }};
56
57 let type_add_lemma = rewrite (cryptol_ss()) (unfold_term ["type_add_lemma"] {{ type_add_lemma }});
58
59 and_true1_thm <- time (prove_print abc and_true1);
60 and_true2_thm <- time (prove_print abc and_true2);
61
62 time (prove_print (do {
63 unfolding ["hmac_update_append"];
64 unfolding ["hmac_update_c_state"];
65 simplify (cryptol_ss ());
66 simplify (addsimps' [hash_lemma1, mod_lemma, tuple_lemma, eq_lemma] empty_ss);
67 simplify (addsimps [and_true1_thm, and_true2_thm] empty_ss);
68 simplify (addsimps' [type_add_lemma] empty_ss);
69 simplify (add_prelude_eqs ["eq_refl"] empty_ss);
70 simplify (addsimps' [eq_lemma] empty_ss);
71 trivial;
72 }) {{ hmac_update_append }});
73
74 time (prove_print (do {
75 unfolding ["hmac_update_empty"];
76 unfolding ["hmac_update_c_state"];
77 simplify(cryptol_ss ());
78 simplify (addsimp' hash_lemma2 empty_ss);
79 unint_yices ["hash_update_c_state"];
80 }) {{ hmac_update_empty }});