Commit Graph

593 Commits

Author SHA1 Message Date
Jaeden Amero
575c1abda2 Merge branch 'mbedtls-1.3' into mbedtls-1.3-restricted 2018-01-29 12:50:44 +00:00
Jaeden Amero
8c01acdd9e Merge remote-tracking branch 'upstream-public/pr/1291' into mbedtls-1.3 2018-01-29 12:50:39 +00:00
Jaeden Amero
d6b8ce467c Merge remote-tracking branch 'upstream-restricted/pr/413' into mbedtls-1.3-restricted 2018-01-26 17:53:40 +00:00
Jaeden Amero
3443744271 Merge remote-tracking branch 'upstream-public/pr/1053' into mbedtls-1.3 2018-01-26 15:14:29 +00:00
Manuel Pégourié-Gonnard
e10d634856 Fix race condition in error printing in ssl_server2.c
The race goes this way:
1. ssl_recv() succeeds (ie no signal received yet)
2. processing the message leads to aborting handshake with ret != 0
3. reset ret if we were signaled
4. print error if ret is still non-zero
5. go back to net_accept() which can be interrupted by a signal
We print the error message only if the signal is received between steps 3 and
5, not when it arrives between steps 1 and 3.

This can cause failures in ssl-opt.sh where we check for the presence of "Last
error was..." in the server's output: if we perform step 2, the client will be
notified and exit, then ssl-opt.sh will send SIGTERM to the server, but if it
didn't get a chance to run and pass step 3 in the meantime, we're in trouble.

The purpose of step 3 was to avoid spurious "Last error" messages in the
output so that ssl-opt.sh can check for a successful run by the absence of
that message. However, it is enough to suppress that message when the last
error we get is the one we expect from being interrupted by a signal - doing
more could hide real errors.

Also, improve the messages printed when interrupted to make it easier to
distinguish the two cases - this could be used in a testing script wanted to
check that the server doesn't see the client as disconnecting unexpectedly.
2018-01-25 17:55:36 +01:00
Hanno Becker
175668a8fd Address issues found by coverity
1) The MPI test for prime generation missed a return value
   check for a call to `mpi_shift_r`. This is neither
   critical nor new but should be fixed.

2) The RSA keygeneration example program contained code
   initializing an RSA context after a potentially failing
   call to CTR DRBG initialization, leaving the corresponding
   RSA context free call in the cleanup section orphaned.
   The commit fixes this by moving the initializtion of the
   RSA context prior to the first potentially failing call.
2018-01-10 11:24:43 +00:00
Gilles Peskine
f15cbdab67 Merge remote-tracking branch 'upstream-public/pr/1109' into mbedtls-1.3 2017-11-28 18:41:31 +01:00
Hanno Becker
fffe3bddb0 Change choice of DHM parameters in ssl_server2 example application 2017-10-13 17:00:34 +01:00
Andres Amaya Garcia
86f76ea25c Add brackets around function macro arguments 2017-10-07 22:21:54 +01:00
Andres Amaya Garcia
2d0a5840fe Fix MSVC warning in sample programs
The warning was caused because of conversions from size_t to int, which
can cause data loss. The files affected are:
* ssl_client2.c
* ssl_server2.c
* ssl_mail_client.c
2017-10-07 22:21:29 +01:00
Hanno Becker
e87e5f6c71 Extend cert_write example program by multiple cmd line options
This commit adds the following command line options to programs/x509/cert_write:
- version (val 1, 2, 3): Set the certificate's version (v1, v2, v3)
- authority_identifier (val 0, 1): Enable or disable the addition of the
                                   authority identifier extension.
- subject_identifier (val 0, 1): Enable or disable the addition of the
                                 subject identifier extension.
- basic_constraints (val 0, 1): Enable or disable the addition of the
                                basic constraints extension.
- md (val MD5, SHA1, SHA256, SHA512): Set the hash function used
                                      when creating the CRT.
2017-10-05 08:37:53 +01:00
Ron Eldor
4ca4fd774d Fix ssl_server2 sample application prompt
FIx the type of server_addr parameter from %d to %s.
Issue reported by Email by Bei Jin
2017-10-02 19:22:04 +01:00
Ron Eldor
bbf4b59f07 Backport 1.3:Remove duplicated def. of PRINT_ERROR
Backport of #1036 to mbed TLS1.3 branch.
Remove duplicated definition of PRINT_ERROR
in the benchmark sample application
2017-08-20 16:24:33 +03:00
Hanno Becker
dcbb0246f9 Correct comments 2017-07-28 22:04:08 +01:00
Hanno Becker
e6ee6383a9 Reliably zeroize sensitive data in AES sample application
The AES sample application programs/aes/aescrypt2 could miss zeroizing
the stack-based key buffer in case of an error during operation. This
commit fixes this and also clears another temporary buffer as well as
all command line arguments (one of which might be the key) before exit.
2017-07-28 21:58:47 +01:00
Hanno Becker
8188d392af Reliably zeroize sensitive data in Crypt-and-Hash sample application
The AES sample application programs/aes/crypt_and_hash could miss
zeroizing the stack-based key buffer in case of an error during
operation. This commit fixes this and also clears all command line
arguments (one of which might be the key) before exit.
2017-07-28 21:58:31 +01:00
Ron Eldor
1d260545fc Minor: Fix typo in program comments
Fix a typo in some reference program applications
2017-07-19 23:44:21 +02:00
Hanno Becker
569a4f4573 Remove %zu format string from ssl_client2 and ssl_server2 2017-06-09 16:26:04 +01:00
Manuel Pégourié-Gonnard
674df30480 Merge remote-tracking branch 'janos/mbedtls-1.3-iotssl-1156-ecdsa-sample-and-doc-clarification' into mbedtls-1.3
* janos/mbedtls-1.3-iotssl-1156-ecdsa-sample-and-doc-clarification:
  Clarify the use of ECDSA API
2017-06-08 10:18:15 +02:00
Janos Follath
5d96a3dcde Clarify the use of ECDSA API
In the ecdsa.c sample application we don't use hashing, we use ecdsa
directly on a buffer containing plain text. Although the text explains
that it should be the message hash it still can be confusing.

Any misunderstandings here are potentially very dangerous, because ECDSA
truncates the message hash if necessary and this can lead to trivial
signature forgeries if the API is misused and the message is passed
directly to the function without hashing.

This commit adds a hash computation step to the ecdsa.c sample
application and clarification to the doxygen documentation of the
ECDSA functions involved.
2017-06-07 17:05:00 +01:00
Hanno Becker
6fd6d248ae Add tests for missing CA chains and bad curves.
This commit adds four tests to tests/ssl-opt.sh:
(1) & (2): Check behaviour of optional/required verification when the
trusted CA chain is empty.
(3) & (4): Check behaviour of optional/required verification when the
client receives a server certificate with an unsupported curve.
2017-06-07 11:40:44 +01:00
Simon Butcher
40d8cc7181 Adds dl link library to OpenSSL example builds
The example o_p_test uses OpenSSL. On some platforms that fails to build
unless the dl library is included as a static link library.
2017-02-01 12:38:44 +00:00
Simon Butcher
8c9ab6ce6f Add extra compilation conditions to X.509 samples
The sample applications programs/pkey/cert_req.c and
programs/pkey/cert_write.c use the library functions mbedtls_pk_write_csr_pem()
and mbedtls_pk_write_crt_pem() respectively and programs/pkey/gen_key.c uses
the library function mbedtls_pk_write_key_pem().

These are dependent on the configuration option POLARSSL_PEM_WRITE_C. If the
option isn't defined the build breaks.

This change adds the compilation condition POLARSSL_PEM_WRITE_C to these
sample applications.
2016-10-13 12:45:07 +01:00
Simon Butcher
23abd160cc Actually apply debug_level settings in cert_app 2016-10-13 12:44:20 +01:00
Simon Butcher
31d7f5b236 Fix for #441 - crypt and hash gcm (#546)
* Fix crypt_and_hash to support decrypting GCM encrypted files

* Fix documentation in crypt_and_hash for the generic case

* Remove unused lastn from crypt_and_hash

lastn is not used with the cipher layer as it already provides padding
and understanding of length of the original data.

Backport of fix by Paul Bakker.
2016-10-13 12:44:19 +01:00
Simon Butcher
8435f9e8ec Add missing stdlib.h header to rsa sample programs 2016-04-13 01:38:54 +01:00
Simon Butcher
de62b6e396 Fixes error and exit paths in rsa sample programs 2016-04-12 17:36:34 +01:00
Janos Follath
fa4a88a8eb Fix memory leaks in example programs. 2016-04-12 16:45:10 +01:00
Jonathan Leroy
2744df4f7a cert_write : fix "Destination buffer is too small" error
This commit fixes the `Destination buffer is too small` error returned
by `mbedtls_cert_write` command when the values of `subject_name` or
`issuer_name` parameters exceed 128 characters.

I have increased the size of these varaibles from 128 to 256 characters,
but I don't know if it's the best way to solve this issue...

Fixes #315.
2015-10-27 15:12:39 +01:00
Manuel Pégourié-Gonnard
8fbb5a32c6 Fix snprintf usage again
Sigh, switching between branches is error-prone
2015-08-31 12:38:12 +02:00
Manuel Pégourié-Gonnard
c728f9486b Fix snprintf usage on windows
Introduced in 6432c7e
2015-08-31 12:30:16 +02:00
Manuel Pégourié-Gonnard
ee7db9cb6d Fix hash buffer size in pkey programs
backport from 102a620
2015-08-31 11:32:03 +02:00
Manuel Pégourié-Gonnard
6432c7e782 Fix memory corruption in rsa sign/verify programs
backport from d74c697

see #210
2015-08-31 11:30:07 +02:00
Manuel Pégourié-Gonnard
a67fd79e8f Fix -Wshadow warnings
Backport of ea35666 and 824ba72

see #240
2015-08-31 11:07:51 +02:00
Manuel Pégourié-Gonnard
e92617b586 Run timing selftest on all platforms 2015-07-06 17:19:27 +02:00
Manuel Pégourié-Gonnard
f0dd045bbe Backport dh_genprime update from 2.0 2015-07-03 17:14:06 +02:00
Manuel Pégourié-Gonnard
006f655218 Add forgotten programs in Makefile
Closes #209
2015-06-29 18:52:57 +02:00
Manuel Pégourié-Gonnard
fa950c9480 fix bug in ssl_mail_client 2015-04-30 12:50:22 +02:00
Manuel Pégourié-Gonnard
ac90673345 Remove unused headers in o_p_test 2015-04-30 10:09:50 +02:00
Manuel Pégourié-Gonnard
637376c2fe Fix bugs in programs displaying verify flags 2015-04-29 14:28:48 +02:00
Manuel Pégourié-Gonnard
0c6ce2f536 Use x509_crt_verify_info() in programs 2015-04-17 19:57:21 +02:00
Paul Bakker
6152b0267c Fixed typos 2015-04-14 15:00:09 +02:00
Manuel Pégourié-Gonnard
0878a0d884 Add missing depends in x509 programs 2015-03-31 15:14:37 +02:00
Manuel Pégourié-Gonnard
8d649c66b3 Simplify ifdef checks in programs/x509 2015-03-31 15:10:03 +02:00
Manuel Pégourié-Gonnard
e46c6c38c9 Fix tests to work with DEPRECATED_REMOVED 2015-03-23 14:11:11 +01:00
Alon Bar-Lev
f7a9f30348 build: Makefile: cleanup CFLAGS
CFLAGS are reserved for external interaction via make variable, the
following should work:

$ make CFLAGS="-O3"
$ CFLAGS="-O3" make

1. Move internal flags to LOCAL_CFLAGS
2. Respect external CFLAGS
3. CFLAGS should be last compiler flags.
4. Default CFLAGS is -O optimization, remove OFLAGS.
5. Add WARNING_CFLAGS to control warning setting and enable to remove
   if compiler does not support flags.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2015-03-13 13:34:25 +00:00
Alon Bar-Lev
ada4105ba2 build: Makefile: cleanup LDFLAGS
LDFLAGS are reserved for external interaction via make variable, the
following should work:

$ make LDFLAGS="-L/xxx"
$ LDFLAGS="-L/xxx" make

1. Move internal flags to LOCAL_LDFLAGS
2. Respect external LDFLAGS
3. LDFLAGS should be last linkage flags.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2015-03-13 13:34:25 +00:00
Manuel Pégourié-Gonnard
fe44643b0e Rename website and repository 2015-03-06 13:17:10 +00:00
Manuel Pégourié-Gonnard
c439e7b099 Minor portability fix in benchmark
On embedded systems, argc might be 0 rather than 1 for no argument.
2015-03-03 13:12:00 +00:00
Manuel Pégourié-Gonnard
b199095ec9 Finish fixing memleak in ssl_server2 arg parsing
Fixes omission in 5c078e1
2015-02-18 09:32:06 +00:00