1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-05-31 15:01:14 +03:00

7374 Commits

Author SHA1 Message Date
Gilles Peskine
fe4d93ad4d ssl_cache: return error codes on error
mbedtls_ssl_cache_get() and mbedtls_ssl_cache_set() returned 1 on many error
conditions. Change this to returning a negative MBEDTLS_ERR_xxx error code.

Completeness: after this commit, there are no longer any occurrences of
`return 1` or `ret = 1`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-29 13:40:33 +02:00
Gilles Peskine
917dd8bd81 Add new error code for SSL cache entry not found
There was no good error to return in this case.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-29 13:39:49 +02:00
Dave Rodgman
7a8ec0f56c
Merge pull request #8209 from lpy4105/issue/8168/2.28_fix-aesni-selection
2.28: Fix AESNI selection
2023-09-26 16:55:28 +00:00
Pengyu Lv
7fb6fc60ce padlock: introduce MBEDTLS_VIA_PADLOCK_HAVE_CODE
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-09-14 14:02:02 +08:00
Gilles Peskine
51616459fa
Merge pull request #7211 from sergio-nsk/patch-3
mbedtls-2.28: Fix llvm error: variable 'default_iv_length' may be used uninitialized
2023-09-13 16:39:08 +02:00
Gilles Peskine
f08ca83b4f 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:21:54 +02:00
Gilles Peskine
e008890afa Update generated files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-07 19:20:34 +02:00
Tom Cosgrove
73285cc075 Define all PSA_xxx macros to 1 rather than have them empty, for consistency
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-09-01 13:07:39 +01:00
Paul Elliott
12a2bfc970
Merge pull request #8096 from davidhorstmann-arm/2.28-initialize-struct-get-other-name
[Backport 2.28] Coverity fix: Set `type_id` in `x509_get_other_name()`
2023-08-31 14:10:06 +00:00
Tom Cosgrove
2bda812130
Merge pull request #8085 from gilles-peskine-arm/mpi_exp_mod-remove_initial_copy-2.28
Backport 2.28: mbedtls_mpi_exp_mod: remove spurious copy of the output variable
2023-08-21 15:50:30 +00:00
Tom Cosgrove
f9f183c107
Merge pull request #8089 from ivq/8017-backport
Backport 2.28: Fix a few unchecked return values
2023-08-21 13:03:01 +00:00
David Horstmann
dcf73265ba Fix incorrect detection of HardwareModuleName
The hardware module name otherName SAN contains 2 OIDs:

 OtherName ::= SEQUENCE {
      type-id    OBJECT IDENTIFIER,
      value      [0] EXPLICIT ANY DEFINED BY type-id }

 HardwareModuleName ::= SEQUENCE {
                           hwType OBJECT IDENTIFIER,
                           hwSerialNum OCTET STRING }

The first, type-id, is the one that identifies the otherName as a
HardwareModuleName. The second, hwType, identifies the type of hardware.

This change fixes 2 issues:

1. We were erroneously trying to identify HardwareModuleNames by looking
at hwType, not type-id.
2. We accidentally inverted the check so that we were checking that
hwType did NOT match HardwareModuleName.

This fix ensures that type-id is correctly checked to make sure that it
matches the OID for HardwareModuleName.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-18 19:51:06 +01:00
David Horstmann
4a46d23a36 Fix: Set type_id in x509_get_other_name()
When parsing a subject alternative name of type otherName, retain the
type-id field of the otherName. Previously this was not copied to the
mbedtls_x509_san_other_name struct when it should have been.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-18 19:46:13 +01:00
Antonio de Angelis
431e5c4199 Remove workaround for non-zero shared_secret array
PSA_KEY_AGREEMENT_MAX_SHARED_SECRET_SIZE is always greater
than 1 so no need for the workaround on the original patch

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-17 15:36:21 +01:00
Chien Wong
0118a1d712
Fix a few unchecked return values
Signed-off-by: Chien Wong <m@xv97.com>
2023-08-17 22:13:11 +08:00
Gilles Peskine
20d54e3115 mbedtls_mpi_exp_mod: remove spurious copy of the output variable
Clear some confusion between `X` as the output variable and "X" as a name
given to the accumulator. Previous iterations of the code used the variable
`X` as the accumulator, but now that the accumulator is `W[x_index]`, some
of the comments didn't make sense.

Remove the copy of the initial value of `X` into `W[x_index]`, which was
meaningless: the initial value of an output variable should not, and did
not, matter. `W[x_index]` is later overridden unconditionally to take the
value `RR`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-17 14:39:25 +02:00
Antonio de Angelis
1505d3232d Fix error strings without quotes
Some of the error strings that should be printed with the
error preprocessor directive are missing quotes

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 16:28:42 +01:00
TTornblom
ac9e3402ab BUILD: Update For IAR support
Applied the same change as in mbed-crypto for using this as a sub
project with the IAR toolchain. Use __asm generic ,and avoid empty
enum. Avoid declaration of array with null size. This is a porting
of the original patch contributed to trusted-firmware-m.

Signed-off-by: TTornblom <thomas.tornblom@iar.com>
Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 16:25:47 +01:00
Gilles Peskine
64a81357c3
Merge pull request #8037 from tom-cosgrove-arm/fix-rijndael-and-drbg-pdf-links-2.28
Backport 2.28: Update links to Rijndael paper and NIST SP 800-90 DRBGs
2023-08-07 19:16:01 +00:00
Gilles Peskine
b438348774
Merge pull request #8010 from marekjansta/fix-x509-ec-algorithm-identifier-2.28
Backport 2.28: Fixed x509 certificate generation to conform to RFCs when using ECC key
2023-08-07 19:14:52 +00:00
Tom Cosgrove
aaec13793a Update links to Rijndael paper and NIST SP 800-90 DRBGs
The link to the DRBG paper points to the March 2007 version, the same as the
original link (rather than the latest version).

The amended Rijndael paper has a two-page "Note on naming" prefix.

Fixes #7193

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-08-04 15:08:48 +01:00
Dave Rodgman
f97832a5ec
Merge pull request #8015 from AgathiyanB/fix-unnecessary-type-quantifier
Fix IAR warning about unnecessary type quantifier
2023-08-03 15:57:01 +00:00
Dave Rodgman
403ce0a6cc Bump version numbers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-02 15:35:45 +01:00
Agathiyan Bragadeesh
06d5e10989 Fix IAR warning about unnecessary type quantifier
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 14:23:01 +01:00
Marek Jansta
0a6743b2de Fixed AlgorithmIdentifier parameters when used with ECDSA signature algorithm in x509 certificate
Signed-off-by: Marek Jansta <jansta@2n.cz>
2023-07-31 17:33:23 +02:00
Marek Jansta
f5257c06d1 Cherry picked required prerequisites from dev branch, git hash 0167244b
Signed-off-by: Marek Jansta <jansta@2n.cz>
2023-07-31 17:33:16 +02:00
Agathiyan Bragadeesh
e7eb8052be Seperate declarations from function body
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-31 16:20:27 +01:00
Agathiyan Bragadeesh
5521b4ce37 Assign have_rng in declaration of ecp_mul_mxz
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-31 16:15:56 +01:00
Agathiyan Bragadeesh
7b0ee1e655 Fix control bypass warnings
Declarations have been moved to the top of functions to fix this

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-27 15:51:46 +01:00
Gilles Peskine
9a9d5eea53 Fix a build error when MBEDTLS_PSA_INJECT_ENTROPY is enabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:07:47 +02:00
Paul Elliott
dc1244d135
Merge pull request #6974 from davidhorstmann-arm/2.28-cmake-pass-through-config-defines
[Backport 2.28] Pass `MBEDTLS_CONFIG_FILE` defines through cmake
2023-07-07 17:01:24 +01:00
Tom Cosgrove
f788a45d47
Merge pull request #7213 from sergio-nsk/patch-5
mbedtls-2.28: Fix error: comparison of integers of different signs: 'SOCKET' and 'int'
2023-07-07 16:46:03 +01:00
David Horstmann
58dda6713c Use emptiness-checks rather than DEFINED checks
For the MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE variables,
check that they are non-empty and defined. This means they can be
unconditionally created in the cache, simplifying the CMakeLists.txt

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 18:12:09 +01:00
David Horstmann
1a30cf70cc Pass config file options to mbedtls_test(_helpers)
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:35:08 +01:00
David Horstmann
e31e287109 Pass MBEDTLS_CONFIG_FILE defines through cmake
When -DMBEDTLS_CONFIG_FILE or -DMBEDTLS_USER_CONFIG_FILE are passed to
cmake, pass them through as compile definitions. This allows different
mbedtls configs to be passed at configure time without modifying any
cmake files.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:33:11 +01:00
Dave Rodgman
08efc3d768
Merge pull request #7854 from daverodgman/fix-unused-aes-2.28
Fix AES dependencies - build TF-M config cleanly - backport 2.28
2023-07-03 16:48:39 +01:00
Dave Rodgman
a3fc295559
Merge pull request #7823 from SlugFiller/mbedtls-2.28
Support compilation using CLang on Windows
2023-07-03 09:52:03 +01:00
Dave Rodgman
f72b8375d0 Fix order of endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 16:33:03 +01:00
Dave Rodgman
1d0033e1ac Improve #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:13:26 +01:00
Dave Rodgman
1ce92e4887 Correct #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:13:15 +01:00
Dave Rodgman
a4a337360d Correct comments on #endif's
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:13:08 +01:00
Dave Rodgman
94210b13eb Compile fixes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 14:08:07 +01:00
Dave Rodgman
bae79fa16e Add missing sha header includes to entropy.c
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:54:53 +01:00
Dave Rodgman
1262315a1a Fix warnings re: unused variables in pkparse and pkwrite
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:54:25 +01:00
Dave Rodgman
f488c2ca79 Add missing include for INT_MAX definition
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:35:25 +01:00
Dave Rodgman
584b62f89e code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:31:29 +01:00
Dave Rodgman
9d3b63396b Fix comment
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:31:29 +01:00
Dave Rodgman
5c047d9672 More dependency fixes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:31:29 +01:00
Dave Rodgman
36c8e581d6 Fix unused variable
Fix when MBEDTLS_AES_SETKEY_ENC_ALT, MBEDTLS_AES_DECRYPT_ALT and
MBEDTLS_AES_ROM_TABLE set.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:31:29 +01:00
Dave Rodgman
dbae184ceb Fix unused variable if MBEDTLS_AES_SETKEY_ENC_ALT and MBEDTLS_AES_DECRYPT_ALT set
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-28 11:31:29 +01:00