Commit graph

2627 commits

Author SHA1 Message Date
Thomas Daubney
d8453bb184 Remove superfluous comment
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-11 15:29:02 +01:00
Thomas Daubney
cd79f77439 Add missing newline
Newline character was missing from end of print
statement.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-11 15:28:13 +01:00
Thomas Daubney
1c2378b8b1 Add variable for message length
Add variable to store message length to increase
clarity in what the program is doing.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-11 15:19:38 +01:00
Tom Cosgrove
3c1cdc9061
Merge pull request #8185 from yanrayw/aes_benchmark_cfb
Benchmark: add AES_CFB128 and AES_CFB8
2023-10-11 09:48:27 +00:00
Thomas Daubney
34500874ce Remove trailing white space in documentation
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-11 10:04:54 +01:00
Thomas Daubney
760538885a Inform user when unknown hash algorithm supplied
Excplictly inform the user that their hash algorithm
selection is invalid.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-10 17:38:53 +01:00
Thomas Daubney
86f9795b00 Update documentation
Add further information about PSA hashing to the
comment at the beginning of the code.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-10 16:50:49 +01:00
Yanray Wang
5cae6e8ddd benchmark: improve code readability
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-10-09 18:40:19 +08:00
Thomas Daubney
540324cd21 Correct styling of Mbed TLS in documentation
Several bits of documentation were incorrectly styling Mbed TLS
as MbedTLS.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-10-06 17:07:24 +01:00
David Horstmann
6c979856c3 Remove generated files in all cmake_as_x tests
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-09-28 11:30:43 +01:00
Minos Galanakis
a8b02ef79b pkey-random: Removed setting mbedtls_target in libs
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-09-25 14:12:22 +01:00
Minos Galanakis
7f8e8c5ae2 program-random: Updated Cmake libs variable
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-09-25 14:12:22 +01:00
Minos Galanakis
ce33e7b22d pkey Cmakelists: Updated the set libs to be consistent with others.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-09-25 14:12:22 +01:00
Minos Galanakis
e13775dedb fuzzer Makefile: Added -lbcrypt linkage
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-09-25 14:12:21 +01:00
Minos Galanakis
b8d6b82df4 programs: Cleaned up bcrypt linking refererences.
bcrypt is added to the cmake `libs` dependency at library\CMakeLists.txt

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-09-25 14:12:21 +01:00
Simon Butcher
1c0c5d2a62 Fix for building programs with mingw
mingw build files were missing the dependency on the bcrypt library

Signed-off-by: Simon Butcher <simon.butcher@arm.com>
2023-09-25 14:12:20 +01:00
Simon Butcher
33425de128 Correct check for WIN32 in cmake files for programs
Condition was checking for Visual Studio, not use of WIN32

Signed-off-by: Simon Butcher <simon.butcher@arm.com>
2023-09-25 14:12:20 +01:00
Kevin Kane
0ec1e68548 Replace Windows APIs that are banned in Windows Store apps
CryptGenRandom and lstrlenW are not permitted in Windows Store apps,
meaning apps that use mbedTLS can't ship in the Windows Store.
Instead, use BCryptGenRandom and wcslen, respectively, which are
permitted.

Also make sure conversions between size_t, ULONG, and int are
always done safely; on a 64-bit platform, these types are different
sizes.

Also suppress macro redefinition warning for intsafe.h:

Visual Studio 2010 and earlier generates C4005 when including both
<intsafe.h> and <stdint.h> because a number of <TYPE>_MAX constants
are redefined. This is fixed in later versions of Visual Studio.
The constants are guaranteed to be the same between both files,
however, so we can safely suppress the warning when including
intsafe.h.

Signed-off-by: Kevin Kane <kkane@microsoft.com>
2023-09-25 14:12:20 +01:00
Gilles Peskine
bd50d5baec
Merge pull request #8177 from gilles-peskine-arm/generated-files-off-in-release
Generated files off in release
2023-09-18 14:11:58 +00:00
Paul Elliott
fd3360ebf4 Remove unneeded setting of ret from ssl programs
Remove coverity warnings on unused values.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-09-15 17:41:25 +01:00
Dave Rodgman
da0bb9fae8
Merge pull request #8034 from gilles-peskine-arm/bump_version-doc_mainpage
Update capitalization of "Mbed" and fix bump_version.sh
2023-09-13 08:41:20 +00:00
Gilles Peskine
e820c0abc8 Update spelling "mbed TLS" to "Mbed TLS"
The official spelling of the trade mark changed from all-lowercase "mbed"
to normal proper noun capitalization "Mbed" a few years ago. We've been
using the new spelling in new text but still have the old spelling in a
lot of text. This commit updates most occurrences of "mbed TLS":

```
sed -i -e 's/mbed TLS/Mbed TLS/g' $(git ls-files ':!ChangeLog' ':!tests/data_files/**' ':!tests/suites/*.data' ':!programs/x509/*' ':!configs/tfm*')
```

Justification for the omissions:

* `ChangeLog`: historical text.
* `test/data_files/**`, `tests/suites/*.data`, `programs/x509/*`: many
  occurrences are significant names in certificates and such. Changing
  the spelling would invalidate many signatures and tests.
* `configs/tfm*`: this is an imported file. We'll follow the upstream
  updates.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-12 19:18:17 +02:00
Paul Elliott
a722d0a415 Update CMake minimum version(s) to match main CMakeLists.txt
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-09-12 16:42:14 +01:00
Yanray Wang
022b9a1ca0 benchmark: add AES_CFB8
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-09-12 16:28:37 +08:00
Yanray Wang
55aba195de benchmark: add AES_CFB128
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-09-12 16:24:27 +08:00
Gilles Peskine
1bfc09bca7 Move comment to its intended location
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-09 21:26:05 +02:00
Gilles Peskine
0b62b7a21f Allow turning off re-generation of files with make
In make builds, when GEN_FILES is false (empty), don't try to re-generate
configuration-independent source files, regardless of whether they seem
out of date. This is useful, for example, if you have a source tree where
`make generated_files` has already run and file timestamps reflect the
time the files were copied or extracted, and you are now in an environment
that lacks some of the necessary tools to re-generate the files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-08 16:19:13 +02:00
Ronald Cron
eab2055bde Fix query_config.c generation with CMake build system
In case of an out-of-tree build with the CMake build
system the path to crypto_config.h has to be defined
as the path to mbedtls_config.h. Add this possibility
tp generate_query_config.pl.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2023-09-08 10:23:25 +02:00
Yanray Wang
9b811658a8 Merge remote-tracking branch 'origin/development' into support_cipher_encrypt_only 2023-09-07 16:18:00 +08:00
Gilles Peskine
b9664ee676 Don't include configuration adjustment headers
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-05 11:57:14 +02:00
Yanray Wang
d7058b0a35 dh_client: removed under CIPHER_ENCRYPT_ONLY
dh_client requests AES-ECB to do decryption. So it needs to be
removed under CIPHER_ENCRYPT_ONLY.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-09-01 17:35:58 +08:00
Gilles Peskine
f745e5b8de Merge remote-tracking branch 'development' into HEAD 2023-08-23 20:35:32 +02:00
Tom Cosgrove
17d5081ffb
Merge pull request #8099 from gilles-peskine-arm/split-config_psa-prepare
Prepare to split config_psa.h
2023-08-22 07:30:46 +00:00
Gilles Peskine
796bc2b8f9
Merge pull request #7486 from AndrzejKurek/calloc-also-zeroizes
Document mbedtls_calloc zeroization
2023-08-21 15:47:21 +00:00
Gilles Peskine
9af413bcc5 Don't try to include mbedtls/config_*.h
They're included by build_info.h and must not be included directly.

Currently, this only concerns one file: config_psa.h. It's technically a bug
to include it, but a harmless one because that header has already been
included by build_info.h except in configurations where it
effectively had no effect (enabling PSA options with PSA turned off).

We plan to split config_psa.h into multiple headers that are less
independent, which could make the inclusion more problematic.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:12:36 +02:00
Gilles Peskine
dbd13c3689
Merge pull request #7662 from lpy4105/issue/renew_cert_2027-01-01
Updating crt/crl files due to expiry before 2027-01-01
2023-08-17 15:38:35 +00:00
Gilles Peskine
d370f93898
Merge pull request #7898 from AndrzejKurek/csr-rfc822-dn
OPC UA - add support for RFC822 and DirectoryName SubjectAltNames when generating CSR's
2023-08-16 09:19:46 +00:00
Manuel Pégourié-Gonnard
660bbf2470 test: disable BIGNUM support on the test ecc_no_bignum component
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-08-10 06:43:23 +02:00
Paul Elliott
2f12a29cdd
Merge pull request #7896 from AgathiyanB/gitignore-generated-files-toggle
Add script to toggle ignoring generated files
2023-08-09 14:54:32 +00:00
Thomas Daubney
a68ef95394 Check length before calling memcmp
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-08-07 11:09:51 +01:00
Thomas Daubney
102033c38d Add new line at end of file to satisfy code style
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-08-03 16:20:09 +01:00
Thomas Daubney
5c2dcbd250 Implement cleanup label
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-08-03 16:03:30 +01:00
Thomas Daubney
21fbe4c90e Remove further superfluous call to psa_hash_abort
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-08-03 15:39:42 +01:00
Thomas Daubney
1ba9744afb Correct code style
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 17:25:16 +01:00
Thomas Daubney
c918c32cc0 Stop hashing the null byte
Change the hash data to not include the null byte used to terminate
the string. Pass sizeof() - 1 to the hash operation API functions
so that the null byte can be ignored.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 17:15:03 +01:00
Thomas Daubney
fbe742b2d0 Add extra check to one-shot operation results
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 16:17:38 +01:00
Thomas Daubney
ce14124f7c Check result of multipart operation
Check that the multi-part operation has produced
the correct result.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 16:14:20 +01:00
Thomas Daubney
606110fc19 Restructure start of program
Restructure the start of the program to make it
clear to a user exactly what this program is for.
Add a comment for additional clarity.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 15:57:10 +01:00
Thomas Daubney
1f98736e71 Add clarifying comment to new program section
Mark the beginning of the section that prints
the result with a comment.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 15:23:06 +01:00
Thomas Daubney
a2b7519d63 Use memcmp instead of reinventing it
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 15:21:46 +01:00
Thomas Daubney
9730cb1274 Change hash output formatting
Change the formatting of the hash output
to remove line breaks and spaces.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 15:07:19 +01:00
Thomas Daubney
c07fa29b58 Change wording in error message
Change wording from "failed" since this implied the
function had returned an error status instead of
producing the wrong result.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 14:58:55 +01:00
Thomas Daubney
3071c85835 Clarify comments
Clarify comments when moving into one-shot part
of demo.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 14:47:47 +01:00
Thomas Daubney
c050037c08 Remove mbedtls_ and psa_ prefix from var names
Remove the mbedtls and psa prefixes from variable
names in order to make clearer what is part of
the API and what is just part of the demo program.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 14:44:25 +01:00
Thomas Daubney
a79f806225 Remove superfluous calls to psa_hash_abort
Calls were not required since psa_hash_setup was yet
to be called.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 14:33:20 +01:00
Thomas Daubney
6fc4ca2d85 Replace hash_size with hash_length
This is to make the variable naming covnention align
with the PSA API documentation.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 14:31:06 +01:00
Thomas Daubney
2c872340e8 Fix erroneous macro guards
Replace MBEDTLS_SHA256_C for PSA_WANT_ALG_SHA_256
everywhere, including comments and print statements.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-28 14:21:38 +01:00
Gowtham Suresh Kumar
186731b22a Fix warnings from clang-16
Running clang-16 on mbedtls reports warnings of type "-Wstrict-prototypes".
This patch fixes these warnings by adding void to functions with no
arguments. The generate_test_code.py is modified to insert void into test
functions with no arguments in *.function files.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-26 17:11:51 +01:00
Gilles Peskine
f5d2d1c7cd Skip dlopen demo in static builds
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 20:23:44 +02:00
Gilles Peskine
c25ae6f48c Use demo_common.sh in dlopen test script
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 20:23:44 +02:00
Gilles Peskine
086f85f055 Fix some mistakes in descriptive messages
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:40:35 +02:00
Gilles Peskine
911081efd2 Explain why $root_dir needs a complicated calculation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:40:14 +02:00
Gilles Peskine
fc09d27a92 Print only missing dependencies
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:40:14 +02:00
Gilles Peskine
c142620724 cleanup is part of the external interface
Since there's no EXIT trap in plain sh, the main script must call it
explicitly when it exits.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:40:14 +02:00
Gilles Peskine
03be234c7f Declare the dependencies of key_ladder_demo.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:36:39 +02:00
Gilles Peskine
b2bcdc1c17 Let demo scripts declare their dependencies
Demo scripts should declare their build-time dependencies, to make
them more user-friendly. If a dependency is not met, users should see
an explicit message rather than an incomprehensible error.

Don't rely on the dependencies of individual programs because some
demo scripts use multiple programs and because some scripts might have
additional requirements.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:36:39 +02:00
Gilles Peskine
958be36b19 Demo scripts: create a seedfile if the configuration requires it
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:36:39 +02:00
Gilles Peskine
d1b5f6f609 Move common code of demo scripts into a library
The new file programs/demo_common.sh contains initialization code,
utility functions and cleanup code meant to be used by all demo
scripts written in sh.

Initial features:

* msg: Display a message.
* run, run_bad: Run a command, visibly.
* $root_dir, $programs_dir: location of the mbedtls source tree.
* $files_to_clean: files that are cleaned up on exit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-25 19:36:13 +02:00
Thomas Daubney
1fd916a1a3 Address review comments
- make operation name more generic
- make use of psa_hash_abort

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-25 16:10:48 +01:00
Thomas Daubney
9520df7580 Fix code style
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-25 10:56:54 +01:00
Thomas Daubney
1db78fa32a Demonstrate algorithm agility
Define HALH_ALG to the desired PSA algorithm
to demostrate the ease of swapping algorithms
with the PSA API.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-24 16:49:14 +01:00
Thomas Daubney
f7348ae1fc Improve program from first round review comments
Following an initial review:
- Swap printf for mbedtls_printf
- Remove MBEDTLS_xxx dependencies
- Demonstrate correct buffer sizing

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-24 12:18:40 +01:00
Thomas Daubney
209c9c9492 Bring code-style up-to-date
This PR was originally created before the code
style was changed. This commit updates the style.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-18 14:59:45 +01:00
Hannes Tschofenig
f8b9ebf297 Add example program for PSA hash
This commit adds the example program for PSA
hash as well as the relevant changes to
CMakeLists.txt and the Makefile.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-07-18 13:55:36 +01:00
Manuel Pégourié-Gonnard
828b3acd6b
Merge pull request #7848 from valeriosetti/issue7749
driver-only ECC: EPCf.TLS testing
2023-07-18 10:33:21 +02:00
Dave Rodgman
91d9daf2b3
Merge pull request #7925 from hasheddan/dtls-server-order
Fix order of steps in DTLS server example program
2023-07-17 09:41:43 +01:00
Daniel Mangum
af2f7a6fcb Fix order of steps in DTLS server example program
Fixes the numbered order of steps in the DTLS server example program.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-07-14 12:00:33 -04:00
Andrzej Kurek
312b6df38a Add a missing guard in cert_req.c
IP parsing requires x509_CRT_PARSE_C
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-10 08:45:30 -04:00
Valerio Setti
dda0019e2e ssl_test_lib: fix rebase error
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-07-10 10:22:51 +02:00
Valerio Setti
5bdebb2004 ssl_test_lib: fix variable naming for curve group
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-07-10 09:13:57 +02:00
Valerio Setti
fb6356f003 ssl_test_lib: simplify function which prints supported curves
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-07-10 09:13:57 +02:00
Valerio Setti
deb676442d ssl_test_lib: manage FFDH keys the same way as ECC ones
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-07-10 09:13:57 +02:00
Valerio Setti
acd32c005f programs: add helper functions for supported EC curves
- get full list, or
- get TLS ID from name

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-07-10 09:13:57 +02:00
Manuel Pégourié-Gonnard
461d59b2f8
Merge pull request #7858 from mprse/ffdh_tls13_v2_f
Make use of FFDH keys in TLS 1.3 - follow-up
2023-07-07 16:19:35 +02:00
Dave Rodgman
c4749b1c66
Merge pull request #7584 from gilles-peskine-arm/fuzz-file-open-fail
Fuzz programs: print an error if loading the reproducer fails
2023-07-07 11:51:59 +01:00
Andrzej Kurek
6bc7a38683 Support more SAN subtypes in cert_req.c
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-07 05:13:13 -04:00
Agathiyan Bragadeesh
77b0d645f5 Add gitignore anchors to denote generated files
These anchors encapsulate gitignore patterns which typically ignore
files generated, so that scripts can be used to comment and uncomment
these patterns for releases when we need the generated files in the
repository.

Signed-off-by: Agathiyan Bragadeesh <agabra02@e127300.arm.com>
2023-07-06 17:58:18 +01:00
Przemek Stekiel
68e7544de8 parse_groups: curve -> group adaptations
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-06 12:16:44 +02:00
Przemek Stekiel
45255e4c71 Adapt names (curves -> groups)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-07-05 09:26:26 +02:00
Pengyu Lv
b078607f04 cert_write: Support write any for extended key usage
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-07-04 17:30:21 +08:00
Manuel Pégourié-Gonnard
56b159a12a
Merge pull request #7627 from mprse/ffdh_tls13_v2
Make use of FFDH keys in TLS 1.3 v.2
2023-07-03 10:12:33 +02:00
Dave Rodgman
c23d2222ea
Merge pull request #7728 from waleed-elmelegy-arm/crypt_and_hash-decrypt-fix
Fix crypt_and_hash decrypt issue when used with stream cipher
2023-06-30 11:42:35 +01:00
Andrzej Kurek
60de0b198a Move the overallocation test to test suites
This way the compiler does not complain about
an overly large allocation made.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-27 09:26:08 -04:00
Andrzej Kurek
aae3208c29 Add an mbedtls_calloc(SIZE_MAX/2, SIZE_MAX/2) test
It should return NULL and not a valid pointer.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-27 09:26:08 -04:00
Andrzej Kurek
e35f3a23be Add a calloc selftest for more than a page
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-27 09:26:08 -04:00
Andrzej Kurek
ecaf6fb8b2 Documentation and cosmetic fixes
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-27 09:26:08 -04:00
Andrzej Kurek
9032711dc7 Move the calloc buffer initialization test to selftest.c
This way it's more in line with the 2.28 version.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-27 09:26:08 -04:00
Manuel Pégourié-Gonnard
39a0a76fcc SSL programs: improve command-line error reporting
Every now and then, I see of these programs failing with a super-long
usage message that gives no clue as to what went wrong. (Recently it
happened with a test case in ssl-opt.sh with a fairly long command line
that was entirely correct, except some options were not valid in this
config - the test should have been skipped but wasn't due to some other
bug. It took me longer to figure out than it should have, and could have
if the program had simply reported which param was not recognized.)

Also, have an explicit "help" command, separate "help_ciphersuites", and
have default usage message that's not multiple screens long.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-06-27 09:28:24 +02:00
Manuel Pégourié-Gonnard
3eea9a461c SSL programs: allow invoking without arguments
All options have reasonable default so the programs don't need arguments
to do something useful.

It is widely accepted for programs that can work without arguments need
not insist on the user passing arguments, see 'ls', 'wc', 'sort', 'more'
and any number of POSIX utilities that all work without arguments.

It is also the historical behaviour of those programs, and something
relied one by at least a few team members.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-06-26 11:29:35 +02:00
Manuel Pégourié-Gonnard
0b74434e2a SSL programs: group options processing in 1 place
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-06-26 11:28:00 +02:00
Paul Elliott
458b96b1a7
Merge pull request #7638 from AndrzejKurek/cert-apps-use-ips
Use better IP parsing in x509 apps
2023-06-20 17:21:04 +01:00
Przemek Stekiel
7d42c0d0e5 Code cleanup #2
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-13 12:30:40 +02:00
Przemek Stekiel
75a5a9c205 Code cleanup
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-13 09:57:23 +02:00
Waleed Elmelegy
46549cb5fa Replace function calls in crypt_and_hash program with locals
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-06-12 14:53:02 +01:00
Waleed Elmelegy
7d39cc410c Fix crypt_and_hash decrypt issue when used with stream cipher
crypt_and_hash decryption fails when used with a stream cipher
mode of operation due to the input not being multiple of block
size, this only applies to block cipher modes and not stream
ciphers.This change exempts CTR, CFB & OFB modes from this check.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-06-09 16:58:23 +01:00
Dave Rodgman
05d71ffe5b Merge remote-tracking branch 'origin/development' into sha3-updated 2023-06-07 18:02:04 +01:00
Andrzej Kurek
0624e460fb Add a guard for IP parsing in cert_req app
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-07 08:54:35 -04:00
Andrzej Kurek
cd17ecfe85 Use better IP parsing in x509 programs
Remove unnecessary duplicated code.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-07 08:50:05 -04:00
Przemek Stekiel
ff9fcbcace ssl_client2, ssl_server2: code optimization + guards adaptation
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-06 12:53:40 +02:00
Przemek Stekiel
da4fba64b8 Further code optimizations
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-06 12:31:09 +02:00
Przemek Stekiel
316c19ef93 Adapt guards, dependencies + optimizations
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-06 12:31:09 +02:00
Przemek Stekiel
e7db09bede Move FFDH helper functions and macros to more suitable locations
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-06 12:31:08 +02:00
Przemek Stekiel
6d7da5ee1e Add FFDH support in client2, server2 applications
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-06-06 12:31:08 +02:00
Gilles Peskine
84b547b5ee
Merge pull request #7400 from AndrzejKurek/cert-write-sans
Add a possibility to generate certificates with a Subject Alternative Name
2023-06-05 15:38:38 +02:00
Andrzej Kurek
f994bc51ad Refactor code in cert_write.c
This way is more robust.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-02 05:10:17 -04:00
Dave Rodgman
7f97675b64
Merge pull request #5237 from davidhorstmann-arm/demo-out-of-tree 2023-05-19 21:27:24 +01:00
Andrzej Kurek
5eebfb8fd0 Enable escaping ';' in cert_write.c SANs
This might get used in URIs.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
446e53d401 Fix a code style issue
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
f70f460e5f Fix temporary IP parsing error
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
ed557930bb Update ip_string_to_bytes to cert_req version
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
5da1d751e9 Add missing memory deallocation
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
1bc7df2540 Add documentation and a changelog entry
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 15:23:56 -04:00
Andrzej Kurek
ccdd975286 Add a certificate exercising all supported SAN types
This will be used for comparison in unit tests.
Add a possibility to write certificates with SAN
in cert_write.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-05-17 11:45:36 -04:00
Paul Elliott
aba165b58c
Merge pull request #7586 from gilles-peskine-arm/gitignore-objects-at-root
Ignore *.o everywhere
2023-05-15 13:57:24 +01:00
Gilles Peskine
8075f76708 Ignore *.o everywhere
We don't commit *.o files anywhere, not even as test data. So ignore them
everywhere.

This resolves *.o files not being ignored under 3rdparty/p256-m.

Also remove a redundant ignore of *.exe in a subdirectory.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:58:05 +02:00
Gilles Peskine
1f9d8a43c2 Fuzz programs: print an error if loading the reproducer fails
The fuzz programs were returning a nonzero status if they failed to load the
reproducer, but that's discreet and not informative. Make them also print an
error message.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:18:08 +02:00
David Horstmann
4dfa368681 Fix demo scripts for out-of-tree builds
Allow demo scripts to be run from the build directory for out-of-tree
builds.

If the executable is not found in the source tree then search in the
current directory in case the script is being run from a build
directory.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-05-09 18:30:05 +01:00
Gilles Peskine
97edeb4fb8
Merge pull request #6866 from mprse/extract-key-ids
Extracting SubjectKeyId and AuthorityKeyId in case of x509 V3 extensions v.2
2023-05-08 20:38:29 +02:00
Pol Henarejos
d06c6fc45b
Merge branch 'development' into sha3
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2023-05-05 16:01:18 +02:00
Dave Rodgman
417c4c8b2c
Merge pull request #5770 from mstorsjo/win32-fallback-timer
Use QueryPerformanceCounter as fallback timer on non-x86 mingw
2023-05-05 14:31:41 +01:00
Gilles Peskine
53a9ac576d
Merge pull request #7443 from mprse/psa_init_in_programs
Init PSA in ssl and x509 programs
2023-04-28 12:49:11 +02:00
Przemek Stekiel
94cf710edc Revert increase of MEMORY_HEAP_SIZE in ssl_client2
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-24 16:35:40 +02:00
Przemek Stekiel
5346396c48 Fix code-style
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-24 09:01:41 +02:00
Przemek Stekiel
758aef60c5 Add guards for mbedtls_psa_crypto_free()
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-24 08:10:01 +02:00
Przemek Stekiel
774f9debf2 Init PSA in fuzz programs
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-24 08:07:20 +02:00
Przemek Stekiel
2c1ef0967c Init PSA in pkey programs
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-19 10:16:53 +02:00
Przemek Stekiel
a8c560a799 Free psa crypto at the end of programs when initialized
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-19 10:15:26 +02:00
Przemek Stekiel
e296868b25 Remove print from mini_client
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-17 11:11:01 +02:00
Przemek Stekiel
a0a1c1eab5 Move psa_crypto_init() after other init calls
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-17 11:10:05 +02:00
Przemek Stekiel
6260ee9cab cert_app: init entropy unconditionally
When mbedtls_entropy_free() is called without mbedtls_entropy_init() entropy is uninitialized and contains garbage which may lead to segmentation fault.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-16 22:42:01 +02:00
Przemek Stekiel
89c636e6cf Init PSA in ssl and x509 programs
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2023-04-16 22:41:52 +02:00
Valerio Setti
d49cbc1493 test: fix remaining failures in test due to the ECP_LIGHT symbol
Changes in test_suite_psa_crypto are to enforce the dependency
on ECP_C which is mandatory for some key's derivation.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-11 11:33:50 +02:00
Gilles Peskine
7c1c7ce90e
Merge pull request #7401 from AndrzejKurek/md-guards-missing
Add missing md.h includes
2023-04-11 09:32:17 +02:00
Gilles Peskine
c9e8a65d06
Merge pull request #7298 from lpy4105/issue/6840/add-cache-entry-removal-api
ssl_cache: misc improvements
2023-04-11 09:30:40 +02:00
Andrzej Kurek
0af32483f3 Change the format of md.h include comments
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-04-07 03:10:28 -04:00
Andrzej Kurek
0e03f4c119 Remove unnecessary include
This is a PSA-based program and psa/crypto.h
is already included.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-04-06 07:55:25 -04:00
Andrzej Kurek
316b7dd19c Add a justification for early md.h include in programs
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-04-05 14:44:38 -04:00
Andrzej Kurek
da86e2e5bd Revert to using MBEDTLS_SHA_1_C when mbedtls_sha1 is called directly
This was mistakingly changed in #7327.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-04-05 14:39:22 -04:00
Andrzej Kurek
eaea30d30e Remove duplicated md.h includes
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-04-05 14:36:51 -04:00
toth92g
27f9e7815c Adding openssl configuration file and command to Makefile to be able to reproduce the certificate for testing Authority and Subject Key Id fields
Increasing heap memory size of SSL_Client2 and SSL_Server2, because the original value is not enough to handle some certificates. The AuthorityKeyId and SubjectKeyId are also parsed now increasing the size of some certificates

Signed-off-by: toth92g <toth92g@gmail.com>
2023-04-04 17:48:27 +02:00