Merge branch 'development' into iotssl-1941-aria-ciphersuites

* development: (504 commits)
  Fix minor code style issues
  Add the uodate to the soversion to the ChangeLog
  Fix the ChangeLog for clarity, english and credit
  Update version to 2.9.0
  ecp: Fix binary compatibility with group ID
  Changelog entry
  Change accepted ciphersuite versions when parsing server hello
  Remove preprocessor directives around platform_util.h include
  Fix style for mbedtls_mpi_zeroize()
  Improve mbedtls_platform_zeroize() docs
  mbedtls_zeroize -> mbedtls_platform_zeroize in docs
  Reword config.h docs for MBEDTLS_PLATFORM_ZEROIZE_ALT
  Organize CMakeLists targets in alphabetical order
  Organize output objs in alfabetical order in Makefile
  Regenerate errors after ecp.h updates
  Update ecp.h
  Change variable bytes_written to header_bytes in record decompression
  Update ecp.h
  Update ecp.h
  Update ecp.h
  ...
This commit is contained in:
Manuel Pégourié-Gonnard 2018-05-22 15:58:50 +02:00
commit a3712beb9b
204 changed files with 7933 additions and 4006 deletions

241
scripts/abi_check.py Executable file
View file

@ -0,0 +1,241 @@
#!/usr/bin/env python3
"""
This file is part of Mbed TLS (https://tls.mbed.org)
Copyright (c) 2018, Arm Limited, All Rights Reserved
Purpose
This script is a small wrapper around the abi-compliance-checker and
abi-dumper tools, applying them to compare the ABI and API of the library
files from two different Git revisions within an Mbed TLS repository.
The results of the comparison are formatted as HTML and stored at
a configurable location. Returns 0 on success, 1 on ABI/API non-compliance,
and 2 if there is an error while running the script.
Note: must be run from Mbed TLS root.
"""
import os
import sys
import traceback
import shutil
import subprocess
import argparse
import logging
import tempfile
class AbiChecker(object):
def __init__(self, report_dir, old_rev, new_rev, keep_all_reports):
self.repo_path = "."
self.log = None
self.setup_logger()
self.report_dir = os.path.abspath(report_dir)
self.keep_all_reports = keep_all_reports
self.should_keep_report_dir = os.path.isdir(self.report_dir)
self.old_rev = old_rev
self.new_rev = new_rev
self.mbedtls_modules = ["libmbedcrypto", "libmbedtls", "libmbedx509"]
self.old_dumps = {}
self.new_dumps = {}
self.git_command = "git"
self.make_command = "make"
def check_repo_path(self):
current_dir = os.path.realpath('.')
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if current_dir != root_dir:
raise Exception("Must be run from Mbed TLS root")
def setup_logger(self):
self.log = logging.getLogger()
self.log.setLevel(logging.INFO)
self.log.addHandler(logging.StreamHandler())
def check_abi_tools_are_installed(self):
for command in ["abi-dumper", "abi-compliance-checker"]:
if not shutil.which(command):
raise Exception("{} not installed, aborting".format(command))
def get_clean_worktree_for_git_revision(self, git_rev):
self.log.info(
"Checking out git worktree for revision {}".format(git_rev)
)
git_worktree_path = tempfile.mkdtemp()
worktree_process = subprocess.Popen(
[self.git_command, "worktree", "add", git_worktree_path, git_rev],
cwd=self.repo_path,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
worktree_output, _ = worktree_process.communicate()
self.log.info(worktree_output.decode("utf-8"))
if worktree_process.returncode != 0:
raise Exception("Checking out worktree failed, aborting")
return git_worktree_path
def build_shared_libraries(self, git_worktree_path):
my_environment = os.environ.copy()
my_environment["CFLAGS"] = "-g -Og"
my_environment["SHARED"] = "1"
make_process = subprocess.Popen(
self.make_command,
env=my_environment,
cwd=git_worktree_path,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
make_output, _ = make_process.communicate()
self.log.info(make_output.decode("utf-8"))
if make_process.returncode != 0:
raise Exception("make failed, aborting")
def get_abi_dumps_from_shared_libraries(self, git_ref, git_worktree_path):
abi_dumps = {}
for mbed_module in self.mbedtls_modules:
output_path = os.path.join(
self.report_dir, "{}-{}.dump".format(mbed_module, git_ref)
)
abi_dump_command = [
"abi-dumper",
os.path.join(
git_worktree_path, "library", mbed_module + ".so"),
"-o", output_path,
"-lver", git_ref
]
abi_dump_process = subprocess.Popen(
abi_dump_command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
abi_dump_output, _ = abi_dump_process.communicate()
self.log.info(abi_dump_output.decode("utf-8"))
if abi_dump_process.returncode != 0:
raise Exception("abi-dumper failed, aborting")
abi_dumps[mbed_module] = output_path
return abi_dumps
def cleanup_worktree(self, git_worktree_path):
shutil.rmtree(git_worktree_path)
worktree_process = subprocess.Popen(
[self.git_command, "worktree", "prune"],
cwd=self.repo_path,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
worktree_output, _ = worktree_process.communicate()
self.log.info(worktree_output.decode("utf-8"))
if worktree_process.returncode != 0:
raise Exception("Worktree cleanup failed, aborting")
def get_abi_dump_for_ref(self, git_rev):
git_worktree_path = self.get_clean_worktree_for_git_revision(git_rev)
self.build_shared_libraries(git_worktree_path)
abi_dumps = self.get_abi_dumps_from_shared_libraries(
git_rev, git_worktree_path
)
self.cleanup_worktree(git_worktree_path)
return abi_dumps
def get_abi_compatibility_report(self):
compatibility_report = ""
compliance_return_code = 0
for mbed_module in self.mbedtls_modules:
output_path = os.path.join(
self.report_dir, "{}-{}-{}.html".format(
mbed_module, self.old_rev, self.new_rev
)
)
abi_compliance_command = [
"abi-compliance-checker",
"-l", mbed_module,
"-old", self.old_dumps[mbed_module],
"-new", self.new_dumps[mbed_module],
"-strict",
"-report-path", output_path
]
abi_compliance_process = subprocess.Popen(
abi_compliance_command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
abi_compliance_output, _ = abi_compliance_process.communicate()
self.log.info(abi_compliance_output.decode("utf-8"))
if abi_compliance_process.returncode == 0:
compatibility_report += (
"No compatibility issues for {}\n".format(mbed_module)
)
if not self.keep_all_reports:
os.remove(output_path)
elif abi_compliance_process.returncode == 1:
compliance_return_code = 1
self.should_keep_report_dir = True
compatibility_report += (
"Compatibility issues found for {}, "
"for details see {}\n".format(mbed_module, output_path)
)
else:
raise Exception(
"abi-compliance-checker failed with a return code of {},"
" aborting".format(abi_compliance_process.returncode)
)
os.remove(self.old_dumps[mbed_module])
os.remove(self.new_dumps[mbed_module])
if not self.should_keep_report_dir and not self.keep_all_reports:
os.rmdir(self.report_dir)
self.log.info(compatibility_report)
return compliance_return_code
def check_for_abi_changes(self):
self.check_repo_path()
self.check_abi_tools_are_installed()
self.old_dumps = self.get_abi_dump_for_ref(self.old_rev)
self.new_dumps = self.get_abi_dump_for_ref(self.new_rev)
return self.get_abi_compatibility_report()
def run_main():
try:
parser = argparse.ArgumentParser(
description=(
"""This script is a small wrapper around the
abi-compliance-checker and abi-dumper tools, applying them
to compare the ABI and API of the library files from two
different Git revisions within an Mbed TLS repository.
The results of the comparison are formatted as HTML and stored
at a configurable location. Returns 0 on success, 1 on ABI/API
non-compliance, and 2 if there is an error while running the
script. Note: must be run from Mbed TLS root."""
)
)
parser.add_argument(
"-r", "--report-dir", type=str, default="reports",
help="directory where reports are stored, default is reports",
)
parser.add_argument(
"-k", "--keep-all-reports", action="store_true",
help="keep all reports, even if there are no compatibility issues",
)
parser.add_argument(
"-o", "--old-rev", type=str, help="revision for old version",
required=True
)
parser.add_argument(
"-n", "--new-rev", type=str, help="revision for new version",
required=True
)
abi_args = parser.parse_args()
abi_check = AbiChecker(
abi_args.report_dir, abi_args.old_rev,
abi_args.new_rev, abi_args.keep_all_reports
)
return_code = abi_check.check_for_abi_changes()
sys.exit(return_code)
except Exception:
traceback.print_exc()
sys.exit(2)
if __name__ == "__main__":
run_main()

View file

@ -17,7 +17,7 @@
#
# Full usage description provided below.
#
# Things that shouldn't be enabled with "full".
# The following options are disabled instead of enabled with "full".
#
# MBEDTLS_TEST_NULL_ENTROPY
# MBEDTLS_DEPRECATED_REMOVED
@ -30,6 +30,7 @@
# MBEDTLS_NO_PLATFORM_ENTROPY
# MBEDTLS_REMOVE_ARC4_CIPHERSUITES
# MBEDTLS_SSL_HW_RECORD_ACCEL
# MBEDTLS_RSA_NO_CRT
# MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
# - this could be enabled if the respective tests were adapted
@ -86,6 +87,7 @@ MBEDTLS_ECP_DP_M383_ENABLED
MBEDTLS_ECP_DP_M511_ENABLED
MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
MBEDTLS_NO_PLATFORM_ENTROPY
MBEDTLS_RSA_NO_CRT
MBEDTLS_REMOVE_ARC4_CIPHERSUITES
MBEDTLS_SSL_HW_RECORD_ACCEL
MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3

View file

@ -11,7 +11,6 @@
#
# 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
@ -102,11 +101,7 @@ log "mbed TLS $MBEDTLS_VERSION$GIT_VERSION"
log "$( arm-none-eabi-gcc --version | head -n1 )"
log "CFLAGS=$ARMGCC_FLAGS"
# creates the yotta config
yotta/create-module.sh >/dev/null
doit default include/mbedtls/config.h
doit yotta yotta/module/mbedtls/config.h
doit thread configs/config-thread.h
doit suite-b configs/config-suite-b.h
doit psk configs/config-ccm-psk-tls1_2.h

View file

@ -47,7 +47,14 @@ close(FORMAT_FILE);
$/ = $line_separator;
open(GREP, "grep \"define MBEDTLS_ERR_\" $include_dir/* |") || die("Failure when calling grep: $!");
my @files = <$include_dir/*.h>;
my @matches;
foreach my $file (@files) {
open(FILE, "$file");
my @grep_res = grep(/^\s*#define\s+MBEDTLS_ERR_\w+\s+\-0x[0-9A-Fa-f]+/, <FILE>);
push(@matches, @grep_res);
close FILE;
}
my $ll_old_define = "";
my $hl_old_define = "";
@ -59,7 +66,8 @@ my $headers = "";
my %error_codes_seen;
while (my $line = <GREP>)
foreach my $line (@matches)
{
next if ($line =~ /compat-1.2.h/);
my ($error_name, $error_code) = $line =~ /(MBEDTLS_ERR_\w+)\s+\-(0x\w+)/;

View file

@ -47,13 +47,15 @@ print_version()
print_version "uname" "-a" ""
echo
: ${ARMC5_CC:=armcc}
print_version "$ARMC5_CC" "--vsn" "armcc not found!" "head -n 2"
echo
if [ "${RUN_ARMCC:-1}" -ne 0 ]; then
: "${ARMC5_CC:=armcc}"
print_version "$ARMC5_CC" "--vsn" "armcc not found!" "head -n 2"
echo
: ${ARMC6_CC:=armclang}
print_version "$ARMC6_CC" "--vsn" "armclang not found!" "head -n 2"
echo
: "${ARMC6_CC:=armclang}"
print_version "$ARMC6_CC" "--vsn" "armclang not found!" "head -n 2"
echo
fi
print_version "arm-none-eabi-gcc" "--version" "gcc-arm not found!" "head -n 1"
echo