Merge branch 'iotssl-683-travis-failing-intermittently'
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index d9b37e0..a617d06 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -2469,6 +2469,8 @@
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
/* Note: your snprintf must correclty zero-terminate the buffer! */
//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
+//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */
+//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */
/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */
/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */
diff --git a/include/mbedtls/debug.h b/include/mbedtls/debug.h
index 7d944f3..2957996 100644
--- a/include/mbedtls/debug.h
+++ b/include/mbedtls/debug.h
@@ -97,7 +97,7 @@
void mbedtls_debug_set_threshold( int threshold );
/**
-* \brief Print a message to the debug output. This function is always used
+ * \brief Print a message to the debug output. This function is always used
* through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl
* context, file and line number parameters.
*
diff --git a/include/mbedtls/platform.h b/include/mbedtls/platform.h
index f71f1b6..1371ff1 100644
--- a/include/mbedtls/platform.h
+++ b/include/mbedtls/platform.h
@@ -64,7 +64,13 @@
#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
-#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default free to use */
+#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */
+#endif
+#if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
+#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */
+#endif
+#if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
+#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< Default exit value to use */
#endif
#else /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
#if defined(MBEDTLS_PLATFORM_STD_MEM_HDR)
@@ -207,6 +213,20 @@
#endif /* MBEDTLS_PLATFORM_EXIT_MACRO */
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
+/*
+ * The default exit values
+ */
+#if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
+#define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
+#else
+#define MBEDTLS_EXIT_SUCCESS 0
+#endif
+#if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
+#define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE
+#else
+#define MBEDTLS_EXIT_FAILURE 1
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index b168b71..6ca07bb 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -52,15 +52,18 @@
#include "mbedtls/ecjpake.h"
#include "mbedtls/timing.h"
-#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
+#include <stdlib.h>
#define mbedtls_printf printf
#define mbedtls_snprintf snprintf
+#define mbedtls_exit exit
+#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
+#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
@@ -99,8 +102,7 @@
int main( int argc, char *argv[] )
{
- int ret = 0, v, suites_tested = 0, suites_failed = 0,
- exitcode = EXIT_SUCCESS;
+ int v, suites_tested = 0, suites_failed = 0;
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
unsigned char buf[1000000];
#endif
@@ -115,7 +117,7 @@
if( pointer != NULL )
{
mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
- return( 1 );
+ mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
/*
@@ -124,7 +126,7 @@
if( run_test_snprintf() != 0 )
{
mbedtls_printf( "the snprintf implementation is broken\n" );
- return( 0 );
+ mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
if( argc == 2 && ( strcmp( argv[1], "--quiet" ) == 0 ||
@@ -145,7 +147,7 @@
#endif
#if defined(MBEDTLS_MD2_C)
- if( ( ret = mbedtls_md2_self_test( v ) ) != 0 )
+ if( mbedtls_md2_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -153,7 +155,7 @@
#endif
#if defined(MBEDTLS_MD4_C)
- if( ( ret = mbedtls_md4_self_test( v ) ) != 0 )
+ if( mbedtls_md4_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -161,7 +163,7 @@
#endif
#if defined(MBEDTLS_MD5_C)
- if( ( ret = mbedtls_md5_self_test( v ) ) != 0 )
+ if( mbedtls_md5_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -169,7 +171,7 @@
#endif
#if defined(MBEDTLS_RIPEMD160_C)
- if( ( ret = mbedtls_ripemd160_self_test( v ) ) != 0 )
+ if( mbedtls_ripemd160_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -177,7 +179,7 @@
#endif
#if defined(MBEDTLS_SHA1_C)
- if( ( ret = mbedtls_sha1_self_test( v ) ) != 0 )
+ if( mbedtls_sha1_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -185,7 +187,7 @@
#endif
#if defined(MBEDTLS_SHA256_C)
- if( ( ret = mbedtls_sha256_self_test( v ) ) != 0 )
+ if( mbedtls_sha256_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -193,7 +195,7 @@
#endif
#if defined(MBEDTLS_SHA512_C)
- if( ( ret = mbedtls_sha512_self_test( v ) ) != 0 )
+ if( mbedtls_sha512_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -201,7 +203,7 @@
#endif
#if defined(MBEDTLS_ARC4_C)
- if( ( ret = mbedtls_arc4_self_test( v ) ) != 0 )
+ if( mbedtls_arc4_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -209,7 +211,7 @@
#endif
#if defined(MBEDTLS_DES_C)
- if( ( ret = mbedtls_des_self_test( v ) ) != 0 )
+ if( mbedtls_des_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -217,7 +219,7 @@
#endif
#if defined(MBEDTLS_AES_C)
- if( ( ret = mbedtls_aes_self_test( v ) ) != 0 )
+ if( mbedtls_aes_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -225,7 +227,7 @@
#endif
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
- if( ( ret = mbedtls_gcm_self_test( v ) ) != 0 )
+ if( mbedtls_gcm_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -233,7 +235,7 @@
#endif
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
- if( ( ret = mbedtls_ccm_self_test( v ) ) != 0 )
+ if( mbedtls_ccm_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -241,7 +243,7 @@
#endif
#if defined(MBEDTLS_BASE64_C)
- if( ( ret = mbedtls_base64_self_test( v ) ) != 0 )
+ if( mbedtls_base64_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -249,7 +251,7 @@
#endif
#if defined(MBEDTLS_BIGNUM_C)
- if( ( ret = mbedtls_mpi_self_test( v ) ) != 0 )
+ if( mbedtls_mpi_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -257,7 +259,7 @@
#endif
#if defined(MBEDTLS_RSA_C)
- if( ( ret = mbedtls_rsa_self_test( v ) ) != 0 )
+ if( mbedtls_rsa_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -265,7 +267,7 @@
#endif
#if defined(MBEDTLS_X509_USE_C)
- if( ( ret = mbedtls_x509_self_test( v ) ) != 0 )
+ if( mbedtls_x509_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -273,7 +275,7 @@
#endif
#if defined(MBEDTLS_XTEA_C)
- if( ( ret = mbedtls_xtea_self_test( v ) ) != 0 )
+ if( mbedtls_xtea_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -281,7 +283,7 @@
#endif
#if defined(MBEDTLS_CAMELLIA_C)
- if( ( ret = mbedtls_camellia_self_test( v ) ) != 0 )
+ if( mbedtls_camellia_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -289,7 +291,7 @@
#endif
#if defined(MBEDTLS_CTR_DRBG_C)
- if( ( ret = mbedtls_ctr_drbg_self_test( v ) ) != 0 )
+ if( mbedtls_ctr_drbg_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -297,7 +299,7 @@
#endif
#if defined(MBEDTLS_HMAC_DRBG_C)
- if( ( ret = mbedtls_hmac_drbg_self_test( v ) ) != 0 )
+ if( mbedtls_hmac_drbg_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -305,7 +307,7 @@
#endif
#if defined(MBEDTLS_ECP_C)
- if( ( ret = mbedtls_ecp_self_test( v ) ) != 0 )
+ if( mbedtls_ecp_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -313,7 +315,7 @@
#endif
#if defined(MBEDTLS_ECJPAKE_C)
- if( ( ret = mbedtls_ecjpake_self_test( v ) ) != 0 )
+ if( mbedtls_ecjpake_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -321,7 +323,7 @@
#endif
#if defined(MBEDTLS_DHM_C)
- if( ( ret = mbedtls_dhm_self_test( v ) ) != 0 )
+ if( mbedtls_dhm_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -329,7 +331,7 @@
#endif
#if defined(MBEDTLS_ENTROPY_C)
- if( ( ret = mbedtls_entropy_self_test( v ) ) != 0 )
+ if( mbedtls_entropy_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -337,7 +339,7 @@
#endif
#if defined(MBEDTLS_PKCS5_C)
- if( ( ret = mbedtls_pkcs5_self_test( v ) ) != 0 )
+ if( mbedtls_pkcs5_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -347,7 +349,7 @@
/* Slow tests last */
#if defined(MBEDTLS_TIMING_C)
- if( ( ret = mbedtls_timing_self_test( v ) ) != 0 )
+ if( mbedtls_timing_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -367,7 +369,7 @@
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
mbedtls_memory_buffer_alloc_free();
- if( ( ret = mbedtls_memory_buffer_alloc_self_test( v ) ) != 0 )
+ if( mbedtls_memory_buffer_alloc_self_test( v ) != 0 )
{
suites_failed++;
}
@@ -393,8 +395,8 @@
}
if( suites_failed > 0)
- exitcode = EXIT_FAILURE;
+ mbedtls_exit( MBEDTLS_EXIT_FAILURE );
- exit( exitcode );
+ mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
}
diff --git a/scripts/config.pl b/scripts/config.pl
index d4c32fd..a6dcfe7 100755
--- a/scripts/config.pl
+++ b/scripts/config.pl
@@ -1,22 +1,73 @@
#!/usr/bin/perl
-
-# Tune the configuration file
+#
+# This file is part of mbed TLS (https://tls.mbed.org)
+#
+# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
+#
+# Purpose
+#
+# Comments and uncomments #define lines in the given header file and optionally
+# sets their value. This is to provide scripting control of what preprocessor
+# symbols, and therefore what build time configuration flags are set in the
+# 'config.h' file.
+#
+# Usage: config.pl [-f <file> | --file <file>] [-o | --force]
+# [set <symbol> <value> | unset <symbol> | full | realfull]
+#
+# Full usage description provided below.
+#
+# Things that shouldn't be enabled with "full".
+#
+# MBEDTLS_DEPRECATED_REMOVED
+# MBEDTLS_HAVE_SSE2
+# MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
+# MBEDTLS_ECP_DP_M221_ENABLED
+# MBEDTLS_ECP_DP_M383_ENABLED
+# MBEDTLS_ECP_DP_M511_ENABLED
+# MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
+# MBEDTLS_NO_PLATFORM_ENTROPY
+# MBEDTLS_REMOVE_ARC4_CIPHERSUITES
+# MBEDTLS_SSL_HW_RECORD_ACCEL
+# MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
+# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
+# - this could be enabled if the respective tests were adapted
+# MBEDTLS_ZLIB_SUPPORT
+# MBEDTLS_PKCS11_C
+# and any symbol beginning _ALT
+#
use warnings;
use strict;
+my $config_file = "include/mbedtls/config.h";
my $usage = <<EOU;
-$0 [-f <file>] unset <name>
-$0 [-f <file>] set <name> [<value>]
-EOU
-# for our eyes only:
-# $0 [-f <file>] full|realfull
+$0 [-f <file> | --file <file>] [-o | --force]
+ [set <symbol> <value> | unset <symbol> | full | realfull]
-# Things that shouldn't be enabled with "full".
-# Notes:
-# - MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 and
-# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION could be enabled if the
-# respective tests were adapted
+Commands
+ set <symbol> [<value] - Uncomments or adds a #define for the <symnol> to
+ the configuration file, and optionally making it
+ of <value>.
+ If the symbol isn't present in the file an error
+ is returned.
+ unset <symbol> - Comments out any #define present in the
+ configuration file.
+ full - Uncomments all #define's in the configuration file
+ excluding some reserved symbols, until the
+ 'Module configuration options' section
+ realfull - Uncomments all #define's with no exclusions
+
+Options
+ -f | --file <filename> - The file or file path for the configuration file
+ to edit. When omitted, the following default is
+ used:
+ $config_file
+ -o | --force - If the symbol isn't present in the configuration
+ file when setting it's value, a #define is
+ appended to the end of the file.
+
+EOU
+
my @excluded = qw(
MBEDTLS_DEPRECATED_REMOVED
MBEDTLS_HAVE_SSE2
@@ -40,40 +91,65 @@
PLATFORM_[A-Z0-9]+_ALT
);
-my $config_file = "include/mbedtls/config.h";
+# Process the command line arguments
-# get -f option
-if (@ARGV >= 2 && $ARGV[0] eq "-f") {
- shift; # -f
- $config_file = shift;
+my $force_option = 0;
- -f $config_file or die "No such file: $config_file\n";
-} else {
- if (! -f $config_file) {
- chdir '..' or die;
- -f $config_file
- or die "Without -f, must be run from root or scripts\n"
+my ($arg, $name, $value, $action);
+
+while ($arg = shift) {
+
+ # Check if the argument is an option
+ if ($arg eq "-f" || $arg eq "--file") {
+ $config_file = shift;
+
+ -f $config_file or die "No such file: $config_file\n";
+
+ }
+ elsif ($arg eq "-o" || $arg eq "--force") {
+ $force_option = 1;
+
+ }
+ else
+ {
+ # ...else assume it's a command
+ $action = $arg;
+
+ if ($action eq "full" || $action eq "realfull") {
+ # No additional parameters
+ die $usage if @ARGV;
+
+ }
+ elsif ($action eq "unset") {
+ die $usage unless @ARGV;
+ $name = shift;
+
+ }
+ elsif ($action eq "set") {
+ die $usage unless @ARGV;
+ $name = shift;
+ $value = shift if @ARGV;
+
+ }
+ else {
+ die "Command '$action' not recognised.\n\n".$usage;
+ }
}
}
-# get action
-die $usage unless @ARGV;
-my $action = shift;
+# Check the config file is present
+if (! -f $config_file) {
-my ($name, $value);
-if ($action eq "full" || $action eq "realfull") {
- # nothing to do
-} elsif ($action eq "unset") {
- die $usage unless @ARGV;
- $name = shift;
-} elsif ($action eq "set") {
- die $usage unless @ARGV;
- $name = shift;
- $value = shift if @ARGV;
-} else {
- die $usage;
+ chdir '..' or die;
+
+ # Confirm this is the project root directory and try again
+ if ( !(-d 'scripts' && -d 'include' && -d 'library' && -f $config_file) ) {
+ die "If no file specified, must be run from the project root or scripts directory.\n";
+ }
}
-die $usage if @ARGV;
+
+
+# Now read the file and process the contents
open my $config_read, '<', $config_file or die "read $config_file: $!\n";
my @config_lines = <$config_read>;
@@ -122,9 +198,27 @@
print $config_write $line;
}
+# Did the set command work?
+if ($action eq "set"&& $force_option && !$done) {
+
+ # If the force option was set, append the symbol to the end of the file
+ my $line = "#define $name";
+ $line .= " $value" if defined $value && $value ne "";
+ $line .= "\n";
+ $done = 1;
+
+ print $config_write $line;
+}
+
close $config_write;
-die "configuration section not found" if ($action eq "full" && !$done);
-die "$name not found" if ($action ne "full" && !$done);
+if ($action eq "full" && !$done) {
+ die "Configuration section was not found in $config_file\n";
+
+}
+
+if ($action ne "full" && $action ne "unset" && !$done) {
+ die "A #define for the symbol $name was not found in $config_file\n";
+}
__END__
diff --git a/scripts/footprint.sh b/scripts/footprint.sh
index 87d62df..026e7a8 100755
--- a/scripts/footprint.sh
+++ b/scripts/footprint.sh
@@ -1,5 +1,23 @@
#!/bin/sh
-
+#
+# This file is part of mbed TLS (https://tls.mbed.org)
+#
+# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
+#
+# Purpose
+#
+# This script determines ROM size (or code size) for the standard mbed TLS
+# configurations, when built for a Cortex M3/M4 target.
+#
+# Configurations included:
+# default include/mbedtls/config.h
+# yotta yotta/module/mbedtls/config.h
+# thread configs/config-thread.h
+# suite-b configs/config-suite-b.h
+# psk configs/config-ccm-psk-tls1_2.h
+#
+# Usage: footprint.sh
+#
set -eu
CONFIG_H='include/mbedtls/config.h'
@@ -48,6 +66,7 @@
scripts/config.pl unset MBEDTLS_NET_C || true
scripts/config.pl unset MBEDTLS_TIMING_C || true
scripts/config.pl unset MBEDTLS_FS_IO || true
+ scripts/config.pl --force set MBEDTLS_NO_PLATFORM_ENTROPY || true
} >/dev/null 2>&1
CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld \
diff --git a/tests/scripts/basic-build-test.sh b/tests/scripts/basic-build-test.sh
index 06c2eb9..ffca6f9 100755
--- a/tests/scripts/basic-build-test.sh
+++ b/tests/scripts/basic-build-test.sh
@@ -36,8 +36,8 @@
# Step 1 - Make and instrumented build for code coverage
-CFLAGS=' --coverage -g3 -O0 '
-make
+export CFLAGS=' --coverage -g3 -O0 '
+make clean; make
# Step 2 - Execute the tests
diff --git a/yotta/data/module.json b/yotta/data/module.json
index 164a083..f303783 100644
--- a/yotta/data/module.json
+++ b/yotta/data/module.json
@@ -1,6 +1,6 @@
{
"name": "mbedtls",
- "version": "2.2.2",
+ "version": "2.3.0",
"description": "The mbed TLS crypto/SSL/TLS library",
"licenses": [
{