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

Proofs of correctness of the TLS Handshake and corking state machine #565

Merged
merged 116 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
9c4e980
Change compiler flags to generate debug information in
achudnov Apr 4, 2017
619f4ba
First version of the cork/uncork correctness proof.
achudnov Apr 5, 2017
6d0e4a9
Preliminary integration of cork/uncork proofs
achudnov Apr 6, 2017
329f0b8
Temporarily disable optimizations when generating bitcodes for
achudnov Apr 6, 2017
047ae67
remove the cork-uncork proof&build scripts from top-level. They've be…
achudnov Apr 6, 2017
a900030
Cleaning up and adding comments to the cork/uncork model programs
achudnov Apr 13, 2017
8e6e963
Better name for the low-level model spec function. Documentation for
achudnov Apr 13, 2017
e64b4a8
More comments in the proof script
achudnov Apr 13, 2017
e329e15
Finish documenting the correctness property
achudnov Apr 19, 2017
6ae5161
Relax precondition, change the low-level spec to match the
achudnov May 10, 2017
1bc11c9
Added a proof with an expected failure that can serve as a negative
achudnov May 10, 2017
4e856ba
Draft of the handshake spec based on RFC 5246 and relation the the s2n
achudnov Jun 7, 2017
709250d
Fixed a typo and added more comments
achudnov Jun 7, 2017
7d7600b
Amended the state relation
achudnov Jun 7, 2017
ca0fd4c
Simulation relation property between a s2n-level and rfc-level
achudnov Jun 7, 2017
9b00504
Added the session ticket state machine per RFC 5077
achudnov Jun 12, 2017
cd1c1d4
Added handshake state machine simulation proof (WIP) to the saw-scrip…
achudnov Jun 12, 2017
0484223
Make the prover output more information
achudnov Jun 12, 2017
9503aad
Split the states to have a more precise state machine
achudnov Jun 12, 2017
3173efc
Added a predicate to tell if a connection value is valid
achudnov Jun 13, 2017
db15e72
Refactoring of the handshake state machine simulation relation encoding
achudnov Jun 13, 2017
f72afcc
Added state machine transitions for OCSP per RFC 6066
achudnov Jun 14, 2017
bdc3b8a
Reformulate the correspondence property to deal with existentially
achudnov Jun 20, 2017
9ed124c
Fix the correspondence to make the proof go through
achudnov Jun 20, 2017
aac8111
Use abc instead of z3.
achudnov Jun 20, 2017
be0571e
Refactored the RFC spec to be more readable
achudnov Jun 21, 2017
8b8706b
Additional comments
achudnov Jun 22, 2017
3c9244f
WIP porting cork-uncork proof to Crucible.
achudnov Jun 27, 2017
24cb883
Change bitcode build process to avoid instructions problematic for Cr…
achudnov Jun 27, 2017
0ad9452
Further build fixes to make the bitcode load in SAW
achudnov Jun 28, 2017
510b489
Split out the low-level specifications for s2n_handshake_io.c in a
achudnov Jun 28, 2017
f1f36c2
Working proof of correspondence between s2n_advance_message and its
achudnov Jun 28, 2017
1d8647d
Connected the low-level correspondence proof to the cork-uncork and
achudnov Jun 28, 2017
accfa4f
Advice SAW to use Yices for code correspondence proofs
achudnov Jun 28, 2017
a1fb113
Extra comments in the proof script
achudnov Jun 28, 2017
435e8de
added a spec for set_handshake_type
jldodds Jun 29, 2017
b1f2579
typechecking, but not yet run proof for extended handshake proof
jldodds Jul 6, 2017
1fb3e07
Resolve merge conflict with ghost corking state.
achudnov Jul 8, 2017
928c134
working proof of set_handshake_type
jldodds Jul 12, 2017
1c45912
makefile cleanup
jldodds Jul 14, 2017
488d225
Extended the high-level specification with transition predicates.
achudnov Jul 15, 2017
2690b15
makefile work
jldodds Jul 17, 2017
3dee208
patch for ccs failure, not working due to modified code in amazon repo
jldodds Jul 17, 2017
cde3190
Merge branch 'master' into handshake-verification
jldodds Jul 17, 2017
44d99bc
removed code update that has now been replaced with ghost code
jldodds Jul 17, 2017
bdda52e
Generating traces of message types for the low-level model of the S2N
achudnov Jul 18, 2017
b8717fd
Adapt the low-level correspondence SAW proof script to the new
achudnov Jul 18, 2017
98e0eae
WIP new simulation relation and proof for the handshake state machines
achudnov Jul 18, 2017
cd95c8e
Refactoring the simulation relation
achudnov Jul 18, 2017
f8f2f02
Normalization of message sequences after APPLICATION_DATA to help with
achudnov Jul 18, 2017
beb7030
Remove the corking state tracking instrumentation from socket
achudnov Jul 18, 2017
5b38745
Proposed fix for the handshake state machine in OCSP cases
achudnov Jul 18, 2017
d658713
Fix the high-low relation
achudnov Jul 18, 2017
1c63c11
WIP debugging low-level correspondence proof for handshake
achudnov Jul 18, 2017
0b925e5
More debug messages
achudnov Jul 18, 2017
b8a8207
brought proofs up to date with Amazon code
jldodds Jul 18, 2017
25a8832
merging the updated proofs for the tip of upstream
achudnov Jul 18, 2017
e24a912
Update the relation between 'connection' and 'Parameters' to reflect
achudnov Jul 18, 2017
2209830
Comment
achudnov Jul 18, 2017
866be8a
New state machine bug: missing SM branch for CLIENT_AUTH | OCSP | FUL…
achudnov Jul 18, 2017
911823f
Fix for the second state machine bug.
achudnov Jul 19, 2017
7472cec
Update the cork-uncork proof script
achudnov Jul 19, 2017
f948bf9
failure test now working
jldodds Jul 19, 2017
c51cb0c
ignore ll files in the bitcode directory
jldodds Jul 19, 2017
2f2cd9a
bring formatting in line with the formatting in the rest of the code
achudnov Jul 19, 2017
f57cfcc
Merge branch 'handshake-verification' of github.com:galoisInc/s2n int…
achudnov Jul 19, 2017
abd661e
Formatting (stray TAB).
achudnov Jul 19, 2017
eb05841
make the cork-uncork failure test pass
jldodds Jul 21, 2017
dbd3919
Merge branch 'handshake-verification' of github.com:GaloisInc/s2n int…
jldodds Jul 21, 2017
726f73a
WIP porting handshake proofs to use struct field names instead of ind…
achudnov Jul 21, 2017
5faf4f6
Merge branch 'master' into handshake-verification
achudnov Jul 22, 2017
a960b26
Field 3 of s2n_config should be ocsp_status
glguy Jul 25, 2017
8230acb
Merge branch 'field-names' into handshake-verification
achudnov Jul 26, 2017
598d516
clean up the proof script
achudnov Jul 26, 2017
786a2fd
increased the sequence length in the cork/uncork proof to 16
achudnov Jul 26, 2017
cdc844a
Richer formulation of the cork/uncork property.
achudnov Aug 1, 2017
61e931f
Debugging
achudnov Aug 1, 2017
851b4df
Merge branch 'feature/fips' of github.com:awslabs/s2n into merge-fips
jldodds Aug 1, 2017
a2a6373
Tighter cork/uncork spec and proof
achudnov Aug 1, 2017
93af2f4
Removing debug info
achudnov Aug 1, 2017
2925cb1
Renamed spec/s2n_advance_message.cry to spec/s2n_handshake_io.cry
achudnov Aug 1, 2017
0914799
Merge branch 'master' of github.com:galoisInc/s2n
achudnov Aug 1, 2017
bb434aa
another failure test case
jldodds Aug 1, 2017
5d8af77
Merge branch 'master' of github.com:awslabs/s2n into merge-master
jldodds Aug 2, 2017
30bb208
Merge branch 'master' into merge-fips
jldodds Aug 2, 2017
7c35292
Merge branch 'master' into merge-master
jldodds Aug 2, 2017
f5187b2
add back g option to makefile
jldodds Aug 2, 2017
b448da3
removed a negative test case that has been invalidated by
jldodds Aug 2, 2017
881e9df
fixed negative test cases
jldodds Aug 3, 2017
9ab2ba9
is g option causing travis problems
jldodds Aug 3, 2017
fe0b849
coq verification of cryptol HMAC equivalent to Appel's HMAC spec
sliverdragon37 Aug 3, 2017
8701eaa
print clang version on travis
jldodds Aug 3, 2017
34a9e14
try latest clang for md5
jldodds Aug 3, 2017
83537f8
put new clang on path
jldodds Aug 3, 2017
4ee05fb
print clang version after updating path
jldodds Aug 3, 2017
e0ecd34
try it with apt
jldodds Aug 3, 2017
b2237a4
typo
jldodds Aug 3, 2017
96ef9ee
another typo
jldodds Aug 3, 2017
90cc42e
fix the build
jldodds Aug 4, 2017
a6fbeb7
Merge remote-tracking branch 'origin/hmac_coq_verif'
jldodds Aug 4, 2017
2445b59
Merge branch 'merge-master'
jldodds Aug 4, 2017
1e6908e
Formatting and better comments for the TLS Handshake and corking
achudnov Aug 7, 2017
663f832
Merge branch 'master' of github.com:galoisInc/s2n
achudnov Aug 7, 2017
9d21607
Simplify the RFC-derived handshake specification: remove the
achudnov Aug 8, 2017
71e4ed6
Merge branch 'master' of https://github.com/awslabs/s2n
achudnov Aug 16, 2017
937a4b2
WIP adapting low-level spec to the changes in the code
achudnov Aug 16, 2017
2f9c90b
quick fix for recent update to s2n
jldodds Aug 22, 2017
91487eb
full proofs for updated handshake
jldodds Aug 23, 2017
b429c23
Merge branch 'master' of github.com:awslabs/s2n
jldodds Aug 23, 2017
56b2bc2
add saw tests back in to travis
jldodds Aug 23, 2017
e91b146
added FCF license
jldodds Aug 24, 2017
f6e65a6
added more information to the cryptol semantics hmac directory
jldodds Aug 24, 2017
3df1870
make README markdown
jldodds Aug 24, 2017
76b364a
readme fix
jldodds Aug 24, 2017
d81a9e4
updated fcf licencse
jldodds Aug 28, 2017
32d3c58
added back an allowed failure
jldodds Aug 28, 2017
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
58 changes: 31 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,47 @@ env:
- S2N_LIBCRYPTO=openssl-1.1.0 OPENSSL_ia32cap="~0x200000200000000" BUILD_S2N=true TESTS=integration GCC6_REQUIRED=true
- S2N_LIBCRYPTO=openssl-1.1.x-master BUILD_S2N=true TESTS=integration GCC6_REQUIRED=true
- S2N_LIBCRYPTO=openssl-1.1.0 LATEST_CLANG=true TESTS=fuzz
- TESTS=sawHMAC SAW_HMAC_TEST=md5 SAW=true GCC6_REQUIRED=false
- TESTS=sawHMAC SAW_HMAC_TEST=sha1 SAW=true GCC6_REQUIRED=false
- TESTS=sawHMAC SAW_HMAC_TEST=sha224 SAW=true GCC6_REQUIRED=false
- TESTS=sawHMAC SAW_HMAC_TEST=sha256 SAW=true GCC6_REQUIRED=false
- TESTS=sawHMAC SAW_HMAC_TEST=sha384 SAW=true GCC6_REQUIRED=false
- TESTS=sawHMAC SAW_HMAC_TEST=sha512 SAW=true GCC6_REQUIRED=false
- TESTS=sawDRBG SAW=true
- TESTS=sawHMACFailure SAW=true


matrix:
exclude:
- os: osx
env: TESTS=ctverif
- os: osx
env: TESTS=sawHMAC SAW_HMAC_TEST=md5 SAW=true GCC6_REQUIRED=false
- os: osx
env: TESTS=sawHMAC SAW_HMAC_TEST=sha1 SAW=true GCC6_REQUIRED=false
- os: osx
env: TESTS=sawHMAC SAW_HMAC_TEST=sha224 SAW=true GCC6_REQUIRED=false
- os: osx
env: TESTS=sawHMAC SAW_HMAC_TEST=sha256 SAW=true GCC6_REQUIRED=false
- os: osx
env: TESTS=sawHMAC SAW_HMAC_TEST=sha384 SAW=true GCC6_REQUIRED=false
- os: osx
env: TESTS=sawHMAC SAW_HMAC_TEST=sha512 SAW=true GCC6_REQUIRED=false
- os: osx
env: S2N_LIBCRYPTO=openssl-1.1.0 LATEST_CLANG=true TESTS=fuzz
- os: osx
env: TESTS=sawDRBG SAW=true GCC6_REQUIRED=false
- os: osx
env: TESTS=sawHMACFailure SAW=true
- os: osx
env: S2N_LIBCRYPTO=openssl-1.1.x-master BUILD_S2N=true TESTS=integration GCC6_REQUIRED=true
#This exception is because the test isn't finished yet, remove to turn on DRBG Saw tests
- env: TESTS=sawDRBG SAW=true
include:
- os : linux
env : TESTS=sawHMAC SAW_HMAC_TEST=md5 SAW=true GCC6_REQUIRED=false
addons: &sawaddons
apt:
packages:
- clang-3.8
- llvm-3.8
- os : linux
env : TESTS=sawHMAC SAW_HMAC_TEST=sha1 SAW=true GCC6_REQUIRED=false
addons : *sawaddons
- os : linux
env : TESTS=sawHMAC SAW_HMAC_TEST=sha224 SAW=true GCC6_REQUIRED=false
addons : *sawaddons
- os : linux
env : TESTS=sawHMAC SAW_HMAC_TEST=sha256 SAW=true GCC6_REQUIRED=false
addons : *sawaddons
- os : linux
env : TESTS=sawHMAC SAW_HMAC_TEST=sha384 SAW=true GCC6_REQUIRED=false
addons : *sawaddons
- os : linux
env : TESTS=sawHMAC SAW_HMAC_TEST=sha512 SAW=true GCC6_REQUIRED=false
addons : *sawaddons
- os : linux
env : TESTS=tls SAW=true GCC6_REQUIRED=false
addons : *sawaddons
- os : linux
env : TESTS=sawHMACFailure SAW=true
addons : *sawaddons
allow_failures:
- os: osx
- env: S2N_LIBCRYPTO=openssl-1.1.x-master BUILD_S2N=true TESTS=integration GCC6_REQUIRED=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should have been removed from the allowed_failures list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed and fixed. I got mixed up with the line in exclude on the merge.

As an additional note, I've switched over all of our runs to including the exact configuration rather than putting them on the matrix and then excluding the configurations I don't want. This should work for that configuration as well, to save a few lines of Travis configuration.

fast_finish: true

before_install:
Expand Down Expand Up @@ -131,5 +134,6 @@ script:
- if [[ "$TESTS" == "fuzz" ]]; then export PATH=$LATEST_CLANG_INSTALL_DIR/bin:$PATH && make clean && make fuzz ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$TESTS" == "sawHMAC" ]]; then make -C tests/saw/ tmp/verify_s2n_hmac_$SAW_HMAC_TEST.log ; fi
- if [[ "$TESTS" == "sawDRBG" ]]; then make -C tests/saw tmp/spec/DRBG/DRBG.log ; fi
- if [[ "$TESTS" == "tls" ]]; then make -C tests/saw tmp/handshake.log && make -C tests/saw tmp/cork-uncork.log ; fi
- if [[ "$TESTS" == "sawHMACFailure" ]]; then make -C tests/saw failure-tests ; fi
- if [[ "$TESTS" == "ctverif" ]]; then .travis/run_ctverif.sh $CTVERIF_INSTALL_DIR ; fi
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ bitcode :

.PHONY : bc
bc:
${MAKE} -C crypto bc
${MAKE} -C crypto bc
# ${MAKE} -C stuffer bc
${MAKE} -C tls bc
# ${MAKE} -C utils bc

.PHONY : saw
saw : bc
Expand Down
7 changes: 2 additions & 5 deletions crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ OBJS=$(SRCS:.c=.o)

BITCODE_DIR?=../tests/saw/bitcode/

BCS_1=s2n_hmac.bc s2n_drbg.bc
BCS_1=s2n_hash.bc s2n_hmac.bc s2n_drbg.bc
BCS=$(addprefix $(BITCODE_DIR), $(BCS_1))

.PHONY : all
all: $(OBJS)

.PHONY : bc
bc: $(BITCODE_DIR)all_llvm.bc

$(BITCODE_DIR)all_llvm.bc : $(BCS)
llvm-link -o $@ $+
bc: $(BCS)

include ../s2n.mk
6 changes: 4 additions & 2 deletions s2n.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ CRYPTO_LIBS = -lcrypto
CC := $(CROSS_COMPILE)$(CC)
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
CLANG ?= clang-3.8
LLVMLINK ?= llvm-link-3.8

SOURCES = $(wildcard *.c *.h)
CRUFT = $(wildcard *.c~ *.h~ *.c.BAK *.h.BAK *.o *.a *.so *.dylib *.bc)
Expand Down Expand Up @@ -66,10 +68,10 @@ ifeq ($(S2N_UNSAFE_FUZZING_MODE),1)
endif


CFLAGS_LLVM = ${DEFAULT_CFLAGS} -emit-llvm -c -O1
CFLAGS_LLVM = ${DEFAULT_CFLAGS} -emit-llvm -c -g -O1

$(BITCODE_DIR)%.bc: %.c
clang $(CFLAGS_LLVM) -o $@ $<
$(CLANG) $(CFLAGS_LLVM) -o $@ $<


INDENTOPTS = -npro -kr -i4 -ts4 -nut -sob -l180 -ss -ncs -cp1
Expand Down
7 changes: 7 additions & 0 deletions stuffer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
SRCS=$(wildcard *.c)
OBJS=$(SRCS:.c=.o)

BITCODE_DIR?=../tests/saw/bitcode/
BCS_1=$(SRCS:.c=.bc)
BCS=$(addprefix $(BITCODE_DIR), $(BCS_1))

.PHONY : all
all: $(OBJS)

.PHONY : bc
bc: $(BCS)

include ../s2n.mk
103 changes: 74 additions & 29 deletions tests/saw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# permissions and limitations under the License.
########################

#The scripts are all of the saw files in this directory
SCRIPTS = $(wildcard *.saw)
#A log file will be created for each test in the temp dir
LOGS=$(patsubst %.saw,tmp/%.log,$(SCRIPTS))
Expand All @@ -32,6 +33,10 @@ all:
@${MAKE} $(LOGS)
@${MAKE} failure-tests


############################################
## Clean targets
############################################
.PHONY : clean-logs
clean-logs :
$(RM) -- $(wildcard tmp/*.log)
Expand All @@ -44,13 +49,6 @@ clean-bitcode :
clean-failure-logs :
$(RM) -- $(wildcard failure_tests/*.log)


tmp/%.log : %.saw bitcode/all_llvm.bc tmp
@echo "Running formal verification with ${Z3_VERSION}"
@echo saw $<
@set -o pipefail; \
saw $< | tee $@

.PHONY: clean
clean: decruft

Expand All @@ -60,29 +58,73 @@ decruft : clean-logs
${RM} -r s2n
${RM} -r tmp

clean_the_dir :
${RM} -r s2n
${RM} -r tmp
${RM} -r failure_tests/*.log
${RM} -r bitcode/*.bc

FAILURE_PATCHES = $(wildcard failure_tests/*.patch)
FAILURE_LOGS = $(FAILURE_PATCHES:.patch=.log)
###########################################
## Script Tests
###########################################

# To make a log we need the corresponding saw file, the all_llvm file, and a temp directory
# The pipefail command causes the entire command to fail if saw fails, even though we pipe it to tee
# without it we would see only the tee return code
tmp/%.log : %.saw bitcode/all_llvm.bc tmp
@echo "Running formal verification with ${Z3_VERSION}"
@echo saw $<
@set -o pipefail; \
saw $< | tee $@


###########################################
## Failure Tests
##
## where we patch the code and make sure
## that our proofs fail when it is patched
## with errors
###########################################

#These won't work in parallel, so we just hard code them,
#Otherwise we'd have to make a separate patched folder for each one
.PHONY : failure-tests
failure-tests : bitcode
@${MAKE} clean-failure-logs
@${MAKE} failure_tests/bad_magic_mod.log
@${MAKE} failure_tests/msgchange.log
@${MAKE} failure_tests/tls_early_ccs.log
@${MAKE} failure_tests/tls_missing_full_handshake.log
@${MAKE} failure_tests/sha_bad_magic_mod.log
@${MAKE} failure_tests/cork_one.log
@${MAKE} failure_tests/cork_two.log

#@${MAKE} $(FAILURE_LOGS) commented for now because these can't happen in parallel

#The bitcode files don't get deleted, in case we want to do tests on them
.SECONDARY : $(wildcard btcode/*.bc)
.SECONDARY : $(wildcard bitcode/*.bc)

failure_tests/%.log : bitcode/%.bc
cp $< bitcode/all_llvm.bc
# We're just making separate prefix targets for each saw script we want to do
# negative tests on
failure_tests/sha_%.log : bitcode/sha_%.bc
#this might not be necessary
cp $< bitcode/all_llvm.bc
! saw verify_s2n_hmac_sha256.saw &> $@

#keeping track of the status to make sure that even if the make fails the patch still gets undone
failure_tests/tls_%.log : bitcode/tls_%.bc
#this might not be necessary
cp $< bitcode/all_llvm.bc
! saw handshake.saw &> $@

failure_tests/cork_%.log : bitcode/cork_%.bc
#this might not be necessary
cp $< bitcode/all_llvm.bc
! saw cork-uncork.saw &> $@


# we patch the s2n dir, build it with the top level s2n makefile, and
# move the resulting, patched and linked llvm bitcode into our bitcode directory
bitcode/%.bc : failure_tests/%.patch
patch -p1 -d s2n -i ../$<
${MAKE} -C s2n bc; \
${MAKE} bitcode/all_llvm.bc; \
status=$$?; \
cp bitcode/all_llvm.bc $@
patch -R -p1 -d s2n -i ../$<; \
Expand All @@ -94,18 +136,24 @@ bitcode :
${MAKE} clean_the_dir
${MAKE} bitcode/all_llvm.bc

clean_the_dir :
${RM} -r s2n
${RM} -r tmp
${RM} -r failure_tests/*.log
${RM} -r bitcode/*.bc


########################################################
## Rules to copy the s2n directory for patching and bulding
########################################################

CRYPTO_C = $(wildcard ../../crypto/*.c) $(wildcard ../../crypto/*.h) ../../crypto/Makefile
CRYPTO_COPY = $(addprefix s2n/crypto/, $(notdir $(CRYPTO_C)))

UTILS_COPY =$(addprefix s2n/utils/, $(notdir $(wildcard ../../utils/*.h)))
TLS_COPY =$(addprefix s2n/tls/, $(notdir $(wildcard ../../tls/*.h)))
STUFFER_COPY =$(addprefix s2n/stuffer/, $(notdir $(wildcard ../../stuffer/*.h)))
UTILS_C = $(wildcard ../../utils/*.c) $(wildcard ../../utils/*.h) ../../utils/Makefile
UTILS_COPY =$(addprefix s2n/utils/, $(notdir $(UTILS_C)))

TLS_C = $(wildcard ../../tls/*.c) $(wildcard ../../tls/*.h) ../../tls/Makefile
TLS_COPY =$(addprefix s2n/tls/, $(notdir $(TLS_C)))

STUFFER_C = $(wildcard ../../stuffer/*.c) $(wildcard ../../stuffer/*.h) ../../stuffer/Makefile
STUFFER_COPY =$(addprefix s2n/stuffer/, $(notdir $(STUFFER_C)))

API_COPY =$(addprefix s2n/api/, $(notdir $(wildcard ../../api/*.h)))
ERROR_COPY =$(addprefix s2n/error/, $(notdir $(wildcard ../../error/*.h)))

Expand All @@ -132,12 +180,9 @@ export BITCODE_DIR := $(CURDIR)/bitcode/
tmp:
mkdir -p tmp

tmp/IS_PATCHED : | tmp
if [ -f ../patch.patch ]; then patch -p1 -d s2n -i ../patch.patch; fi
touch $@

bitcode/all_llvm.bc : s2n/crypto s2n/utils s2n/stuffer s2n/tls s2n/api s2n/error s2n/Makefile s2n/s2n.mk $(CRYPTO_COPY) $(UTILS_COPY) $(TLS_COPY) $(STUFFER_COPY) $(API_COPY) $(ERROR_COPY)
bitcode/all_llvm.bc : s2n/crypto s2n/utils s2n/tls s2n/api s2n/error s2n/stuffer s2n/Makefile s2n/s2n.mk $(CRYPTO_COPY) $(UTILS_COPY) $(TLS_COPY) $(API_COPY) $(ERROR_COPY) $(STUFFER_COPY)
${MAKE} -C s2n bc
${MAKE} -C bitcode all_llvm.bc

s2n/%.h : ../../%.h
cp $< $@
Expand Down
3 changes: 2 additions & 1 deletion tests/saw/bitcode/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.bc
*.bc
*.ll
5 changes: 5 additions & 0 deletions tests/saw/bitcode/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
include ../../../s2n.mk

BCS=$(wildcard *.bc)

all_llvm.bc : $(BCS)
$(LLVMLINK) -o $@ $+
16 changes: 16 additions & 0 deletions tests/saw/cork-uncork.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Entry point for the corking correctness proof.
import "spec/cork-uncork.cry";
include "s2n_handshake_io.saw";

//prove correspondence of the C code and the low-level model
s2n_handshake_io_lowlevel;
print "Verified that the low-level specification corresponds to the C code";
//prove correspondence of the high-level and low-level models
prove_print abc {{ highLevelSimulatesLowLevel `{16} }};
print "Verified the low-level->high-level cork-uncork simulation";
//prove no-double-uncork property for server mode
prove_print abc {{ noDoubleCorkUncork }};
print "Verified that double uncorking or corking cannot occur in server mode";
//(for the record) evidence that a double uncork can occur in client mode
print "Expecting failure when proving low-high simulation without the server mode assumption";
sat abc {{ ~highLevelDoesNotSimulateLowLevel `{16} }};
12 changes: 12 additions & 0 deletions tests/saw/failure_tests/cork_one.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/tls/s2n_handshake_io.c b/tls/s2n_handshake_io.c
index fd9eb0d..51f4c53 100644
--- a/tls/s2n_handshake_io.c
+++ b/tls/s2n_handshake_io.c
@@ -242,6 +242,7 @@ static int s2n_advance_message(struct s2n_connection *conn)
if (s2n_connection_is_managed_corked(conn)) {
/* Set TCP_CORK/NOPUSH */
GUARD(s2n_socket_write_cork(conn));
+ GUARD(s2n_socket_write_cork(conn));
}

return 0;
12 changes: 12 additions & 0 deletions tests/saw/failure_tests/cork_two.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/tls/s2n_handshake_io.c b/tls/s2n_handshake_io.c
index fd9eb0d..11734ac 100644
--- a/tls/s2n_handshake_io.c
+++ b/tls/s2n_handshake_io.c
@@ -242,6 +242,7 @@ static int s2n_advance_message(struct s2n_connection *conn)
if (s2n_connection_is_managed_corked(conn)) {
/* Set TCP_CORK/NOPUSH */
GUARD(s2n_socket_write_cork(conn));
+ GUARD(s2n_socket_write_uncork(conn));
}

return 0;
15 changes: 0 additions & 15 deletions tests/saw/failure_tests/msgchange.patch

This file was deleted.

9 changes: 9 additions & 0 deletions tests/saw/failure_tests/tls_early_ccs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Binary files s2n/.git/index and s2n2/.git/index differ
diff -p1 -Nur s2n/tls/s2n_handshake_io.c s2n2/tls/s2n_handshake_io.c
--- s2n/tls/s2n_handshake_io.c 2017-07-14 15:29:09.806626239 -0700
+++ s2n2/tls/s2n_handshake_io.c 2017-07-19 11:17:13.347220835 -0700
@@ -106,3 +106,3 @@ static message_type_t handshakes[64][16]
CLIENT_HELLO,
- SERVER_HELLO, SERVER_CERT, SERVER_HELLO_DONE,
+ SERVER_HELLO, CLIENT_CHANGE_CIPHER_SPEC, SERVER_CERT, SERVER_HELLO_DONE,
CLIENT_KEY, CLIENT_CHANGE_CIPHER_SPEC, CLIENT_FINISHED,
Loading