-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Study: PK including parse/write in ECP-free builds #6009
Comments
Currently the lifecycle of the key material in PK with
While it makes some sense in that it allowed implementation of I can see two alternative approaches:
The big advantage of the first approach is simplicity. However, it might not work if the key attributes can only be determined when doing the operation (TODO: check the code). Also, for public keys it might result in allocating a lot of PSA key slots in some circumstances, such as parsing a large number of X.509 certificates (like the list of trusted roots). The second approach is a bit more complex but would avoid these issues. It may also be possible to use the first approach for private keys and the second one for public keys. This is probably not a complete solution to building PK(parse,write) without ECP, but probably an important part of the solution, which I think sounds also nice to have anyway. @gilles-peskine-arm If you have any thoughts on the topic they're welcome. |
Done in #6389, which needs rebasing and some tweaks around RSA (as it stands now, you can make a configuration without PK_WRITE where the build passes but then PSA exports of RSA keys fail at runtime).
Indeed, when importing, you can't know what algorithms the key will be used for. For example a TLS 1.2 server might use the same RSA key to decrypt and sign. For ECC keys we might be able to get away with one flavor of ECDSA plus ECDH, but it's clearly a hack which is only possible by abusing the enrollment algorithm feature.
That is also a concern. Especially if PSA is in a secure world keystore and pk is in a normal world with more RAM.
There's also the lack of support for parsing compressed points in PSA. This is a known issue, with no ETA for a solution (it doesn't fit well in the driver interface design, and I'd rather finish implementing the basic design before adding warts). |
Oh, that's great news! I'm adding that PR to this EPIC then.
Agreed.
Indeed, so combined with the previous point I think we have rather strong arguments for storing the serialized form of the key and temporarily importing at use time, rather than permanently storing in a key slot.
I wouldn't consider that a blocker in the short term. Currently you can only build PK with ECP present and then you get parsing of keys with compressed points. In the near future we can add the option of building without ECP but then you don't get parsing of keys with compressed points (but you still have it in builds that were previously possible, that is with ECP). We just need to be careful and have enough testing (I don't think we're testing compressed points at the pkparse level right now) to make sure we don't break anything that currently works. In the long term though, that will need to be resolved before we can move to a fully PSA-only world. |
Looking at #6389 it's not doing what I had in mind. What I had in mind was to store the serialized key material as an array of bytes in the context, so that when using the key we can directly I think #6389 is a step in the right direction, but not going all the way. |
Currently the PK module does most crypto operations using PSA Crypto in builds with
MBEDTLS_USE_PSA_CRYPTO
. However, for parsing and writing keys it still relies on ECP functions - for (de)serialization, but also for checking the validity of the data, and also completing key pairs by computing the public part when only the private part was included. Also, it always stores key data in ECP structures, where it can only be accessed using ECP functions.We want to be able to build, use and test the library without ECP when PSA drivers for ECDH and ECDSA are available. (Note: most of our tests depend on PK parse to load the key material that is required for testing.)
This task is to study how this can be achieve, come up with a plan, and create a series of estimated task achieving that result.
The text was updated successfully, but these errors were encountered: