-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.bash
executable file
·130 lines (114 loc) · 3.84 KB
/
run.bash
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# This is to let the script abort if any command fails.
set -e
# Assumptions of this script:
# - an environment variable CRYPTOVERIF is defined and points to the
# directory where the CryptoVerif folder is located. This is the
# folder that contains for example the file `build`, and after
# building CryptoVerif, the file `default.ocvl`
# If you do not have the environment variable CRYPTOVERIF defined,
# you can also uncomment the following line and adapt the path
# accordingly:
#CRYPTOVERIF=~/CryptoVerif
# Define some paths
CV=${CRYPTOVERIF}/cryptoverif
STDLIB=${CRYPTOVERIF}/default.ocvl
LIB=lib.ocvl
OUT=out
# Usually no need to modify something after this line.
file_exists_or_abort()
{
filename=$1
if [ ! -f $filename ]
then
echo "File '$filename' not found. Did you execute this script in the directory in which it's stored?"
exit 2
fi
}
file_exists_or_abort lib.truncate.ocvl
file_exists_or_abort lib.option.ocvl
file_exists_or_abort lib.choice.ocvl
file_exists_or_abort lib.gdh.ocvl
file_exists_or_abort lib.authkem.ocvl
file_exists_or_abort lib.aead.ocvl
file_exists_or_abort lib.prf.ocvl
# Check presence of standard library
if [[ -f ${STDLIB} ]]; then
echo "Found the CryptoVerif standard library at ${STDLIB}."
cat ${STDLIB} lib.truncate.ocvl lib.option.ocvl lib.choice.ocvl lib.gdh.ocvl lib.authkem.ocvl lib.aead.ocvl lib.prf.ocvl > ${LIB}
else
echo "I don't seem to find the CryptoVerif standard library at"
echo "${STDLIB}"
echo "Please set the CRYPTOVERIF environment variable correctly,"
echo "or set the CRYPTOVERIF variable by editing this script."
exit 1
fi
# Check presence of CryptoVerif binary.
if [[ -f ${CV} ]]; then
echo "Found the CryptoVerif binary at ${CV}."
else
echo "I don't seem to find the CryptoVerif binary at"
echo "${CV}"
echo "Please set the CRYPTOVERIF environment variable correctly,"
echo "or set the CRYPTOVERIF variable by editing this script."
echo "Please verify that you ran the build script to compile CryptoVerif."
exit 1
fi
if [[ -d ${OUT} ]]; then
echo "Intermediate games output will be stored in ${OUT}."
else
if [[ -f ${OUT} ]]; then
echo "Expected ${OUT} to be a directory for intermediate games output,"
echo "but it appears to be a file. Please change the OUT variable in"
echo "this script or remove the file."
exit 1
fi
mkdir -p ${OUT}
echo "Intermediate games output will be stored in newly created directory ${OUT}."
fi
function prove() {
MODEL="$1"
CVFILE="${MODEL}.ocv"
if [[ -f ${CVFILE} ]]; then
echo "Running CryptoVerif on ${CVFILE}"
set +e # we want to treat failures of CryptoVerif
eval "${CV} -lib ${LIB} -oproof ${MODEL}.proof -o ${OUT} ${CVFILE} > ${MODEL}.out"
RESULT=$? # get the return code of CryptoVerif
if [[ "$RESULT" -eq "0" ]]; then
tail -n 2 ${MODEL}.out
# return code 0 does not necessarily mean that the proof
# succeeded, so the following grep might return 0 lines
grep "RESULT Proved" ${MODEL}.proof
else
echo "CryptoVerif terminated with an error:"
tail -n 5 ${MODEL}.out
fi
set -e # go back to exit-on-error mode
else
echo "I don't seem to find ${CVFILE}, skipping this proof."
fi
}
function generate_and_prove() {
MODEL="$1"
M4FILE="${MODEL}.m4.ocv"
CVFILE="${MODEL}.ocv"
echo ""
if [[ -f ${M4FILE} ]]; then
echo "Generating CryptoVerif model"
m4 ${M4FILE} > ${CVFILE}
prove ${MODEL}
else
echo "I don't seem to find ${M4FILE}, skipping this proof."
fi
}
# Run DHKEM proofs.
for NOTION in outsider-cca outsider-auth insider-cca; do
generate_and_prove "dhkem.auth.${NOTION}-lr"
done
echo ""
# Run KeySchedule proof in standard model for KeySchedule_auth.
prove "keyschedule.auth.prf"
# Run composition proofs.
for NOTION in outsider-cca outsider-auth insider-cca; do
generate_and_prove "hpke.auth.${NOTION}"
done