Debian Codegraph @

crt/s2n/tests/saw/Makefile

raw symbols SCIP
1 #####################
2 # Copyright 2016 Galois, Inc. All Rights Reserved
3 #
4 # Authors:
5 # Joey Dodds : [email protected]
6 # Nathan Collins : [email protected]
7 #
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 #The scripts are all of the saw files in this directory
22 SCRIPTS = $(wildcard *.saw)
23 #A log file will be created for each test in the temp dir
24 LOGS=$(patsubst %.saw,tmp/%.log,$(SCRIPTS))
25 SHELL:=/bin/bash
26 YICES_VERSION=$(shell yices-smt2 --version)
27 export LIBCRYPTO_ROOT:=$(shell pwd)/../../libcrypto-root
28
29 .PHONY : all
30 all:
31 @echo "Running formal verification with ${YICES_VERSION}"
32 @${MAKE} clean-logs
33 @${MAKE} clean_the_dir
34 @${MAKE} $(LOGS)
35 @${MAKE} failure-tests
36
37
38 ############################################
39 ## Clean targets
40 ############################################
41 .PHONY : clean-logs
42 clean-logs :
43 $(RM) -- $(wildcard tmp/*.log)
44
45 .PHONY : clean-bitcode
46 clean-bitcode :
47 $(RM) -- bitcode/all_llvm.bc
48
49 .PHONY : clean-failure-logs
50 clean-failure-logs :
51 $(RM) -- $(wildcard failure_tests/*.log)
52
53 .PHONY: clean
54 clean: decruft
55
56 .PHONY: decruft
57 decruft : clean-logs
58 ${MAKE} -C bitcode decruft
59 ${RM} -r s2n
60 ${RM} -r tmp
61
62 clean_the_dir :
63 ${RM} -r s2n
64 ${RM} -r tmp
65 ${RM} -r failure_tests/*.log
66 ${RM} -r bitcode/*.bc
67
68 ###########################################
69 ## Script Tests
70 ###########################################
71
72 # To make a log we need the corresponding saw file, the all_llvm file, and a temp directory
73 # The pipefail command causes the entire command to fail if saw fails, even though we pipe it to tee
74 # without it we would see only the tee return code
75 tmp/%.log : %.saw bitcode/all_llvm.bc tmp
76 @echo "Running formal verification with ${YICES_VERSION}"
77 @echo "Running formal verification with SAW version:"
78 @saw --version
79 set -o pipefail; \
80 saw $< | tee $@
81
82 ###########################################
83 ## Failure Tests
84 ##
85 ## where we patch the code and make sure
86 ## that our proofs fail when it is patched
87 ## with errors
88 ###########################################
89
90 #These won't work in parallel, so we just hard code them,
91 #Otherwise we'd have to make a separate patched folder for each one
92 .PHONY : failure-tests
93 failure-tests : bitcode
94 @${MAKE} clean-failure-logs
95 @${MAKE} failure_tests/tls_early_ccs.log
96 @${MAKE} failure_tests/tls_missing_full_handshake.log
97 @${MAKE} failure_tests/sha_bad_magic_mod.log
98 @${MAKE} failure_tests/cork_one.log
99 @${MAKE} failure_tests/cork_two.log
100
101 #The bitcode files don't get deleted, in case we want to do tests on them
102 .SECONDARY : $(wildcard bitcode/*.bc)
103
104 # We're just making separate prefix targets for each saw script we want to do
105 # negative tests on
106 failure_tests/sha_%.log : bitcode/sha_%.bc
107 #this might not be necessary
108 cp $< bitcode/all_llvm.bc
109 set -o pipefail; \
110 ! (saw verify_HMAC.saw 2>&1 | tee $@)
111 grep "error: in _SAW_verify_prestate" $@
112
113 failure_tests/tls_%.log : bitcode/tls_%.bc
114 #this might not be necessary
115 cp $< bitcode/all_llvm.bc
116 set -o pipefail; \
117 ! (saw verify_state_machine.saw 2>&1 | tee $@)
118 grep "error: in _SAW_verify_prestate" $@
119
120 failure_tests/cork_%.log : bitcode/cork_%.bc
121 #this might not be necessary
122 cp $< bitcode/all_llvm.bc
123 set -o pipefail; \
124 ! (saw verify_cork_uncork.saw 2>&1 | tee $@)
125 grep "error: in llvm_ghost_value" $@
126
127
128 # we patch the s2n dir, build it with the top level s2n makefile, and
129 # move the resulting, patched and linked llvm bitcode into our bitcode directory
130 bitcode/%.bc : failure_tests/%.patch
131 patch -p1 -d s2n -i ../$<
132 ${MAKE} -C s2n bc; \
133 ${MAKE} bitcode/all_llvm.bc; \
134 status=$$?; \
135 cp bitcode/all_llvm.bc $@
136 patch -R -p1 -d s2n -i ../$<; \
137 exit $$status
138
139 #if we ask this makefile to create bitcode it will always completely rebuild it
140 .PHONY : bitcode
141 bitcode :
142 ${MAKE} clean_the_dir
143 ${MAKE} bitcode/all_llvm.bc
144
145 ########################################################
146 ## Rules to copy the s2n directory for patching and bulding
147 ########################################################
148
149 CRYPTO_C = $(wildcard ../../crypto/*.c) $(wildcard ../../crypto/*.h) ../../crypto/Makefile
150 CRYPTO_COPY = $(addprefix s2n/crypto/, $(notdir $(CRYPTO_C)))
151
152 UTILS_C = $(wildcard ../../utils/*.c) $(wildcard ../../utils/*.h) ../../utils/Makefile
153 UTILS_COPY =$(addprefix s2n/utils/, $(notdir $(UTILS_C)))
154
155 TLS_C = $(wildcard ../../tls/*.c ../../tls/*/*.c ../../tls/*.h ../../tls/*/*.h ../../tls/*/Makefile) ../../tls/Makefile
156 TLS_COPY = $(subst ../../tls/, s2n/tls/, $(TLS_C))
157 TLS_DIRS = $(sort $(dir $(TLS_COPY)))
158
159 STUFFER_C = $(wildcard ../../stuffer/*.c) $(wildcard ../../stuffer/*.h) ../../stuffer/Makefile
160 STUFFER_COPY =$(addprefix s2n/stuffer/, $(notdir $(STUFFER_C)))
161
162 API_COPY = $(subst ../../api, s2n/api, $(wildcard ../../api/*.h ../../api/*/*.h))
163 API_DIRS = $(sort $(dir $(API_COPY)))
164
165 ERROR_C = $(wildcard ../../error/*.c) $(wildcard ../../error/*.h) ../../error/Makefile
166 ERROR_COPY = $(addprefix s2n/error/, $(notdir $(ERROR_C)))
167
168 LIB_COPY = s2n/lib/Makefile
169
170 s2n/error :
171 mkdir -p $@
172
173 s2n/api :
174 mkdir -p $(API_DIRS)
175
176 s2n/crypto :
177 mkdir -p $@
178
179 s2n/utils :
180 mkdir -p $@
181
182 s2n/tls :
183 mkdir -p $(TLS_DIRS)
184
185 s2n/stuffer :
186 mkdir -p $@
187
188 s2n/lib :
189 mkdir -p $@
190
191 export BITCODE_DIR := $(CURDIR)/bitcode/
192
193 tmp:
194 mkdir -p tmp
195
196 bitcode/all_llvm.bc : s2n/crypto s2n/utils s2n/tls s2n/api s2n/error s2n/stuffer s2n/Makefile s2n/s2n.mk $(CRYPTO_COPY) $(PQ_CRYPTO_COPY) $(UTILS_COPY) $(TLS_COPY) $(API_COPY) $(ERROR_COPY) $(STUFFER_COPY)
197 ${MAKE} -C s2n bc
198 ${MAKE} -C bitcode all_llvm.bc
199
200
201 s2n/lib/libs2n.so : s2n/crypto s2n/utils s2n/tls s2n/api s2n/error s2n/stuffer s2n/lib s2n/Makefile s2n/s2n.mk $(CRYPTO_COPY) $(UTILS_COPY) $(TLS_COPY) $(API_COPY) $(ERROR_COPY) $(STUFFER_COPY) $(LIB_COPY)
202 ${MAKE} -C s2n libs NO_STACK_PROTECTOR=1 NO_INLINE=1
203
204 s2n/%.h : ../../%.h
205 cp $< $@
206
207 s2n/%.c : ../../%.c
208 cp $< $@
209
210 s2n/%.S : ../../%.S
211 cp $< $@
212
213 s2n/%Makefile : ../../%Makefile
214 cp $< $@
215
216 s2n/Makefile : ../../Makefile
217 cp $< $@
218
219 s2n/s2n.mk : ../../s2n.mk
220 cp $< $@