mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Merge remote-tracking branch 'origin/development' into development-restricted
* origin/development: (36 commits) Do not build fuzz on windows No booleans and import config Removing space before opening parenthesis Style corrections Syntax fix Fixes warnings from MSVC Add a linker flag to enable gcov in basic-build-test.sh tests: Limit each log to 10 GiB Fix parsing issue when int parameter is in base 16 checks MBEDTLS_PEM_PARSE_C Restore programs/fuzz/Makefile after in-tree cmake Move fuzz directory to programs Documentation for corpus generation Restore tests/fuzz/Makefile after in-tree cmake Adding ifdefs to avoid warnings for unused globals Adds LDFLAGS fsanitize=address Refactor receive_uint32() Refactor get_byte function Make the script portable to both pythons Update the test encoding to support python3 ...
This commit is contained in:
@ -15,6 +15,10 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Limit the size of each log to 10 GiB, in case of failures with this script
|
||||
# where it may output seemingly unlimited length error logs.
|
||||
ulimit -f 20971520
|
||||
|
||||
# initialise counters
|
||||
TESTS=0
|
||||
FAILED=0
|
||||
|
@ -24,7 +24,8 @@
|
||||
# configurations, and can and will arbitrarily change the current CMake
|
||||
# configuration. The following files must be committed into git:
|
||||
# * include/mbedtls/config.h
|
||||
# * Makefile, library/Makefile, programs/Makefile, tests/Makefile
|
||||
# * Makefile, library/Makefile, programs/Makefile, tests/Makefile,
|
||||
# programs/fuzz/Makefile
|
||||
# After running this script, the CMake cache will be lost and CMake
|
||||
# will no longer be initialised.
|
||||
#
|
||||
@ -75,9 +76,9 @@
|
||||
# * Run `make clean`.
|
||||
# * Restore `include/mbedtks/config.h` from a backup made before running
|
||||
# the component.
|
||||
# * Check out `Makefile`, `library/Makefile`, `programs/Makefile` and
|
||||
# `tests/Makefile` from git. This cleans up after an in-tree use of
|
||||
# CMake.
|
||||
# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`,
|
||||
# `tests/Makefile` and `programs/fuzz/Makefile` from git.
|
||||
# This cleans up after an in-tree use of CMake.
|
||||
#
|
||||
# Any command that is expected to fail must be protected so that the
|
||||
# script keeps running in --keep-going mode despite `set -e`. In keep-going
|
||||
@ -234,8 +235,8 @@ cleanup()
|
||||
-iname CMakeCache.txt \) -exec rm {} \+
|
||||
# Recover files overwritten by in-tree CMake builds
|
||||
rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
|
||||
git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
|
||||
git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile
|
||||
git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
|
||||
git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
|
||||
cd crypto
|
||||
rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
|
||||
git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile
|
||||
@ -1052,7 +1053,7 @@ component_test_m32_o0 () {
|
||||
# Build once with -O0, to compile out the i386 specific inline assembly
|
||||
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
|
||||
scripts/config.pl full
|
||||
make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32'
|
||||
make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address'
|
||||
|
||||
msg "test: i386, make, gcc -O0 (ASan build)"
|
||||
make test
|
||||
@ -1071,7 +1072,7 @@ component_test_m32_o1 () {
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_DEBUG
|
||||
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32'
|
||||
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address'
|
||||
|
||||
msg "test: i386, make, gcc -O1 (ASan build)"
|
||||
make test
|
||||
|
@ -64,6 +64,7 @@ echo
|
||||
|
||||
# Step 1 - Make and instrumented build for code coverage
|
||||
export CFLAGS=' --coverage -g3 -O0 '
|
||||
export LDFLAGS=' --coverage'
|
||||
make clean
|
||||
cp "$CONFIG_H" "$CONFIG_BAK"
|
||||
scripts/config.pl full
|
||||
|
@ -79,7 +79,7 @@ class TestDataParser(object):
|
||||
split_colon_fn = lambda x: re.sub(r'\\' + split_char, split_char, x)
|
||||
if len(split_char) > 1:
|
||||
raise ValueError('Expected split character. Found string!')
|
||||
out = map(split_colon_fn, re.split(r'(?<!\\)' + split_char, inp_str))
|
||||
out = list(map(split_colon_fn, re.split(r'(?<!\\)' + split_char, inp_str)))
|
||||
out = [x for x in out if x]
|
||||
return out
|
||||
|
||||
@ -99,11 +99,11 @@ class TestDataParser(object):
|
||||
|
||||
# Check dependencies
|
||||
dependencies = []
|
||||
line = data_f.next().strip()
|
||||
line = next(data_f).strip()
|
||||
match = re.search('depends_on:(.*)', line)
|
||||
if match:
|
||||
dependencies = [int(x) for x in match.group(1).split(':')]
|
||||
line = data_f.next().strip()
|
||||
line = next(data_f).strip()
|
||||
|
||||
# Read test vectors
|
||||
line = line.replace('\\n', '\n')
|
||||
@ -115,7 +115,7 @@ class TestDataParser(object):
|
||||
err_str_fmt = "Number of test arguments({}) should be even: {}"
|
||||
raise TestDataParserError(err_str_fmt.format(args_count, line))
|
||||
grouped_args = [(args[i * 2], args[(i * 2) + 1])
|
||||
for i in range(len(args)/2)]
|
||||
for i in range(int(len(args)/2))]
|
||||
self.tests.append((name, function_name, dependencies,
|
||||
grouped_args))
|
||||
|
||||
@ -261,21 +261,21 @@ class MbedTlsTest(BaseHostTest):
|
||||
data_bytes += bytearray([function_id, len(parameters)])
|
||||
for typ, param in parameters:
|
||||
if typ == 'int' or typ == 'exp':
|
||||
i = int(param)
|
||||
data_bytes += 'I' if typ == 'int' else 'E'
|
||||
i = int(param, 0)
|
||||
data_bytes += b'I' if typ == 'int' else b'E'
|
||||
self.align_32bit(data_bytes)
|
||||
data_bytes += self.int32_to_big_endian_bytes(i)
|
||||
elif typ == 'char*':
|
||||
param = param.strip('"')
|
||||
i = len(param) + 1 # + 1 for null termination
|
||||
data_bytes += 'S'
|
||||
data_bytes += b'S'
|
||||
self.align_32bit(data_bytes)
|
||||
data_bytes += self.int32_to_big_endian_bytes(i)
|
||||
data_bytes += bytearray(list(param))
|
||||
data_bytes += '\0' # Null terminate
|
||||
data_bytes += bytearray(param, encoding='ascii')
|
||||
data_bytes += b'\0' # Null terminate
|
||||
elif typ == 'hex':
|
||||
binary_data = self.hex_str_bytes(param)
|
||||
data_bytes += 'H'
|
||||
data_bytes += b'H'
|
||||
self.align_32bit(data_bytes)
|
||||
i = len(binary_data)
|
||||
data_bytes += self.int32_to_big_endian_bytes(i)
|
||||
@ -310,7 +310,7 @@ class MbedTlsTest(BaseHostTest):
|
||||
|
||||
param_bytes, length = self.test_vector_to_bytes(function_id,
|
||||
dependencies, args)
|
||||
self.send_kv(length, param_bytes)
|
||||
self.send_kv(''.join('{:02x}'.format(x) for x in length), ''.join('{:02x}'.format(x) for x in param_bytes))
|
||||
|
||||
@staticmethod
|
||||
def get_result(value):
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Limit the size of each log to 10 GiB, in case of failures with this script
|
||||
# where it may output seemingly unlimited length error logs.
|
||||
ulimit -f 20971520
|
||||
|
||||
if cd $( dirname $0 ); then :; else
|
||||
echo "cd $( dirname $0 ) failed" >&2
|
||||
exit 1
|
||||
|
@ -59,10 +59,29 @@ int verify_dependencies( uint8_t count, uint8_t * dep_p )
|
||||
return( DEPENDENCY_SUPPORTED );
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Receives hex string on serial interface, and converts to a byte.
|
||||
*
|
||||
* \param none
|
||||
*
|
||||
* \return unsigned int8
|
||||
*/
|
||||
uint8_t receive_byte()
|
||||
{
|
||||
uint8_t byte;
|
||||
uint8_t c[3];
|
||||
char *endptr;
|
||||
c[0] = greentea_getc();
|
||||
c[1] = greentea_getc();
|
||||
c[2] = '\0';
|
||||
|
||||
assert( unhexify( &byte, c ) != 2 );
|
||||
return( byte );
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Receives unsigned integer on serial interface.
|
||||
* Integers are encoded in network order.
|
||||
* Integers are encoded in network order, and sent as hex ascii string.
|
||||
*
|
||||
* \param none
|
||||
*
|
||||
@ -71,10 +90,17 @@ int verify_dependencies( uint8_t count, uint8_t * dep_p )
|
||||
uint32_t receive_uint32()
|
||||
{
|
||||
uint32_t value;
|
||||
value = (uint8_t)greentea_getc() << 24;
|
||||
value |= (uint8_t)greentea_getc() << 16;
|
||||
value |= (uint8_t)greentea_getc() << 8;
|
||||
value |= (uint8_t)greentea_getc();
|
||||
const uint8_t c[9] = { greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
'\0'
|
||||
};
|
||||
assert( unhexify( &value, c ) != 8 );
|
||||
return( (uint32_t)value );
|
||||
}
|
||||
|
||||
@ -132,7 +158,7 @@ uint8_t * receive_data( uint32_t * data_len )
|
||||
greentea_getc(); // read ';' received after key i.e. *data_len
|
||||
|
||||
for( i = 0; i < *data_len; i++ )
|
||||
data[i] = greentea_getc();
|
||||
data[i] = receive_byte();
|
||||
|
||||
/* Read closing braces */
|
||||
for( i = 0; i < 2; i++ )
|
||||
|
Reference in New Issue
Block a user