31656 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
8e70c2bcd9 Test cert alert KEY_USAGE -> UNSUPPORTED_CERT
In terms of line coverage, this was covered, except we never checked the
behaviour was as intended.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:23:31 +01:00
Sam Berry
2547cd3535 Free allocated memory where methods were returning
without freeing

Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-08-16 16:38:34 +01:00
Waleed Elmelegy
e25cb1bcda Fix formatting issue in psa_key_agreement() documentation
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-16 14:37:46 +01:00
Waleed Elmelegy
d1562407c3 Fix possible issues in testing and implementation of psa_key_agreement()
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-16 14:37:46 +01:00
Waleed Elmelegy
8faeee24ae Improve documentation of psa_key_agreement()
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-16 14:37:46 +01:00
Waleed Elmelegy
cb0ed88df1 Add change log entry for adding psa_key_agreement() API
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-16 14:37:46 +01:00
Waleed Elmelegy
bdf2c98a27 Add psa_key_agreement() API
Add psa_key_agreement() API and basic testing.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-16 14:36:47 +01:00
Janos Follath
659f9e78fd
Merge pull request #9441 from paul-elliott-arm/add_docs_iop_key_generation
Add documentation for interruptible ECC key generation
2024-08-16 08:34:24 +00:00
Janos Follath
9e088847ae Clarify IOP key generation restriction
Public keys can't be generated.

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 13:51:05 +01:00
Janos Follath
9f48917b88 Improve IOP documentation
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 13:51:05 +01:00
Janos Follath
7311600fd5 Constrain interruptible key generation to key-pairs
Erroring on a symmetric-key type would actually be an extra line of
code.

In theory we could try to save that one line of code, but it is
premature optimisation at this point. Also, this is a predominantly
asymmetric crypto feature, it is less confusing/more user friendly if we
don't allow symmetric keys here.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 13:51:05 +01:00
Janos Follath
211ebb51da Don't return success on a stub
We shouldn't return PSA_SUCCESS from a function that isn't implemented.
PSA_ERROR_NOT_SUPPORTED seems like the most appropriate return status
for a function that isn't implemented.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 13:51:05 +01:00
Paul Elliott
2dc5fa3a19 Add generated files for new iop key generation funcs
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-08-15 13:51:05 +01:00
Paul Elliott
0c1aa4af38 Add psa_generate_key_iop_abort() documentation
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-08-15 13:51:04 +01:00
Paul Elliott
08afb00a9b Add psa_generate_key_iop_complete() documentation
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-08-15 13:51:04 +01:00
Paul Elliott
6044f3e444 Add psa_generate_key_iop_setup() documentation
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-08-15 13:51:04 +01:00
Paul Elliott
f712452a0e Add psa_generate_key_iop_get_num_ops() docs
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-08-15 13:51:04 +01:00
Paul Elliott
9e143a73ea Add psa_generate_key_iop_t structs and docs
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 13:50:52 +01:00
Tom Cosgrove
2bb83bd885
Merge pull request #9480 from gilles-peskine-arm/psa-keystore-static-release-update-development
Key store spec: update release target for the static key store
2024-08-15 11:09:54 +01:00
Sergey Markelov
4ed0fded12 Fix Mbed-TLS build when WIN32_LEAN_AND_MEAN macro is defined globally
Signed-off-by: Sergey Markelov <sergey@solidstatenetworks.com>
2024-08-14 15:15:14 -07:00
Gilles Peskine
59602d3929 The fully static key store will miss the 3.6.1 release
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-14 11:41:34 +02:00
Gilles Peskine
3c1d287f8d Mention the option name for the dynamic key store
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-14 11:41:33 +02:00
Manuel Pégourié-Gonnard
8067879c1f
Merge pull request #9313 from sezrab/psa_util_in_builds_without_psa-development
psa_util.c included in builds without PSA, which can break the build
2024-08-14 07:16:21 +00:00
Manuel Pégourié-Gonnard
a7b0e55efc
Merge pull request #9474 from gilles-peskine-arm/framework-update-20240813-development
Update framework to the head of the main branch
2024-08-14 07:11:29 +00:00
Gilles Peskine
d11025027b
Merge pull request #9362 from eleuzi01/replace-key-camellia
Replace MBEDTLS_SSL_HAVE_CAMELLIA with PSA_WANT_KEY_TYPE_CAMELLIA
2024-08-13 13:55:34 +00:00
Sam Berry
26769f190b Changelog entry
Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-08-13 14:40:22 +01:00
Janos Follath
1176e6f90e
Merge pull request #9410 from paul-elliott-arm/add_docs_iop_key_agreement
Add IOP Key agreement Documentation
2024-08-13 13:25:22 +00:00
Gilles Peskine
2ae2f451a9 Update framework to the head of the main branch
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-13 11:45:07 +02:00
Elena Uziunaite
da41b60cef Replace MBEDTLS_SSL_HAVE_CAMELLIA with PSA_WANT_KEY_TYPE_CAMELLIA
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-13 09:58:00 +01:00
Gilles Peskine
b8457fff9f
Merge pull request #9353 from eleuzi01/replace-ecp-have-secp384r1
Replace MBEDTLS_ECP_HAVE_SECP384R1 with PSA_WANT_ECC_SECP_R1_384
2024-08-12 14:37:10 +00:00
Gilles Peskine
0858fdca38
Merge pull request #9189 from misch7/fix-v3.6-issues-9186-and-9188
Fix build of v3.6 (issues #9186 and #9188)
2024-08-12 09:34:17 +00:00
Gilles Peskine
1782cc8b95
Merge pull request #1264 from Mbed-TLS/pre3.6.1_test_merge_upstream_dev
Merge development into -restricted
2024-08-12 11:24:35 +02:00
Michael Schuster
b77c419add
Update the submodule to the head of PR in the framework repository
See Mbed-TLS/mbedtls-framework#23

Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-09 20:39:28 +02:00
Bence Szépkúti
88f3dd9f78
Merge pull request #9402 from tom-daubney-arm/remove_function_level_alt_interface
Remove function level alt interface
2024-08-09 17:59:51 +00:00
Michael Schuster
a52952dcb1 Update the submodule to the head of PR in the framework repository
See Mbed-TLS/mbedtls-framework#23

Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-09 14:58:54 +01:00
Gilles Peskine
d339aefd91 Clarify some internal documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
5abeb8c77b Make integer downsizing explicit
Reassure both humans and compilers that the places where we assign an
integer to a smaller type are safe.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
75fd2401e5 Changelog entry for MBEDTLS_PSA_KEY_STORE_DYNAMIC
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
a9dda7e3d0 Add test components with the PSA static key store
We were only testing the static key store (MBEDTLS_PSA_KEY_STORE_DYNAMIC
disabled) with configs/*.h. Add a component with the static key store and
everything else (including built-in keys), and a component with the static
key store and CTR_DBRG using PSA for AES (which means PSA uses a volatile
key internally).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
75071066f2 Dynamic key store: make full-key-store tests work effectively
Add a practical way to fill the dynamic key store by artificially limiting
the slice length through a test hook.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
aadeeb3e76 Microoptimizations when MBEDTLS_PSA_KEY_STORE_DYNAMIC is disabled
Compensate some of the code size increase from implementing dynamic key slots.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
eab36d1d06 Dynamic key store: implementation
When MBEDTLS_PSA_KEY_STORE_DYNAMIC is enabled, key slots are now organized in
multiple slices. The slices are allocated on demand, which allows the key
store to grow. The size of slices grows exponentially, which allows reaching
a large number of slots with a small (static) number of slices without too
much overhead.

Maintain a linked list of free slots in each slice. This way, allocating a
slot takes O(1) time unless a slice needs to be allocated.

In this commit, slices are only ever freed when deinitializing the key
store. This should be improved in the future to free empty slices.

To avoid growing the persistent key cache without control, the persistent
key cache has a fixed size (reusing MBEDTLS_PSA_KEY_SLOT_COUNT to avoid
creating yet another option).

When MBEDTLS_PSA_KEY_STORE_DYNAMIC is disabled. no semantic change and
minimal changes to the code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
dc41fff669 psa_key_slot_t: different fields in free vs occupied slots
Place some fields of psa_key_slot_t in a union, to prepare for a new field
in free slots that should not require extra memory.

For occupied slots, place only the registered_readers field in the union,
not other fields, to minimize textual changes. All fields could move to the
union except state (also needed in free slots) and attr (which must stay
first to reduce the code size, because it is accessed at many call sites).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
5c81b9403d Dynamic key store: disable full-key-store tests
It's impractical to fill the key store when it can grow to accommodate
millions of keys.

A later commit will restore those tests in test configurations with the
dynamic key store.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:11 +02:00
Gilles Peskine
54ee98c067 Dynamic key store: preparatory refactoring
Add some abstractions around code that traverses the key store, in
preparation for adding support for MBEDTLS_PSA_KEY_STORE_DYNAMIC.

No intended behavior change. The generated machine code should be
almost the same with an optimizing compiler (in principle, it could be the
same with sufficient constant folding and inlining, but in practice it will
likely be a few byes larger),

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:10 +02:00
Gilles Peskine
9e9e1f60e2 Dynamic key store: new compilation option
Create a new compilation option for a dynamically resized key store. The
implementation will follow in subsequent commits.

This option is off by default with custom configuration files, which is best
for typical deployments on highly constrained platforms. This option is on
by default with the provided configuration file, which is best for typical
deployments on relatively high-end platforms.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 15:41:10 +02:00
Michael Schuster
9e52d157e8 Fix missing-prototype error for the print_buf functions in sample programs
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-09 10:29:59 +01:00
Michael Schuster
c1cd26b20f Revert commit 33af72df in order to not depend on test code
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-09 10:29:59 +01:00
Michael Schuster
82cb06913a Fix format-pedantic error in programs/test/metatest.c
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-09 10:29:59 +01:00
Michael Schuster
f672b694fa Use correct conditionals in programs/ssl (fix unused-function errors)
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-09 10:29:59 +01:00