-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathexample_aesScriptTodo.sml
65 lines (53 loc) · 2.11 KB
/
example_aesScriptTodo.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(*
This is a simple example of applying the translator to AES.
*)
open HolKernel bossLib Theory Parse Tactic boolLib Lib;
val _ = new_theory "example_aes";
open wordsTheory wordsLib arithmeticTheory listTheory aesTheory;
open ml_translatorTheory ml_translatorLib word_preludeTheory;
val _ = translation_extends "word_prelude";
(* translations *)
fun find_def tm = let
val thy = #Thy (dest_thy_const tm)
val name = #Name (dest_thy_const tm)
in fetch thy (name ^ "_def") handle HOL_ERR _ =>
fetch thy (name ^ "_DEF") handle HOL_ERR _ =>
fetch thy (name)
end
(* AES *)
val AES_def = save_thm("AES_def", AES_def);
val AES_CORRECT = save_thm("AES_CORRECT",AES_CORRECT);
val res = translate (find_def ``Sbox``);
val res = translate (find_def ``InvSbox``);
val Sbox_side = Q.prove(
`!x. sbox_side x = T`,
EVAL_TAC THEN MP_TAC (INST_TYPE [alpha|->``:8``] w2n_lt) THEN SRW_TAC [] [])
|> update_precondition;
val InvSbox_side = Q.prove(
`!x. invsbox_side x = T`,
EVAL_TAC THEN MP_TAC (INST_TYPE [alpha|->``:8``] w2n_lt) THEN SRW_TAC [] [])
|> update_precondition;
val res = translate (find_def ``genSubBytes``)
val res = translate (find_def ``SubBytes``)
val res = translate (find_def ``ShiftRows``)
val res = translate (find_def ``XOR_BLOCK``)
val res = translate (find_def ``AddRoundKey``)
val res = translate (find_def ``genMixColumns``)
val res = translate MultTheory.xtime_def
val res = translate MultTheory.ConstMult_def
val res = translate (find_def ``MultCol``)
val res = translate (find_def ``MixColumns``)
val res = translate aesTheory.ROTKEYS_def
val res = translate aesTheory.RoundTuple_def
val res = translate aesTheory.Round_def
val res = translate (find_def ``from_state``)
val res = translate (find_def ``to_state``)
val res = translate (find_def ``InvMultCol``)
val res = translate (find_def ``InvMixColumns``)
val res = translate (find_def ``InvShiftRows``)
val res = translate (find_def ``InvSubBytes``)
val res = translate aesTheory.InvRoundTuple_def
val res = translate aesTheory.InvRound_def
val res = translate (find_def ``AES_FWD``)
val res = translate (find_def ``AES_BWD``)
val _ = export_theory ();