-
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
Design discussion: add new symbol for PSA key enrollment functions #8449
Design discussion: add new symbol for PSA key enrollment functions #8449
Conversation
d168b18
to
dd9102e
Compare
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 current implementation breaks backward compatibility.
Also, the reason we would want this is unclear. This feature doesn't cost a lot of code size.
include/mbedtls/mbedtls_config.h
Outdated
* | ||
* \warning This is an Mbed TLS extension to the standard PSA interface. | ||
*/ | ||
// #define MBEDTLS_PSA_ENABLE_KEY_ENROLLMENT |
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.
For backward compatibility, the feature has to be available by default. So we need to make this a negative option, off by default.
include/mbedtls/mbedtls_config.h
Outdated
@@ -1364,6 +1364,15 @@ | |||
*/ | |||
//#define MBEDTLS_PSA_CRYPTO_CLIENT | |||
|
|||
/** | |||
* \def MBEDTLS_PSA_ENABLE_KEY_ENROLLMENT |
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.
How much code size will this save (once it's finished)?
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.
For this question I replied in the comment below
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.
This is not about code size. This is about compliance with the PSA crypto APIs implemented as services e.g. by TF-M. alg2 and the key enrollment concept doesn't exist in TF-M.
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 existence of this feature doesn't break compliance with the PSA crypto API, and services built on top of Mbed TLS don't need to support setting the enrollment algorithm.
Can you please describe the problem you're facing? If it's not code size then I suspect you're trying to fix it in the wrong place.
library/pk.c
Outdated
@@ -347,7 +352,11 @@ int mbedtls_pk_can_do_ext(const mbedtls_pk_context *ctx, psa_algorithm_t alg, | |||
* This would also match ECDSA/RSA_PKCS1V15_SIGN/RSA_PSS with | |||
* a fixed hash on key_alg/key_alg2. | |||
*/ | |||
#if defined(MBEDTLS_PSA_ENABLE_KEY_ENROLLMENT) |
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.
@@ -48,6 +48,7 @@ extern "C" { | |||
* @{ | |||
*/ | |||
|
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.
Missing: removing the alg2
field from the context, and the code in psa_crypto.c
that deals with it.
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.
True, that's something I noticed as well. I didn't modify that part because, as I explained in my comment below, I was mostly focused on having a TLS/DTLS implementation which could work with standard PSA interface.
However I agree that this is something I can improve as well. I will try to fix this ASAP
I see, that's what I mentioned also in the description indeed. I implemented it as positive symbol because that's what I've been asked, but we can find a different solution for that. Making it negative it's surely an option, but what about keeping it positive and having it automatically enabled by
Here I will provide my answer, but I'm pretty sure Nordic and/or TFM group can bring more arguments to the discussion. |
That's true, but it is not something that Mbed TLS currently supports. It's on our mental roadmap, currently thinking we might deliver this some time in the 4.x series or maybe in 5.0, but it's not scheduled yet and we're currently prioritizing other features over this. |
004bb51
to
3fd4f0d
Compare
Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
3fd4f0d
to
ab08775
Compare
I see that you're continuing to work on this pull request, but it's still not clear to me why we should accept it. By default, we don't want new compilation options: they have to have a clear benefit. Saving a significant amount of code size would be an acceptable benefit, but apparently that's not it, then what? |
As I explained here, Nordic is concerned about the possibility to use TLS and related "middle/high level modules" together with some other PSA implementation, i.e. building TLS with I know you said this is not in the roadmap for near future, but on one hand Nordic is interested in this feature and, on the other one, since AFAIU it is still something you would like to do sooner or later, we're just anticipating this work a bit. |
Ok. That's a desirable feature, and we can support improvements in that direction, even if we have no engineering time beyond reviewing your work.
It seems to me that you're looking in the wrong place to solve your problem. |
That's correct, but if the end user does not add MbedTLS version of |
That's fine: the X.509 and TLS code don't call those functions. Are you trying to use an Mbed TLS build with If you have your own PSA Crypto implementation, it's up to you to implement the API. The client-side functions of Mbed TLS aren't going to help you much anyway, since in a client-server implementation the client-side code is pretty much IPC calls which you have to implement based on your IPC mechanism.
Yes, and that's true for all the fields: |
…not available Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
ab08775
to
71e2710
Compare
Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
Return error instead of silently ignoring that parameter. Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
Signed-off-by: Valerio Setti <[email protected]>
71e2710
to
ad74536
Compare
I'm afraid I agree with Gilles and am unconvinced this is something we want at the moment. Each additional compilation option is a cost, and I'm not seeing a benefit that would justify that cost now or in the near future.
I think the above sentence shows a confusion between two distinct things.
I think this PR could be useful only as a step toward the 2nd goal. However, seeing as it's in the distant future, I don't think this is enough to justify the cost of an additional config option right now. One more thing. If Nordic (or anyone else) would like us to put that 2nd goal on our roadmap, please let us know, but:
(On a personal note, I guess (2) might be a bit similar to driver-only, in that both are obvious on paper ("I have a driver for X, why would I need the built-in implementation?", resp. "PSA Crypto is a standard interface, TLS should be able to work with any compliant implementation") but turn out to be a lot of work in practice. For driver-only, we've been at it for more than one year now and we've not done yet. Hopefully some things will become easier after 4.0, though.) |
OK, thanks for the very detailed explanation and distinction between points (1) and (2). In particular the sentence
helped a lot in the clarification. Now that you provided these details I would say that Nordic's goal is to get point (2). But again, this is just my hypothesis, so I will let @frkv correct me if I'm wrong.
This PR is unlikely the right place to discuss long term goals. I think that the bi-weekly meeting is a better option for this since it involves also management. |
@mpg Could you tell me your opinion on where TF-M sits in this comparison as a PSA crypto provider? |
Yes, that's my view as well.
Indeed. But unless I'm mistaken, neither the TLS not the X.509 library are directly using the non-standard APIs that this PR is about. Those APIs are only used in PK, which is then used by TLS and X.509. However this is likely to change in 4.0 - either the internal structure of PK (and perhaps part of its interface), or its use by TLS & X.509, or both. (Edit: I've made a note to make sure we take this in consideration as part of our work on PK for 4.0.) So, it doesn't change my assessment that this PR, despite its best intentions, is not really a useful step towards that goal. |
They shouldn't be! The pk module does not need to support two algorithms in the same PSA key. It's news to me that We can and should remove some of those uses, but I'm not sure if we can remove all of them.
|
I agree that at some point we should stop using those non-standard APIs in PK, but it's not really clear to me if that's something we want to (or even can!) do now with a compile time option, as opposed to 4.0 as part of bigger changes (either removing PK or reworking it).
That's a problem for TLS and I suspect for any protocol that does similar negotiation: TLS needs to know in advance what operations it will be able to do with the provisioned private key(s), in order to offer the corresponding algorithms. I think PSA Crypto should really offer a standard, non-CPU-intensive way of doing that. (The alternative would be to require TLS users to provide the information to the TLS stack, but then users would complain that it's silly because the information is right there in the key, and I'd agree with them.) (That's probably a separate discussion though.)
Agree. I'll note that in a way it will move the call out of the library and into the user's hands: people (like us in our SSL test programs like But in this case, moving the call out of the library and into the user's hands is exactly what we want: users get to decide whether to use the non-standard function or not.
Agreed. And this kind of hack doesn't work for RSA where we could possibly want v15-crypt, v15-sign and pss-sign if we wanted the key to be usable for all the key exchanges we support in TLS 1.2+1.3. Right know I don't remember how we handled that in our SSL test programs
Precisely. When you parse an EC key, you get an We could probably get away with allowing only (deterministic) ECDSA, since PK can't do ECDH anyway, so in order to to ECDH we need to somehow get the key out of the PK context (this happens in TLS 1.2). At the point we do that, we could export the key and re-import it with an ECDH policy, instead of just extracting the key ID from the PK context - after all, in the That would move the complexity/hack out or PKparse and into TLS 1.2, but more importantly it would avoid use of a non-standard function in either place.
Ah, good point. |
I'm thinking here we could just guard the call to that function with I've created #8602 based on that - please shout if you disagree!
I think that will be done as part of #7760.
Now tracked in #8601
Now tracked in #8600 |
I believe we have an agreement that we don't want to introduce a new symbol at this point, but the PR and discussion have highlighted other changes we would like to make. I believe all those changes are now tracked in separate issues, so I'm closing this PR. |
Description
This PR adds a new build symbol named
MBEDTLS_PSA_ENABLE_KEY_ENROLLMENT
to enable PSA key enrollment functions:Reasons for this change
This change was raised in last biweekly meeting by Nordic and it is strongly requested for TF-M support.
PR checklist