mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-23 15:55:10 +01:00
Merge branch 'development' into iotssl-2257-chacha-poly-primitives
* development: (97 commits) Updated version number to 2.10.0 for release Add a disabled CMAC define in the no-entropy configuration Adapt the ARIA test cases for new ECB function Fix file permissions for ssl.h Add ChangeLog entry for PR#1651 Fix MicroBlaze register typo. Fix typo in doc and copy missing warning Fix edit mistake in cipher_wrap.c Update CTR doc for the 64-bit block cipher Update CTR doc for other 128-bit block ciphers Slightly tune ARIA CTR documentation Remove double declaration of mbedtls_ssl_list_ciphersuites Update CTR documentation Use zeroize function from new platform_util Move to new header style for ALT implementations Add ifdef for selftest in header file Fix typo in comments Use more appropriate type for local variable Remove useless parameter from function Wipe sensitive info from the stack ...
This commit is contained in:
commit
39b1904b9f
47 changed files with 3422 additions and 592 deletions
|
|
@ -100,6 +100,7 @@ YOTTA=1
|
|||
# Default commands, can be overriden by the environment
|
||||
: ${OPENSSL:="openssl"}
|
||||
: ${OPENSSL_LEGACY:="$OPENSSL"}
|
||||
: ${OPENSSL_NEXT:="$OPENSSL"}
|
||||
: ${GNUTLS_CLI:="gnutls-cli"}
|
||||
: ${GNUTLS_SERV:="gnutls-serv"}
|
||||
: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
|
||||
|
|
@ -144,15 +145,26 @@ Tool path options:
|
|||
--gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
|
||||
--openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
|
||||
--openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
|
||||
--openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
|
||||
EOF
|
||||
}
|
||||
|
||||
# remove built files as well as the cmake cache/config
|
||||
cleanup()
|
||||
{
|
||||
if [ -n "${MBEDTLS_ROOT_DIR+set}" ]; then
|
||||
cd "$MBEDTLS_ROOT_DIR"
|
||||
fi
|
||||
|
||||
command make clean
|
||||
|
||||
find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
|
||||
# Remove CMake artefacts
|
||||
find . -name .git -prune -o -name yotta -prune -o \
|
||||
-iname CMakeFiles -exec rm -rf {} \+ -o \
|
||||
\( -iname cmake_install.cmake -o \
|
||||
-iname CTestTestfile.cmake -o \
|
||||
-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
|
||||
|
|
@ -235,6 +247,7 @@ while [ $# -gt 0 ]; do
|
|||
--no-yotta) YOTTA=0;;
|
||||
--openssl) shift; OPENSSL="$1";;
|
||||
--openssl-legacy) shift; OPENSSL_LEGACY="$1";;
|
||||
--openssl-next) shift; OPENSSL_NEXT="$1";;
|
||||
--out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
|
||||
--random-seed) unset SEED;;
|
||||
--release-test|-r) SEED=1;;
|
||||
|
|
@ -356,6 +369,7 @@ echo "FORCE: $FORCE"
|
|||
echo "SEED: ${SEED-"UNSET"}"
|
||||
echo "OPENSSL: $OPENSSL"
|
||||
echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
|
||||
echo "OPENSSL_NEXT: $OPENSSL_NEXT"
|
||||
echo "GNUTLS_CLI: $GNUTLS_CLI"
|
||||
echo "GNUTLS_SERV: $GNUTLS_SERV"
|
||||
echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
|
||||
|
|
@ -380,7 +394,8 @@ if [ -n "${SEED-}" ]; then
|
|||
fi
|
||||
|
||||
# Make sure the tools we need are available.
|
||||
check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
|
||||
check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
|
||||
"$GNUTLS_CLI" "$GNUTLS_SERV" \
|
||||
"$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
|
||||
"arm-none-eabi-gcc" "i686-w64-mingw32-gcc" "gdb"
|
||||
if [ $RUN_ARMCC -ne 0 ]; then
|
||||
|
|
@ -419,6 +434,10 @@ tests/scripts/check-generated-files.sh
|
|||
msg "test: doxygen markup outside doxygen blocks" # < 1s
|
||||
tests/scripts/check-doxy-blocks.pl
|
||||
|
||||
msg "test: check-files.py" # < 1s
|
||||
cleanup
|
||||
tests/scripts/check-files.py
|
||||
|
||||
msg "test/build: declared and exported names" # < 3s
|
||||
cleanup
|
||||
tests/scripts/check-names.sh
|
||||
|
|
@ -524,6 +543,9 @@ if_build_succeeded tests/ssl-opt.sh -f Default
|
|||
msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
|
||||
if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
|
||||
|
||||
msg "test: compat.sh ARIA"
|
||||
if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA'
|
||||
|
||||
msg "test/build: curves.pl (gcc)" # ~ 4 min
|
||||
cleanup
|
||||
record_status tests/scripts/curves.pl
|
||||
|
|
@ -910,8 +932,20 @@ make
|
|||
|
||||
msg "test: cmake 'out-of-source' build"
|
||||
make test
|
||||
# Test an SSL option that requires an auxiliary script in test/scripts/.
|
||||
# Also ensure that there are no error messages such as
|
||||
# "No such file or directory", which would indicate that some required
|
||||
# file is missing (ssl-opt.sh tolerates the absence of some files so
|
||||
# may exit with status 0 but emit errors).
|
||||
if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err
|
||||
if [ -s ssl-opt.err ]; then
|
||||
cat ssl-opt.err >&2
|
||||
record_status [ ! -s ssl-opt.err ]
|
||||
rm ssl-opt.err
|
||||
fi
|
||||
cd "$MBEDTLS_ROOT_DIR"
|
||||
rm -rf "$OUT_OF_SOURCE_DIR"
|
||||
unset MBEDTLS_ROOT_DIR
|
||||
|
||||
for optimization_flag in -O2 -O3 -Ofast -Os; do
|
||||
for compiler in clang gcc; do
|
||||
|
|
|
|||
223
tests/scripts/check-files.py
Executable file
223
tests/scripts/check-files.py
Executable file
|
|
@ -0,0 +1,223 @@
|
|||
#!/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 checks the current state of the source code for minor issues,
|
||||
including incorrect file permissions, presence of tabs, non-Unix line endings,
|
||||
trailing whitespace, presence of UTF-8 BOM, and TODO comments.
|
||||
Note: requires python 3, must be run from Mbed TLS root.
|
||||
"""
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import codecs
|
||||
import sys
|
||||
|
||||
|
||||
class IssueTracker(object):
|
||||
"""Base class for issue tracking. Issues should inherit from this and
|
||||
overwrite either issue_with_line if they check the file line by line, or
|
||||
overwrite check_file_for_issue if they check the file as a whole."""
|
||||
|
||||
def __init__(self):
|
||||
self.heading = ""
|
||||
self.files_exemptions = []
|
||||
self.files_with_issues = {}
|
||||
|
||||
def should_check_file(self, filepath):
|
||||
for files_exemption in self.files_exemptions:
|
||||
if filepath.endswith(files_exemption):
|
||||
return False
|
||||
return True
|
||||
|
||||
def issue_with_line(self, line):
|
||||
raise NotImplementedError
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
for i, line in enumerate(iter(f.readline, b"")):
|
||||
self.check_file_line(filepath, line, i + 1)
|
||||
|
||||
def check_file_line(self, filepath, line, line_number):
|
||||
if self.issue_with_line(line):
|
||||
if filepath not in self.files_with_issues.keys():
|
||||
self.files_with_issues[filepath] = []
|
||||
self.files_with_issues[filepath].append(line_number)
|
||||
|
||||
def output_file_issues(self, logger):
|
||||
if self.files_with_issues.values():
|
||||
logger.info(self.heading)
|
||||
for filename, lines in sorted(self.files_with_issues.items()):
|
||||
if lines:
|
||||
logger.info("{}: {}".format(
|
||||
filename, ", ".join(str(x) for x in lines)
|
||||
))
|
||||
else:
|
||||
logger.info(filename)
|
||||
logger.info("")
|
||||
|
||||
|
||||
class PermissionIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Incorrect permissions:"
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
if not (os.access(filepath, os.X_OK) ==
|
||||
filepath.endswith((".sh", ".pl", ".py"))):
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
class EndOfFileNewlineIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Missing newline at end of file:"
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
if not f.read().endswith(b"\n"):
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
class Utf8BomIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "UTF-8 BOM present:"
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
if f.read().startswith(codecs.BOM_UTF8):
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
class LineEndingIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Non Unix line endings:"
|
||||
|
||||
def issue_with_line(self, line):
|
||||
return b"\r" in line
|
||||
|
||||
|
||||
class TrailingWhitespaceIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Trailing whitespace:"
|
||||
self.files_exemptions = [".md"]
|
||||
|
||||
def issue_with_line(self, line):
|
||||
return line.rstrip(b"\r\n") != line.rstrip()
|
||||
|
||||
|
||||
class TabIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Tabs present:"
|
||||
self.files_exemptions = [
|
||||
"Makefile", "generate_visualc_files.pl"
|
||||
]
|
||||
|
||||
def issue_with_line(self, line):
|
||||
return b"\t" in line
|
||||
|
||||
|
||||
class TodoIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "TODO present:"
|
||||
self.files_exemptions = [
|
||||
__file__, "benchmark.c", "pull_request_template.md"
|
||||
]
|
||||
|
||||
def issue_with_line(self, line):
|
||||
return b"todo" in line.lower()
|
||||
|
||||
|
||||
class IntegrityChecker(object):
|
||||
|
||||
def __init__(self, log_file):
|
||||
self.check_repo_path()
|
||||
self.logger = None
|
||||
self.setup_logger(log_file)
|
||||
self.files_to_check = (
|
||||
".c", ".h", ".sh", ".pl", ".py", ".md", ".function", ".data",
|
||||
"Makefile", "CMakeLists.txt", "ChangeLog"
|
||||
)
|
||||
self.issues_to_check = [
|
||||
PermissionIssueTracker(),
|
||||
EndOfFileNewlineIssueTracker(),
|
||||
Utf8BomIssueTracker(),
|
||||
LineEndingIssueTracker(),
|
||||
TrailingWhitespaceIssueTracker(),
|
||||
TabIssueTracker(),
|
||||
TodoIssueTracker(),
|
||||
]
|
||||
|
||||
def check_repo_path(self):
|
||||
if not all(os.path.isdir(d) for d in ["include", "library", "tests"]):
|
||||
raise Exception("Must be run from Mbed TLS root")
|
||||
|
||||
def setup_logger(self, log_file, level=logging.INFO):
|
||||
self.logger = logging.getLogger()
|
||||
self.logger.setLevel(level)
|
||||
if log_file:
|
||||
handler = logging.FileHandler(log_file)
|
||||
self.logger.addHandler(handler)
|
||||
else:
|
||||
console = logging.StreamHandler()
|
||||
self.logger.addHandler(console)
|
||||
|
||||
def check_files(self):
|
||||
for root, dirs, files in sorted(os.walk(".")):
|
||||
for filename in sorted(files):
|
||||
filepath = os.path.join(root, filename)
|
||||
if (os.path.join("yotta", "module") in filepath or
|
||||
not filepath.endswith(self.files_to_check)):
|
||||
continue
|
||||
for issue_to_check in self.issues_to_check:
|
||||
if issue_to_check.should_check_file(filepath):
|
||||
issue_to_check.check_file_for_issue(filepath)
|
||||
|
||||
def output_issues(self):
|
||||
integrity_return_code = 0
|
||||
for issue_to_check in self.issues_to_check:
|
||||
if issue_to_check.files_with_issues:
|
||||
integrity_return_code = 1
|
||||
issue_to_check.output_file_issues(self.logger)
|
||||
return integrity_return_code
|
||||
|
||||
|
||||
def run_main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"This script checks the current state of the source code for "
|
||||
"minor issues, including incorrect file permissions, "
|
||||
"presence of tabs, non-Unix line endings, trailing whitespace, "
|
||||
"presence of UTF-8 BOM, and TODO comments. "
|
||||
"Note: requires python 3, must be run from Mbed TLS root."
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l", "--log_file", type=str, help="path to optional output log",
|
||||
)
|
||||
check_args = parser.parse_args()
|
||||
integrity_check = IntegrityChecker(check_args.log_file)
|
||||
integrity_check.check_files()
|
||||
return_code = integrity_check.output_issues()
|
||||
sys.exit(return_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_main()
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/sh
|
||||
#! /usr/bin/env sh
|
||||
|
||||
# check if generated files are up-to-date
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018, ARM Limited, All Rights Reserved
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
# Check if generated files are up-to-date.
|
||||
|
||||
set -eu
|
||||
|
||||
|
|
@ -11,14 +17,53 @@ fi
|
|||
|
||||
check()
|
||||
{
|
||||
FILE=$1
|
||||
SCRIPT=$2
|
||||
SCRIPT=$1
|
||||
TO_CHECK=$2
|
||||
PATTERN=""
|
||||
FILES=""
|
||||
|
||||
if [ -d $TO_CHECK ]; then
|
||||
for FILE in $TO_CHECK/*; do
|
||||
FILES="$FILE $FILES"
|
||||
done
|
||||
else
|
||||
FILES=$TO_CHECK
|
||||
fi
|
||||
|
||||
for FILE in $FILES; do
|
||||
cp $FILE $FILE.bak
|
||||
done
|
||||
|
||||
cp $FILE $FILE.bak
|
||||
$SCRIPT
|
||||
diff $FILE $FILE.bak
|
||||
mv $FILE.bak $FILE
|
||||
|
||||
# Compare the script output to the old files and remove backups
|
||||
for FILE in $FILES; do
|
||||
if ! diff $FILE $FILE.bak >/dev/null 2>&1; then
|
||||
echo "'$FILE' was either modified or deleted by '$SCRIPT'"
|
||||
exit 1
|
||||
fi
|
||||
mv $FILE.bak $FILE
|
||||
|
||||
if [ -d $TO_CHECK ]; then
|
||||
# Create a grep regular expression that we can check against the
|
||||
# directory contents to test whether new files have been created
|
||||
if [ -z $PATTERN ]; then
|
||||
PATTERN="$(basename $FILE)"
|
||||
else
|
||||
PATTERN="$PATTERN\|$(basename $FILE)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -d $TO_CHECK ]; then
|
||||
# Check if there are any new files
|
||||
if ls -1 $TO_CHECK | grep -v "$PATTERN" >/dev/null 2>&1; then
|
||||
echo "Files were created by '$SCRIPT'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check library/error.c scripts/generate_errors.pl
|
||||
check library/version_features.c scripts/generate_features.pl
|
||||
check scripts/generate_errors.pl library/error.c
|
||||
check scripts/generate_features.pl library/version_features.c
|
||||
check scripts/generate_visualc_files.pl visualc/VS2010
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue