Commit graph

1450 commits

Author SHA1 Message Date
Andres Amaya Garcia f7cf56fa45 Fix integer overflows in buffer bound checks
Fix potential integer overflows in the following functions:
  * mbedtls_md2_update() to be bypassed and cause
  * mbedtls_cipher_update()
  * mbedtls_ctr_drbg_reseed()
This overflows would mainly be exploitable in 32-bit systems and could
cause buffer bound checks to be bypassed.
2017-02-08 12:04:24 +00:00
Andres AG f535662894 Add tests for overreads in pem_read_buffer() 2017-02-08 12:03:46 +00:00
Simon Butcher 1d4db5b7b5 Merge 'iotssl-1099-incorrect-renego-dtls'
Fix an incorrect condition in ssl_check_ctr_renegotiate() that compared
64 bits of record counter instead of 48 bits as described in RFC 6347
Section 4.3.1. This would cause the function's return value to be
occasionally incorrect and the renegotiation routines to be triggered
at unexpected times.
2017-02-02 23:47:08 +00:00
Andres AG 9060d4da08 Fix generate_code.pl to handle escaped : 2017-02-02 14:38:13 +00:00
Andres AG 9f430c15d8 Add tests for out flags from x509_crt_verify_top()
The tests load certificate chains from files. The CA chains contain a
past or future certificate and an invalid certificate. The test then
checks that the flags set are MBEDTLS_X509_BADCERT_EXPIRED or
MBEDTLS_X509_BADCERT_FUTURE.
2017-01-20 13:52:01 +00:00
Andres AG a39db394db Add test for infinite loop in CRL parse 2017-01-19 17:10:51 +00:00
Andres AG 692ad84e5c Add DTLS test to check 6 byte record ctr is cmp
Add a test to ssl-opt.sh to ensure that in DTLS a 6 byte record counter
is compared in ssl_check_ctr_renegotiate() instead of a 8 byte one as in
the TLS case. Because currently there are no testing facilities to check
that renegotiation routines are triggered after X number of input/output
messages, the test consists on setting a renegotiation period that
cannot be represented in 6 bytes, but whose least-significant byte is 2.
If the library behaves correctly, the renegotiation routines will be
executed after two exchanged.
2017-01-19 16:30:57 +00:00
Simon Butcher cb587009d6 Fix all.sh test builds with recent glibc and clang
Fixes strict C99 builds in all.sh with glibc version >2.19 where platform support
wasn't being compiled in automatically.

Also fixes C99 syntax with armclang.
2017-01-06 16:14:44 +00:00
Simon Butcher 105e856143 Merge branch 'gcc-compiler-warnings' 2017-01-05 18:26:40 +00:00
Simon Butcher 49f00bd81d Clarify use of armcc in all.sh 2017-01-05 16:20:56 +00:00
Andres AG a5cd973047 Add -march argument to armc6 build tests 2017-01-05 10:15:00 +00:00
Andres AG 31f9b5bdd8 Modify output_env.sh to make it extensible 2017-01-05 10:14:51 +00:00
Andres AG 87bb577cfb Add ARM Compiler 6 build tests to all.sh 2017-01-03 10:12:11 +00:00
Simon Butcher 710dd4fdd6 Merge branch 'speedup_tests'
Pull Request #533 - Use MAKEFLAGS to pass args to make in all.sh

Modify the script at tests/scripts/all.sh to export the variable
MAKEFLAGS with -j if it was not set before. This should decrease the
total runtime of tests/scripts/all.sh by letting make run multiple jobs
in parallel. Also, add a check at the top of the script to cause a
failure if the environment is not Linux.w
2016-12-30 19:09:40 +00:00
Janos Follath 1808dc01bd Update library version number to 2.4.1 2016-12-13 16:00:52 +00:00
Andres AG 9c94b6951c Add tests for overreads in pem_read_buffer() 2016-11-21 11:03:40 +00:00
Simon B d473c1f359 Remove need for elevated command line in Windows
Changes use of mklink in Windows test builds, to create junctions instead of
directory symbolic links. This removes the need for an elevated command prompt
when running cmake to create the Visual Studio project files.
2016-11-17 16:04:33 +00:00
Simon Butcher 002bc6262b Make mingw test build a requirement of all.sh
Changed the mingw test build to be a required test of the all.sh script.
2016-11-17 09:27:45 +00:00
Simon Butcher 91aef33832 Fix mingw test build to avoid executing the tests
Changed the mingw build target to avoid building mingw test suites and
then attempting to run them which was failing on Linux.
2016-11-17 09:22:47 +00:00
Simon Butcher f95c1764fa Make the test builds much stricter for warnings
Tighten up the test options in all.sh, test-ref-configs.pl and curves.pl
to ensure the builds are strict for all warnings, warnings are treated
as errors, and that wherever possible builds are strict to the C99
standard. (Note that builds that use the Unix sockets API cannot be).
2016-11-17 09:22:46 +00:00
Andres AG ea67eeb4e8 Remove unused var warnings in windows unittests 2016-11-10 17:22:12 +00:00
Simon B 9b3e3c4942 Fix config of compiler warning flags with MSVC
Compiler warnings were being configured twice and not suppressed on the
test suites with Microsoft Visual Studio.
2016-11-10 15:37:33 +00:00
Simon Butcher 16c54ee9c8 Update library version number to 2.4.0 2016-10-16 19:34:39 +01:00
Simon Butcher 8e00410402 Merge fix for AEAD Random IVs 2016-10-14 00:48:33 +01:00
Simon Butcher 9800a058ae Merge branch 'development' 2016-10-13 17:25:56 +01:00
Simon Butcher 99000142cb Merge fix for IE Certificate Compatibility 2016-10-13 17:21:01 +01:00
Simon Butcher 488c08c00b Merge branch fixing date validity in X.509 2016-10-13 16:13:09 +01:00
Janos Follath f45dab1939 Fix global variable shadowing 2016-10-13 13:54:48 +01:00
Simon Butcher 6437b221a3 Fix stdio redirection memory leak in test suites 2016-10-13 13:54:48 +01:00
Janos Follath e5dc202469 Restore P>Q in RSA key generation (#558)
The PKCS#1 standard says nothing about the relation between P and Q
but many libraries guarantee P>Q and mbed TLS did so too in earlier
versions.

This commit restores this behaviour.
2016-10-13 13:54:48 +01:00
Janos Follath d7b9049806 Fix memory leaks in CMAC tests 2016-10-13 13:53:56 +01:00
Andres AG fe4db8f575 Fix memory leak in test_suite_cmac.function 2016-10-13 13:53:56 +01:00
Andres AG f04f54d432 Add seed cmdline arg to test scripts 2016-10-13 13:53:33 +01:00
Janos Follath 2d9c46767a Fix minor style issues in test framework 2016-10-13 13:53:13 +01:00
Simon Butcher 33388669ec Fix to test output in test suites
Fixes the test suites to consistently use mbedtls_fprintf to output to
stdout or stderr.

Also redirects output from the tests to /dev/null to avoid confusing
output if the test suite code or library outputs anything to stdout.
2016-10-13 13:53:13 +01:00
Simon Butcher 8739aa9403 Fix exit and formatting in CMAC test suite
Minor fixes following review.
2016-10-13 13:53:13 +01:00
Simon Butcher 03faeac7ec Add CMAC test suite to CMakeLists.txt 2016-10-13 13:53:13 +01:00
Simon Butcher c3db62fd51 Extend test coverage of CMAC
Expands tests to include NULL tests and successive calls to
mbedtls_cipher_cmac_update() and mbedtls_cipher_cmac_reset().
2016-10-13 13:53:13 +01:00
Andres AG 8254b6c9f3 Clean up of formatting, and potential integer overflow fix 2016-10-13 13:51:13 +01:00
Simon Butcher f394e09431 Clean up and minor fixes following review
Minor fixes following review including:
    * formatting changes including indentation and code style
    * corrections
    * removal of debug code
    * clarification of code through variable renaming
    * memory leak
    * compiler warnings
2016-10-13 13:51:12 +01:00
Simon Butcher 937fddbfcb Introduce a CMAC specific test suite 2016-10-13 13:51:11 +01:00
Andres AG 42547d0cf7 Set selftest verbose flag to boost coverage 2016-10-13 13:48:48 +01:00
Andres AG 84c46db746 Fix scripts to support multiple openssl and gnutls 2016-10-13 13:48:48 +01:00
Andres AG 3616f6f261 Rename net.{c,h} to net_sockets.{c,h}
The library/net.c and its corresponding include/mbedtls/net.h file are
renamed to library/net_sockets.c and include/mbedtls/net_sockets.h
respectively. This is to avoid naming collisions in projects which also
have files with the common name 'net'.
2016-10-13 13:48:48 +01:00
Simon Butcher 1c8b33ad19 Merge branch 'development' 2016-10-13 13:40:41 +01:00
Janos Follath e709f7c9e0 Fix global variable shadowing 2016-10-13 13:20:12 +01:00
Simon Butcher e019296ab7 Fix stdio redirection memory leak in test suites 2016-10-13 10:03:08 +01:00
Janos Follath ef44178474 Restore P>Q in RSA key generation (#558)
The PKCS#1 standard says nothing about the relation between P and Q
but many libraries guarantee P>Q and mbed TLS did so too in earlier
versions.

This commit restores this behaviour.
2016-10-13 00:25:07 +01:00
Janos Follath 99d09d2747 Fix memory leaks in CMAC tests 2016-10-12 15:32:54 +01:00
Andres AG c4424c0a69 Fix memory leak in test_suite_cmac.function 2016-10-12 15:32:53 +01:00
Janos Follath d444358247 Fix memory leaks in CMAC tests 2016-10-12 14:31:01 +01:00
Andres AG 8abc6b86f9 Fix memory leak in test_suite_cmac.function 2016-10-12 00:40:16 +01:00
Andres AG c47857dbf4 Add seed cmdline arg to test scripts 2016-10-12 00:36:31 +01:00
Andres AG 7770ea82d5 Add seed cmdline arg to test scripts 2016-10-12 00:32:17 +01:00
Andres AG e0af995f12 Add test for bounds in X509 DER write funcs 2016-10-11 14:07:48 +01:00
Janos Follath 8ca53b51c5 Fix minor style issues in test framework 2016-10-11 12:25:34 +01:00
Simon Butcher 2573136fa8 Fix to test output in test suites
Fixes the test suites to consistently use mbedtls_fprintf to output to
stdout or stderr.

Also redirects output from the tests to /dev/null to avoid confusing
output if the test suite code or library outputs anything to stdout.
2016-10-11 12:25:34 +01:00
Simon Butcher bd8d221920 Fix exit and formatting in CMAC test suite
Minor fixes following review.
2016-10-11 12:25:04 +01:00
Simon Butcher 53da6ae842 Add CMAC test suite to CMakeLists.txt 2016-10-11 12:25:04 +01:00
Simon Butcher 33183fd408 Extend test coverage of CMAC
Expands tests to include NULL tests and successive calls to
mbedtls_cipher_cmac_update() and mbedtls_cipher_cmac_reset().
2016-10-11 12:25:04 +01:00
Andres AG a592dcc1c6 Clean up of formatting, and potential integer overflow fix 2016-10-06 15:23:39 +01:00
Simon Butcher 69283e51d5 Clean up and minor fixes following review
Minor fixes following review including:
    * formatting changes including indentation and code style
    * corrections
    * removal of debug code
    * clarification of code through variable renaming
    * memory leak
    * compiler warnings
2016-10-06 12:49:58 +01:00
Simon Butcher d812fa69d9 Introduce a CMAC specific test suite 2016-10-05 14:19:18 +01:00
Andres AG 4b76aecaf3 Add check for validity of date in x509_get_time() 2016-09-28 14:32:54 +01:00
Andres AG 93012e8bce Set selftest verbose flag to boost coverage 2016-09-27 17:29:22 +01:00
Andres AG b2fdd04f6a Fix scripts to support multiple openssl and gnutls 2016-09-27 16:04:44 +01:00
Andres AG 788aa4a812 Rename net.{c,h} to net_sockets.{c,h}
The library/net.c and its corresponding include/mbedtls/net.h file are
renamed to library/net_sockets.c and include/mbedtls/net_sockets.h
respectively. This is to avoid naming collisions in projects which also
have files with the common name 'net'.
2016-09-26 23:23:52 +01:00
Andres AG 38495a3824 Use MAKEFLAGS to pass args to make in all.sh
Modify the script at tests/scripts/all.sh to export the variable
MAKEFLAGS with -j if it was not set before. This should decrease the
total runtime of tests/scripts/all.sh by letting make run multiple jobs
in parallel. Also, add a check at the top of the script to cause a
failure if the environment is not Linux.
2016-09-22 17:01:13 +01:00
Simon Butcher 41eeccf76b Fix merge of OpenSSL/GNUTLS version options in all.sh 2016-09-15 20:45:53 +01:00
Andres AG f181e25e5b Remove specific GnuTLS and OpenSSL version requirements 2016-09-15 20:45:53 +01:00
Andres AG f07314e787 Allow cmake 'out-of-source' builds
Allow mbed TLS to be build in a subdirectory. Also add a test in
all.sh
2016-09-15 20:45:53 +01:00
Andres AG d9eba4ba3d Allow alternate openssl and gnutls in all.sh
Allow the user to specify alternative openssl, gnutls-cli and
gnutls-serv binaries to execute legacy tests in all.sh.
2016-09-15 20:45:53 +01:00
Simon Butcher b7f45c54a7 Fixes for entropy test suite for some configurations
Changes to allow the entropy tests to work for configurations without an
entropy seed file (MBEDTLS_ENTROPY_NV_SEED), and with no entropy sources
configured (MBEDTLS_TEST_NULL_ENTROPY).
2016-09-15 18:42:26 +01:00
Simon Butcher 8e3afc7332 Removes duplicated selftests from all.sh
All selftests are now called from the test suites so don't need to be executed
explicitly in tests/scripts/all.sh
2016-09-15 17:13:08 +01:00
Andres AG dc192215f4 Allow cmake 'out-of-source' builds
Allow mbed TLS to be build in a subdirectory. Also add a test in
all.sh
2016-09-06 20:38:40 +01:00
Simon Butcher ac22d1113c Remove references to PolarSSL in compat.sh
Removed references to PolarSSL for mbed TLS for clarity.
2016-09-05 13:17:25 +01:00
Simon Butcher 7dda0dd038 Fix typo in dependency in test_suite_debug.data 2016-09-04 15:14:38 +01:00
palaviv f180df99a9 Added needed ECDSA dependencies to test_suite_x509parse.data 2016-09-04 15:14:38 +01:00
palaviv 00cb9c5c08 Added needed HASH dependencies to tests/suites/test_suite_pkparse.data 2016-09-04 15:14:38 +01:00
palaviv 1472f11608 Added needed HASH dependencies to test_suite_debug.data 2016-09-04 15:14:38 +01:00
palaviv a07ecda04e Added needed HASH dependencies to test_suite_x509parse.data 2016-09-04 15:14:38 +01:00
Janos Follath 74537a69fd ECJPAKE: Fix intermittently failing tests
In some tests in ssl-opt.sh the client finishes sooner and the server
gets killed before it could reach certain errors. Consequently the
the script doesn't find the error it is looking for and the test fails.

To resolve this issue, we introduce a per-test option to wait after the
client finishes.
2016-09-03 18:19:12 +03:00
Andres AG e7723ec284 Make entropy bias self test poll multiple times
Instead of polling the hardware entropy source a single time and
comparing the output with itself, the source is polled at least twice
and make sure that the separate outputs are different.
2016-08-30 16:50:48 +01:00
Andres AG b34e42e69e Add a new self test to entropy module
The self test is a quick way to check at startup whether the entropy
sources are functioning correctly. The self test only polls 8 bytes
from the default entropy source and performs the following checks:

- The bytes are not all 0x00 or 0xFF.
- The hardware does not return an error when polled.
- The entropy does not provide data in a patter. Only check pattern
  at byte, word and long word sizes.
2016-08-30 16:50:48 +01:00
Andres AG 99b257ca19 Fix memory leak in test_suite_md.function 2016-08-26 17:21:14 +01:00
Paul Bakker 4b8bc5228a Removed running selftest program from basic-build-test.sh
All self tests are run in the unit test framework as well.
2016-08-25 16:36:35 +01:00
Paul Bakker 03091e1e6a Remove stale Makefile lines for old test suite 2016-08-25 16:36:35 +01:00
Paul Bakker 50157ff5ab Add new timing test suite that runs the timing self test 2016-08-25 16:36:35 +01:00
Paul Bakker 81c60910e1 Run PKCS#5 selftest in test suites 2016-08-25 16:36:35 +01:00
Simon Butcher 80cd444978 Adds missing dependency to AES special case tests
Added MBEDTLS_AES_C to the AES cipher special behaviours test case.
2016-08-25 15:42:28 +01:00
Paul Bakker 5c57e02b1d Fix style issues in test_suite_md.function 2016-08-25 15:42:28 +01:00
Paul Bakker 6a9c725652 Add Cipher layer corner case test coverage 2016-08-25 15:42:28 +01:00
Paul Bakker 185ccf7070 Add coverage for CTR-DRBG corner case function behaviours 2016-08-25 15:42:28 +01:00
Paul Bakker ec5ceb65d6 Test invalid bit value in mbedtls_mpi_set_bit() 2016-08-25 15:42:28 +01:00
Paul Bakker c7d6bd4b5f Add mbedtls_asn1_write_len() support for 3 and 4 byte lengths
As a consequence also adds coverage for reading 3 and 4 byte lengths
(which were not covered before)
2016-08-25 15:42:27 +01:00
Paul Bakker 5e8b77cd8c Test result of mbedtls_asn1_write_len() through mbedtls_asn1_get_len() 2016-08-25 15:42:27 +01:00
Paul Bakker 58bfb83bb0 Add buffer length tests for mbedtls_asn1_write_len() 2016-08-25 15:42:27 +01:00
Paul Bakker e325db9055 Add explicit test coverage for mbedtls_asn1_write_len() 2016-08-25 15:42:27 +01:00
Paul Bakker 97c53c2867 Add coverage testing of mbedtls_md_clone() (and wraps)
+13 functions, +57 lines
2016-08-25 15:42:27 +01:00
Paul Bakker e35afa28f7 Update *_multi tests in test_suite_md to do more than 1 step 2016-08-25 15:42:27 +01:00