-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extended key creation functions for non-default production methods #194
Add extended key creation functions for non-default production methods #194
Conversation
For now - marked this as a draft PR. Some rework of the API is required. It turns out that the variable-sized structure definition is not strictly legal in C++, and inclusion and use from C++ is an expected use case for the Crypto API. |
doc/crypto/api.db/psa/crypto.h
Outdated
typedef uint8_t psa_pake_step_t; | ||
typedef struct psa_key_production_parameters_t { | ||
uint32_t flags; | ||
uint8_t data[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesterday I learned that flexible array members are not standard C++. It is generally expected that C++ compilers can consume C headers, so Mbed TLS and PSA should avoid making headers incompatible with C++.
In Mbed TLS, we'll stay with this API in 3.6.x LTS (too late, it's released), but we'd like to change the API to be C++-compatible in our next major release.
The obvious fix would be to separate the variable-length data out of the struct. This may require a little more RAM in client-server scenarios, but on the bright side it would save the hassle around mixing fixed-format and variable-length data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The obvious fix would be to separate the variable-length data out of the struct. This may require a little more RAM
The most obvious is declaring array of size 1 instead of 0; RAM waste would be none or minimal.
Static analysis and memory sanitizer might be unhappy, though.
ed4a717
to
d074a0f
Compare
d074a0f
to
db30ef6
Compare
Updated in line with the proposal in #167 (comment). This is force-pushed to remove the uneccessary changes to the buffer parameter conventions. The changes between the earlier API in the PR are visible in the single commit db30ef6. |
To support migration for applications using the beta version of this API in Mbed TLS, we need to consider if we can use a different function name for these new APIs. |
Some ideas (including considered and discarded ones) for alternative function names:
Rejected ideas
|
Using a 'custom' infix, to differentitate the API from the beta API deployed in MbedTLS
49cc0ef
to
bde1d2d
Compare
Rebased to sync with main. |
This change has been adopted from Mbed TLS: Mbed-TLS/mbedtls#8815, with changes to make it compatible with C++ compilation.
psa_generate_key_ext()
andpsa_key_derivation_output_key_ext()
, that accept additional parameters to control the key creation process.Notes:
Fixes #167