Commit Graph

7140 Commits

Author SHA1 Message Date
Jaeden Amero
68b60b0090 Merge remote-tracking branch 'origin/pr/2740' into mbedtls-2.7
* origin/pr/2740:
  Split _abi_compliance_command into smaller functions
  Record the commits that were compared
  Document how to build the typical argument for -s
  Allow running /somewhere/else/path/to/abi_check.py
2019-07-09 13:56:15 +01:00
Jaeden Amero
76fda568b7 Merge remote-tracking branch 'origin/mbedtls-2.7' into mbedtls-2.7-restricted
* origin/mbedtls-2.7:
  Changelog entry for HAVEGE fix
  Prevent building the HAVEGE module on platforms where it doesn't work
  Fix misuse of signed ints in the HAVEGE module
2019-07-09 13:23:42 +01:00
k-stachowiak
0f16adace4 Add a test for mlaformed ECJPAKE context 2019-07-09 10:22:13 +02:00
k-stachowiak
202b1df5ba Fix handling of md failure
The failure of mbedtls_md was not checked in one place. This could have led
to an incorrect computation if a hardware accelerator failed. In most cases
this would have led to the key exchange failing, so the impact would have been
a hard-to-diagnose error reported in the wrong place. If the two sides of the
key exchange failed in the same way with an output from mbedtls_md that was
independent of the input, this could have led to an apparently successful key
exchange with a predictable key, thus a glitching md accelerator could have
caused a security vulnerability.
2019-07-08 15:26:09 +02:00
Gilles Peskine
b14b7305c6 Split _abi_compliance_command into smaller functions
This makes the code easier to read and pacifies pylint.
2019-07-05 17:06:42 +02:00
Gilles Peskine
2b3f1346ef Record the commits that were compared
Record the commit ID in addition to the symbolic name of the version
being tested. This makes it easier to figure out what has been
compared when reading logs that don't always indicate explicitly what
things like HEAD are.

This makes the title of HTML reports somewhat verbose, but I think
that's a small price to pay.
2019-07-05 17:06:42 +02:00
Gilles Peskine
cc02658d27 Document how to build the typical argument for -s 2019-07-05 17:06:42 +02:00
Gilles Peskine
16dfdb3539 Allow running /somewhere/else/path/to/abi_check.py
Don't require abi_check.py to be the one in scripts/ under the current
directory.
2019-07-05 17:06:42 +02:00
Jaeden Amero
bf8df56b90 Merge remote-tracking branch 'origin/pr/2733' into mbedtls-2.7
* origin/pr/2733:
  Changelog entry for HAVEGE fix
  Prevent building the HAVEGE module on platforms where it doesn't work
  Fix misuse of signed ints in the HAVEGE module
2019-07-05 15:42:12 +01:00
Gilles Peskine
950de1e331 Test that a shared library build produces a dynamically linked executable 2019-07-05 15:48:52 +02:00
Gilles Peskine
17ecb24cb8 Test that the shared library build with CMake works 2019-07-05 15:48:36 +02:00
Gilles Peskine
f852f5fd15 Add a test of MBEDTLS_CONFIG_FILE
configs/README.txt documents that you can use an alternative
configuration file by defining the preprocessor symbol
MBEDTLS_CONFIG_FILE. Test this.
2019-07-05 15:48:36 +02:00
Gilles Peskine
990ea3da50 Changelog entry for HAVEGE fix 2019-07-05 11:44:12 +02:00
Gilles Peskine
d1800a76a9 Prevent building the HAVEGE module on platforms where it doesn't work
If int is not capable of storing as many values as unsigned, the code
may generate a trap value. If signed int and unsigned int aren't
32-bit types, the code may calculate meaningless values.
2019-07-05 11:33:10 +02:00
Gilles Peskine
8850e2e367 Fix misuse of signed ints in the HAVEGE module
The elements of the HAVEGE state are manipulated with bitwise
operations, with the expectations that the elements are 32-bit
unsigned integers (or larger). But they are declared as int, and so
the code has undefined behavior. Clang with Asan correctly points out
some shifts that reach the sign bit.

Use unsigned int internally. This is technically an aliasing violation
since we're accessing an array of `int` via a pointer to `unsigned
int`, but since we don't access the array directly inside the same
function, it's very unlikely to be compiled in an unintended manner.
2019-07-05 11:31:50 +02:00
Gilles Peskine
570f7a2318 Allow TODO in code
Don't reject TODO in code. Fix #2587
2019-07-05 10:56:19 +02:00
Gilles Peskine
081daf0dd3 Use the docstring in the command line help 2019-07-05 10:56:19 +02:00
Jaeden Amero
1e61b0fb3f Merge remote-tracking branch 'restricted/pr/581' into mbedtls-2.7-restricted
* restricted/pr/581:
  Remove unnecessary empty line
  Add a test for signing content with a long ECDSA key
  Add documentation notes about the required size of the signature buffers
  Add missing MBEDTLS_ECP_C dependencies in check_config.h
  Change size of preallocated buffer for pk_sign() calls
2019-06-24 11:40:49 +01:00
Jaeden Amero
0b2035794f Merge remote-tracking branch 'origin/pr/2713' into mbedtls-2.7
* origin/pr/2713:
  programs: Make `make clean` clean all programs always
  ssl_tls: Enable Suite B with subset of ECP curves
  windows: Fix Release x64 configuration
  timing: Remove redundant include file
  net_sockets: Fix typo in net_would_block()
2019-06-21 15:58:02 +01:00
Jaeden Amero
c0ff88e624 Merge remote-tracking branch 'origin/pr/2702' into mbedtls-2.7
* origin/pr/2702:
  Pass -m32 to the linker as well
2019-06-21 15:55:21 +01:00
Jaeden Amero
54c800ef24 Merge remote-tracking branch 'origin/pr/2616' into mbedtls-2.7
* origin/pr/2616:
  Use 'config.pl baremetal' in all.sh
2019-06-21 15:55:21 +01:00
Jaeden Amero
0cf1776a2d Merge remote-tracking branch 'origin/pr/2451' into mbedtls-2.7
* origin/pr/2451:
  Fix #2370, minor typos and spelling mistakes
2019-06-21 15:55:21 +01:00
Jaeden Amero
dd11fbccd2 Merge remote-tracking branch 'origin/pr/2320' into mbedtls-2.7
* origin/pr/2320:
  Clarify ChangeLog entry for fix to #1628
  Add Changelog entry for clang test-ref-configs.pl fix
  Enable more compiler warnings in tests/Makefile
  Change file scoping of test helpers.function
2019-06-21 15:55:21 +01:00
Jaeden Amero
a1ab6fed91 programs: Make make clean clean all programs always
If `make TEST_CPP:=1` is run, and then `make clean` (as opposed to `make
TEST_CPP:=1 clean`), the cpp_dummy_build will be left behind after the
clean. Make `make clean more convenient to use by removing programs that
could be generated from any configuration, not just the active one.

Fixes #1862
2019-06-20 16:30:36 +01:00
Jaeden Amero
ba59f6b38e ssl_tls: Enable Suite B with subset of ECP curves
Make sure the code compiles even if some curves are not defined.

Fixes #1591
2019-06-20 16:30:36 +01:00
Jaeden Amero
a33bb945eb windows: Fix Release x64 configuration
Inherit PlatformToolset from the project configuration. This allow the
project to configure PlatformToolset, and aligns the Release x64 build
with other build types.

Fixes #1430
2019-06-20 16:30:35 +01:00
Jaeden Amero
548ba2e190 timing: Remove redundant include file
There is no need to include winbase.h, as it will be pulled in by
windows.h as needed.

Fixes #2640
2019-06-20 16:28:10 +01:00
Jaeden Amero
1529ede823 net_sockets: Fix typo in net_would_block()
Fixes #528
2019-06-20 16:28:10 +01:00
Gilles Peskine
9bf1509ef3 Adapt auth_crypt_tv usage to 2.7 2019-06-18 16:14:39 +02:00
Hanno Becker
dd91b24764 Add missing dependencies in test_suite_cipher.gcm 2019-06-18 16:11:38 +02:00
Hanno Becker
d62577fa74 Adapt ChangeLog 2019-06-18 16:11:29 +02:00
Hanno Becker
311276c871 Add NIST AES GCM test vectors to single-step cipher API test suite
The test suites `test_suite_gcm.aes{128,192,256}_en.data` contains
numerous NIST test vectors for AES-*-GCM against which the GCM
API mbedtls_gcm_xxx() is tested.

However, one level higher at the cipher API, no tests exist which
exercise mbedtls_cipher_auth_{encrypt/decrypt}() for GCM ciphers,
although test_suite_cipher.function contains the test auth_crypt_tv
which does precisely that and is already used e.g. in
test_suite_cipher.ccm.

This commit replicates the test vectors from
test_suite_gcm.aes{128,192,256}_en.data in test_suite_cipher.gcm.data
and adds a run of auth_crypt_tv for each of them.

The conversion was mainly done through the sed command line

```
s/gcm_decrypt_and_verify:\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):
\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\)/auth_crypt_tv:
\1:\2:\4:\5:\3:\7:\8:\9/
```
2019-06-18 16:10:42 +02:00
Jaeden Amero
35a7e4675f Merge remote-tracking branch 'origin/pr/2688' into mbedtls-2.7
* origin/pr/2688:
  Update library version to 2.7.11
2019-06-18 14:22:59 +01:00
Gilles Peskine
d535f4d667 Pass -m32 to the linker as well
For unit tests and sample programs, CFLAGS=-m32 is enough to get a
32-bit build, because these programs are all compiled directly
from *.c to the executable in one shot. But with makefile rules that
first build object files and then link them, LDFLAGS=-m32 is also
needed.
2019-06-17 19:15:37 +02:00
Jaeden Amero
2fa0172ae1 Merge remote-tracking branch 'origin/pr/2483' into mbedtls-2.7
* origin/pr/2483:
  Correct placement of ChangeLog entry
  Improve documentation of mbedtls_x509_get_ext()
  Adapt ChangeLog
  Always return a high-level error code from X.509 module
  Obey bounds of ASN.1 substructures
2019-06-14 15:28:02 +01:00
Jaeden Amero
fe1180a9db Merge remote-tracking branch 'origin/pr/2696' into mbedtls-2.7
* origin/pr/2696:
  UDP proxy: Don't attempt to dissect dgram into records when dropping
2019-06-14 08:55:32 +01:00
Jaeden Amero
d03977dc3c Merge remote-tracking branch 'origin/pr/2677' into mbedtls-2.7
* origin/pr/2677:
  Show removed symbols in abi check
2019-06-14 08:54:35 +01:00
Jaeden Amero
ea60486507 Merge remote-tracking branch 'origin/pr/2674' into mbedtls-2.7
* origin/pr/2674:
  Remove all abi dumps, not just ones shared between versions
2019-06-14 08:53:40 +01:00
Jaeden Amero
98fc5f4937 Merge remote-tracking branch 'origin/pr/2482' into mbedtls-2.7
* origin/pr/2482:
  Document support for MD2 and MD4 in programs/x509/cert_write
  Correct name of X.509 parsing test for well-formed, ill-signed CRT
  Add test cases exercising successful verification of MD2/MD4/MD5 CRT
  Add test case exercising verification of valid MD2 CRT
  Add MD[245] test CRTs to tree
  Add instructions for MD[245] test CRTs to tests/data_files/Makefile
  Add suppport for MD2 to CSR and CRT writing example programs
  Convert further x509parse tests to use lower-case hex data
  Correct placement of ChangeLog entry
  Adapt ChangeLog
  Use SHA-256 instead of MD2 in X.509 CRT parsing tests
  Consistently use lower case hex data in X.509 parsing tests
2019-06-14 08:50:16 +01:00
Jaeden Amero
334ab9b7cb Merge remote-tracking branch 'origin/pr/2498' into mbedtls-2.7
* origin/pr/2498:
  Adapt ChangeLog
  ssl_server2: Fail gracefully if no PEM-encoded CRTs are available
  ssl_server2: Skip CA setup if `ca_path` or `ca_file` argument "none"
  ssl_client2: Fail gracefully if no PEM-encoded CRTs are available
  ssl_client2: Skip CA setup if `ca_path` or `ca_file` argument "none"
2019-06-14 08:48:10 +01:00
Hanno Becker
7bac1ab38a UDP proxy: Don't attempt to dissect dgram into records when dropping
To prevent dropping the same message over and over again, the UDP proxy
test application programs/test/udp_proxy _logically_ maintains a mapping
from records to the number of times the record has already been dropped,
and stops dropping once a configurable threshold (currently 2) is passed.

However, the actual implementation deviates from this logical view
in two crucial respects:
- To keep the implementation simple and independent of
  implementations of suitable map interfaces, it only counts how
  many times a record of a given _size_ has been dropped, and
  stops dropping further records of that size once the configurable
  threshold is passed. Of course, this is not fail-proof, but a
  good enough approximation for the proxy, and it allows to use
  an inefficient but simple array for the required map.
- The implementation mixes datagram lengths and record lengths:
  When deciding whether it is allowed to drop a datagram, it
  uses the total datagram size as a lookup index into the map
  counting the number of times a package has been dropped. However,
  when updating this map, the UDP proxy traverses the datagram
  record by record, and updates the mapping at the level of record
  lengths.

Apart from this inconsistency, the current implementation suffers
from a lack of bounds checking for the parsed length of incoming
DTLS records that can lead to a buffer overflow when facing
malformed records.

This commit removes the inconsistency in datagram vs. record length
and resolves the buffer overflow issue by not attempting any dissection
of datagrams into records, and instead only counting how often _datagrams_
of a particular size have been dropped.

There is only one practical situation where this makes a difference:
If datagram packing is used by default but disabled on retransmission
(which OpenSSL has been seen to do), it can happen that we drop a
datagram in its initial transmission, then also drop some of its records
when they retransmitted one-by-one afterwards, yet still keeping the
drop-counter at 1 instead of 2. However, even in this situation, we'll
correctly count the number of droppings from that point on and eventually
stop dropping, because the peer will not fall back to using packing
and hence use stable record lengths.
2019-06-13 11:19:20 +01:00
k-stachowiak
dff85e7e8a Remove unnecessary empty line 2019-06-13 11:54:49 +02:00
Jaeden Amero
6794f68d29 Update library version to 2.7.11 2019-06-11 17:31:57 +01:00
k-stachowiak
45d0ba15a0 Add a test for signing content with a long ECDSA key
Due to the way the current PK API works, it may have not been clear
for the library clients, how big output buffers they should pass
to the signing functions. Depending on the key type they depend on
MPI or EC specific compile-time constants.

Inside the library, there were places, where it was assumed that
the MPI size will always be enough, even for ECDSA signatures.
However, for very small sizes of the MBEDTLS_MPI_MAX_SIZE and
sufficiently large key, the EC signature could exceed the MPI size
and cause a stack overflow.

This test establishes both conditions -- small MPI size and the use
of a long ECDSA key -- and attempts to sign an arbitrary file.
This can cause a stack overvlow if the signature buffers are not
big enough, therefore the test is performed for an ASan build.
2019-06-10 11:48:38 +02:00
Jaeden Amero
c06b6e0bd2 Merge remote-tracking branch 'origin/pr/2658' into mbedtls-2.7
* origin/pr/2658:
  Create link to include/mbedtls only when testing is enabled
2019-06-06 14:18:43 +01:00
k-stachowiak
eee98e9d82 Add documentation notes about the required size of the signature buffers 2019-06-06 13:07:19 +02:00
k-stachowiak
199707fcff Add missing MBEDTLS_ECP_C dependencies in check_config.h 2019-06-06 13:06:57 +02:00
k-stachowiak
b50c39ca4a Change size of preallocated buffer for pk_sign() calls 2019-06-06 13:06:46 +02:00
Darryl Green
db95d7e99d Show removed symbols in abi check 2019-06-05 12:59:07 +01:00
Hanno Becker
d7bc9ffd24 Correct placement of ChangeLog entry 2019-06-04 14:03:39 +01:00