mbed TLS upgraded to 2.6.0

Fork of mbedtls by Mark Radbourne

Committer:
Jasper Wallace
Date:
Fri Sep 29 19:50:30 2017 +0100
Revision:
2:bbdeda018a3c
Parent:
1:9ebc941037d5
Update to mbedtls 2.6.0, many changes.

Changes to mbedtls sources made:

in include/mbedtls/config.h comment out:

#define MBEDTLS_FS_IO
#define MBEDTLS_NET_C
#define MBEDTLS_TIMING_C

uncomment:

#define MBEDTLS_NO_PLATFORM_ENTROPY

remove the following directorys:

programs
yotta
visualc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jasper Wallace 1:9ebc941037d5 1 #!/bin/sh
Jasper Wallace 1:9ebc941037d5 2
Jasper Wallace 1:9ebc941037d5 3 # Measure memory usage of a minimal client using a small configuration
Jasper Wallace 1:9ebc941037d5 4 # Currently hardwired to ccm-psk and suite-b, may be expanded later
Jasper Wallace 1:9ebc941037d5 5 #
Jasper Wallace 1:9ebc941037d5 6 # Use different build options for measuring executable size and memory usage,
Jasper Wallace 1:9ebc941037d5 7 # since for memory we want debug information.
Jasper Wallace 1:9ebc941037d5 8
Jasper Wallace 1:9ebc941037d5 9 set -eu
Jasper Wallace 1:9ebc941037d5 10
Jasper Wallace 1:9ebc941037d5 11 CONFIG_H='include/mbedtls/config.h'
Jasper Wallace 1:9ebc941037d5 12
Jasper Wallace 1:9ebc941037d5 13 CLIENT='mini_client'
Jasper Wallace 1:9ebc941037d5 14
Jasper Wallace 1:9ebc941037d5 15 CFLAGS_EXEC='-fno-asynchronous-unwind-tables -Wl,--gc-section -ffunction-sections -fdata-sections'
Jasper Wallace 1:9ebc941037d5 16 CFLAGS_MEM=-g3
Jasper Wallace 1:9ebc941037d5 17
Jasper Wallace 1:9ebc941037d5 18 if [ -r $CONFIG_H ]; then :; else
Jasper Wallace 1:9ebc941037d5 19 echo "$CONFIG_H not found" >&2
Jasper Wallace 1:9ebc941037d5 20 exit 1
Jasper Wallace 1:9ebc941037d5 21 fi
Jasper Wallace 1:9ebc941037d5 22
Jasper Wallace 1:9ebc941037d5 23 if grep -i cmake Makefile >/dev/null; then
Jasper Wallace 1:9ebc941037d5 24 echo "Not compatible with CMake" >&2
Jasper Wallace 1:9ebc941037d5 25 exit 1
Jasper Wallace 1:9ebc941037d5 26 fi
Jasper Wallace 1:9ebc941037d5 27
Jasper Wallace 1:9ebc941037d5 28 if [ $( uname ) != Linux ]; then
Jasper Wallace 1:9ebc941037d5 29 echo "Only work on Linux" >&2
Jasper Wallace 1:9ebc941037d5 30 exit 1
Jasper Wallace 1:9ebc941037d5 31 fi
Jasper Wallace 1:9ebc941037d5 32
Jasper Wallace 1:9ebc941037d5 33 if git status | grep -F $CONFIG_H >/dev/null 2>&1; then
Jasper Wallace 1:9ebc941037d5 34 echo "config.h not clean" >&2
Jasper Wallace 1:9ebc941037d5 35 exit 1
Jasper Wallace 1:9ebc941037d5 36 fi
Jasper Wallace 1:9ebc941037d5 37
Jasper Wallace 1:9ebc941037d5 38 # make measurements with one configuration
Jasper Wallace 1:9ebc941037d5 39 # usage: do_config <name> <unset-list> <server-args>
Jasper Wallace 1:9ebc941037d5 40 do_config()
Jasper Wallace 1:9ebc941037d5 41 {
Jasper Wallace 1:9ebc941037d5 42 NAME=$1
Jasper Wallace 1:9ebc941037d5 43 UNSET_LIST=$2
Jasper Wallace 1:9ebc941037d5 44 SERVER_ARGS=$3
Jasper Wallace 1:9ebc941037d5 45
Jasper Wallace 1:9ebc941037d5 46 echo ""
Jasper Wallace 1:9ebc941037d5 47 echo "config-$NAME:"
Jasper Wallace 1:9ebc941037d5 48 cp configs/config-$NAME.h $CONFIG_H
Jasper Wallace 1:9ebc941037d5 49 scripts/config.pl unset MBEDTLS_SSL_SRV_C
Jasper Wallace 1:9ebc941037d5 50
Jasper Wallace 1:9ebc941037d5 51 for FLAG in $UNSET_LIST; do
Jasper Wallace 1:9ebc941037d5 52 scripts/config.pl unset $FLAG
Jasper Wallace 1:9ebc941037d5 53 done
Jasper Wallace 1:9ebc941037d5 54
Jasper Wallace 1:9ebc941037d5 55 grep -F SSL_MAX_CONTENT_LEN $CONFIG_H || echo 'SSL_MAX_CONTENT_LEN=16384'
Jasper Wallace 1:9ebc941037d5 56
Jasper Wallace 1:9ebc941037d5 57 printf " Executable size... "
Jasper Wallace 1:9ebc941037d5 58
Jasper Wallace 1:9ebc941037d5 59 make clean
Jasper Wallace 1:9ebc941037d5 60 CFLAGS=$CFLAGS_EXEC make OFLAGS=-Os lib >/dev/null 2>&1
Jasper Wallace 1:9ebc941037d5 61 cd programs
Jasper Wallace 1:9ebc941037d5 62 CFLAGS=$CFLAGS_EXEC make OFLAGS=-Os ssl/$CLIENT >/dev/null
Jasper Wallace 1:9ebc941037d5 63 strip ssl/$CLIENT
Jasper Wallace 1:9ebc941037d5 64 stat -c '%s' ssl/$CLIENT
Jasper Wallace 1:9ebc941037d5 65 cd ..
Jasper Wallace 1:9ebc941037d5 66
Jasper Wallace 1:9ebc941037d5 67 printf " Peak ram usage... "
Jasper Wallace 1:9ebc941037d5 68
Jasper Wallace 1:9ebc941037d5 69 make clean
Jasper Wallace 1:9ebc941037d5 70 CFLAGS=$CFLAGS_MEM make OFLAGS=-Os lib >/dev/null 2>&1
Jasper Wallace 1:9ebc941037d5 71 cd programs
Jasper Wallace 1:9ebc941037d5 72 CFLAGS=$CFLAGS_MEM make OFLAGS=-Os ssl/$CLIENT >/dev/null
Jasper Wallace 1:9ebc941037d5 73 cd ..
Jasper Wallace 1:9ebc941037d5 74
Jasper Wallace 1:9ebc941037d5 75 ./ssl_server2 $SERVER_ARGS >/dev/null &
Jasper Wallace 1:9ebc941037d5 76 SRV_PID=$!
Jasper Wallace 1:9ebc941037d5 77 sleep 1;
Jasper Wallace 1:9ebc941037d5 78
Jasper Wallace 1:9ebc941037d5 79 if valgrind --tool=massif --stacks=yes programs/ssl/$CLIENT >/dev/null 2>&1
Jasper Wallace 1:9ebc941037d5 80 then
Jasper Wallace 1:9ebc941037d5 81 FAILED=0
Jasper Wallace 1:9ebc941037d5 82 else
Jasper Wallace 1:9ebc941037d5 83 echo "client failed" >&2
Jasper Wallace 1:9ebc941037d5 84 FAILED=1
Jasper Wallace 1:9ebc941037d5 85 fi
Jasper Wallace 1:9ebc941037d5 86
Jasper Wallace 1:9ebc941037d5 87 kill $SRV_PID
Jasper Wallace 1:9ebc941037d5 88 wait $SRV_PID
Jasper Wallace 1:9ebc941037d5 89
Jasper Wallace 1:9ebc941037d5 90 scripts/massif_max.pl massif.out.*
Jasper Wallace 1:9ebc941037d5 91 mv massif.out.* massif-$NAME.$$
Jasper Wallace 1:9ebc941037d5 92 }
Jasper Wallace 1:9ebc941037d5 93
Jasper Wallace 1:9ebc941037d5 94 # preparation
Jasper Wallace 1:9ebc941037d5 95
Jasper Wallace 1:9ebc941037d5 96 CONFIG_BAK=${CONFIG_H}.bak
Jasper Wallace 1:9ebc941037d5 97 cp $CONFIG_H $CONFIG_BAK
Jasper Wallace 1:9ebc941037d5 98
Jasper Wallace 1:9ebc941037d5 99 rm -f massif.out.*
Jasper Wallace 1:9ebc941037d5 100
Jasper Wallace 1:9ebc941037d5 101 printf "building server... "
Jasper Wallace 1:9ebc941037d5 102
Jasper Wallace 1:9ebc941037d5 103 make clean
Jasper Wallace 1:9ebc941037d5 104 make lib >/dev/null 2>&1
Jasper Wallace 1:9ebc941037d5 105 (cd programs && make ssl/ssl_server2) >/dev/null
Jasper Wallace 1:9ebc941037d5 106 cp programs/ssl/ssl_server2 .
Jasper Wallace 1:9ebc941037d5 107
Jasper Wallace 1:9ebc941037d5 108 echo "done"
Jasper Wallace 1:9ebc941037d5 109
Jasper Wallace 1:9ebc941037d5 110 # actual measurements
Jasper Wallace 1:9ebc941037d5 111
Jasper Wallace 1:9ebc941037d5 112 do_config "ccm-psk-tls1_2" \
Jasper Wallace 1:9ebc941037d5 113 "" \
Jasper Wallace 1:9ebc941037d5 114 "psk=000102030405060708090A0B0C0D0E0F"
Jasper Wallace 1:9ebc941037d5 115
Jasper Wallace 1:9ebc941037d5 116 do_config "suite-b" \
Jasper Wallace 1:9ebc941037d5 117 "MBEDTLS_BASE64_C MBEDTLS_PEM_PARSE_C MBEDTLS_CERTS_C" \
Jasper Wallace 1:9ebc941037d5 118 ""
Jasper Wallace 1:9ebc941037d5 119
Jasper Wallace 1:9ebc941037d5 120 # cleanup
Jasper Wallace 1:9ebc941037d5 121
Jasper Wallace 1:9ebc941037d5 122 mv $CONFIG_BAK $CONFIG_H
Jasper Wallace 1:9ebc941037d5 123 make clean
Jasper Wallace 1:9ebc941037d5 124 rm ssl_server2
Jasper Wallace 1:9ebc941037d5 125
Jasper Wallace 1:9ebc941037d5 126 exit $FAILED