Commit graph

7341 commits

Author SHA1 Message Date
Andres Amaya Garcia
5517202541 Fix ret code in ssl_client1.c 2018-06-14 23:01:10 +01:00
Andres Amaya Garcia
73d4a5f131 Fix ret code in gen_random_ctr_drbg.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
55a0d56b33 Fix ret code in gen_entropy.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
a8332637d7 Fix ret code in rsa_verify_pss.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
0a860f6301 Fix ret code in rsa_verify.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
3c41e564f8 Fix ret code in rsa_sign_pss.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
1a66056c77 Fix ret code in rsa_sign.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
70e1ffdacd Fix ret code in rsa_genkey.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
ed68488e28 Fix ret code in key_app_writer.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
0faf1a5c01 Fix ret code in key_app.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
208c217dfa Fix ret code in gen_key.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
2602a1fbc5 Fix ret code in ecdsa.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
03a992c817 Fix ret code in dh_server.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
d6bfeff289 Fix ret code in dh_genprime.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
898841dc71 Fix ret code in dh_client.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
4c47df6f3f Fix ret code in crypt_and_hash.c 2018-06-14 22:59:57 +01:00
Andres Amaya Garcia
388c1b124e Fix ret code in aescrypt2.c 2018-06-14 22:59:57 +01:00
Gilles Peskine
ace05929e8 Fix harmless use of uninitialized memory in ssl_parse_encrypted_pms
In ssl_parse_encrypted_pms, some operational failures from
ssl_decrypt_encrypted_pms lead to diff being set to a value that
depended on some uninitialized unsigned char and size_t values. This didn't
affect the behavior of the program (assuming an implementation with no
trap values for size_t) because all that matters is whether diff is 0,
but Valgrind rightfully complained about the use of uninitialized
memory. Behave nicely and initialize the offending memory.
2018-06-14 13:26:52 +02:00
Gilles Peskine
c306a059d1 SSL async tests: add a few test cases for error in decrypt
The code paths in the library are different for decryption and for
signature. Improve the test coverage by doing some error path tests
for decryption in addition to signature.
2018-06-14 13:26:52 +02:00
Gilles Peskine
4481744538 Fix memory leak in ssl_server2 with SNI + async callback
In ssl_server2, the private key objects are normally local variables
of the main function. However this does not hold for private keys in
the SNI configuration. When async callbacks are used, the test code
transfers the ownership of the private keys to the async callbacks.
Therefore the test code must free the SNI private keys through the
async callbacks (but it must not free the straight private keys this
way since they are not even heap-allocated).
2018-06-14 13:26:52 +02:00
Gilles Peskine
e247989061 SNI + SSL async callback: make all keys async
When testing async callbacks with SNI, make all the keys async, not
just the first one. Otherwise the test is fragile with respect to
whether a key is used directly or through the async callbacks.
2018-06-14 13:26:52 +02:00
Gilles Peskine
2636fade52 ssl_async_resume: free the operation context on error 2018-06-14 13:26:52 +02:00
Gilles Peskine
f5a9996088 ssl_server2: get op_name from context in ssl_async_resume as well 2018-06-14 13:26:52 +02:00
Gilles Peskine
ef30742a27 Clarify "as directed here" in SSL async callback documentation 2018-06-14 13:26:51 +02:00
Gilles Peskine
7457933a04 SSL async callbacks documentation: clarify resource cleanup
Clarify when resume must clean up resources and when cancel is called.
2018-06-14 13:26:51 +02:00
Gilles Peskine
3dae1cfa3a Async callback: use mbedtls_pk_check_pair to compare keys
In the current test code, the object that is used as a public key in
the certificate also contains a private key. However this is because
of the way the stest code is built and does not demonstrate the API in
a useful way. Use mbedtls_pk_check_pair, which is not what real-world
code would do (since the private key would typically be in an external
cryptoprocessor) but is a more representative placeholder.
2018-06-14 13:26:51 +02:00
Gilles Peskine
a668c60186 Rename mbedtls_ssl_async_{get,set}_data for clarity
Rename to mbedtls_ssl_get_async_operation_data and
mbedtls_ssl_set_async_operation_data so that they're about
"async operation data" and not about some not-obvious "data".
2018-06-14 13:26:51 +02:00
Gilles Peskine
02b86d0415 Fix copypasta in the async callback documentation 2018-06-14 13:26:51 +02:00
Gilles Peskine
166ce748cf SSL async callback: cert is not always from mbedtls_ssl_conf_own_cert
The certificate passed to async callbacks may not be the one set by
mbedtls_ssl_conf_own_cert. For example, when using an SNI callback,
it's whatever the callback is using. Document this, and add a test
case (and code sample) with SNI.
2018-06-14 13:26:51 +02:00
Gilles Peskine
d6fbfde994 ssl_async_set_key: detect if ctx->slots overflows 2018-06-14 13:26:51 +02:00
Gilles Peskine
07981585d3 Fix missing continuation indicator in ssl-opt.sh 2018-06-14 13:26:51 +02:00
Gilles Peskine
20e2bdf4b0 SSL async tests: tighten a few log checks in some test cases 2018-06-14 13:26:51 +02:00
Gilles Peskine
94e153af77 Improve documentation of the async callback's crypto parameters 2018-06-14 13:26:51 +02:00
Gilles Peskine
37d417561d Add test case for SSL async resume after resume
Add a test case for SSL asynchronous signature where f_async_resume is
called twice. Verify that f_async_sign_start is only called once.

This serves as a non-regression test for a bug where f_async_sign_start
was only called once, which turned out to be due to a stale build
artifacts with mismatched numerical values of
MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS.
2018-06-14 13:26:51 +02:00
Gilles Peskine
4d9ec4dcf7 Fix uninitialized variable in ssl_server2 2018-06-14 13:26:51 +02:00
Gilles Peskine
6331d78675 Don't use the printf format %zd
We target C89 libc, so don't use %zd or %zu. Just use %u, and make
slot numbers `unsigned` for simplicity.
2018-06-14 13:26:51 +02:00
Gilles Peskine
03af7f6ae7 Change boolean bitfield to unsigned
Reminder to self: 1 is not a valid value in a 1-bit bitfield. It's
undefined behavior and gcc -ansi -pedantic helpfully complains about it.
2018-06-14 13:26:51 +02:00
Jaeden Amero
ff2f493432 config: List cipher modes in alphabetical order
Keeping the cipher modes list in alphabetical order makes it easier to
find things. Move OFB and XTS to their appropriate locations in the
list.
2018-06-14 11:42:27 +01:00
Simon Butcher
4ab8acd696 Merge remote-tracking branch 'public/pr/1075' into development 2018-06-14 10:34:44 +01:00
Simon Butcher
6ac1cf6f5f Merge remote-tracking branch 'public/pr/1182' into development 2018-06-14 10:33:29 +01:00
Simon Butcher
e5cd86874e Add ChangeLog entry for PR #1555
Adds ChangeLog entry for PR #1555, 'Only redefine _WIN32_WINNT macro when <
0x0501'
2018-06-14 10:30:19 +01:00
Simon Butcher
c1bf1aaee5 Merge remote-tracking branch 'public/pr/1555' into development 2018-06-14 10:24:56 +01:00
Simon Butcher
73a4b80475 Merge remote-tracking branch 'public/pr/1672' into development 2018-06-14 10:24:02 +01:00
Simon Butcher
9a8db56959 Merge remote-tracking branch 'public/pr/1730' into development 2018-06-14 10:23:29 +01:00
Simon Butcher
2ff0e52087 Fix missing preprocessor condition in AES self-test
The AES OFB self-test made use of a variable `offset` but failed to have a
preprocessor condition around it, so unless CTR and CBC were enabled, the
variable would be undeclared.
2018-06-14 09:57:07 +01:00
Philippe Antoine
c03059db42 Simplify code in mbedtls_x509_csr_parse 2018-06-14 07:35:11 +02:00
Gilles Peskine
0a8352b4c2 Fix harmless use of uninitialized memory in ssl_parse_encrypted_pms
In ssl_parse_encrypted_pms, some operational failures from
ssl_decrypt_encrypted_pms lead to diff being set to a value that
depended on some uninitialized unsigned char and size_t values. This didn't
affect the behavior of the program (assuming an implementation with no
trap values for size_t) because all that matters is whether diff is 0,
but Valgrind rightfully complained about the use of uninitialized
memory. Behave nicely and initialize the offending memory.
2018-06-13 18:21:25 +02:00
Gilles Peskine
725f1cb6bd SSL async tests: add a few test cases for error in decrypt
The code paths in the library are different for decryption and for
signature. Improve the test coverage by doing some error path tests
for decryption in addition to signature.
2018-06-13 18:10:41 +02:00
Gilles Peskine
3f3ada8839 Fix memory leak in ssl_server2 with SNI + async callback
In ssl_server2, the private key objects are normally local variables
of the main function. However this does not hold for private keys in
the SNI configuration. When async callbacks are used, the test code
transfers the ownership of the private keys to the async callbacks.
Therefore the test code must free the SNI private keys through the
async callbacks (but it must not free the straight private keys this
way since they are not even heap-allocated).
2018-06-13 18:09:28 +02:00
Gilles Peskine
157f6d8f74 SNI + SSL async callback: make all keys async
When testing async callbacks with SNI, make all the keys async, not
just the first one. Otherwise the test is fragile with respect to
whether a key is used directly or through the async callbacks.
2018-06-13 18:06:51 +02:00