-
Notifications
You must be signed in to change notification settings - Fork 68
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
Further simplification of the Mbed Crypto provider #187
Comments
You are right that there will be holes but I think the window of values is so big that it should not be a problem when Parsec is used. Maybe only in stress test?
I think it is better placed in
Nice! I think that running out of slots is a valid error to return anyway and not something we should handle in Parsec. |
If we run a stress test that generates 100 keys per second, we'd have to run it for almost 1 year and a half to run out of handles (if we assume that the whole 32 bit space is available). |
The Mbed Crypto provider should also use parallaxsecond/rust-psa-crypto#30 instead of redefining. |
PSA key ID range is 1 to 1,073,741,823, but even so, maybe I'm over thinking it a bit. If you have that many keys and generated one per second, it would take you 34 years to run out of space 😋.
Can we do optional types based on features? 'If |
I think the Mutex for the |
As stated here, we have a thread safety issue that needs fixing. This is because
Ignoring |
I forgot about that! We discussed about that and possibly having a |
That's very weird, it literally contradicts the documentation:
The documentation for a (now deprecated) |
Yeah, I tried it and it wouldn't compile.
I presume they haven't done this yet! |
For 1., if you're not concerned about creating holes when destroying keys, do we ever need to decrement the counter by more than 1? As an example: we generate 100 keys, then destroy keys 90 to 100 in ascending order (so key 100 is the last to be destroyed), do we reset the counter to 89 as this is now the highest key ID in use, or do we leave it at 100 (or even 99, as it would be easy to check if the current key being destroyed is the highest, if it is we know the next highest key ID has to be no higher than current_highest_ID - 1)? If we get rid of |
I think even checking if the key to delete has the highest key ID in use and preventing data races when doing that and deleting the key (preventing other keys to be created with that ID) is quite complicated and would need another mutex. |
Ok. What about if create_key_id fails to store the key? Currently, the new ID is only saved if the key with the new ID is saved to the store successfully. With the |
Yes, that is a good point. I think it should be fine never to decrement the counter and return safely an error if it is too big. If in the future we run into problems because of this, we can change our system. |
If the number is too big then you can overwrite the atomic with the maximum allowed value. At that point it doesn't matter whether it's MAX or MAX+1 because creations will fail anyway before reaching Mbed Crypto. It's more important to decide how to get past this problem in a system that actually uses this provider (assuming someone might want to use it in production). |
In the conversation of #186 :
I am thinking of a few things as next steps to simplify the provider further, I said:
to which @sbailey-arm replied:
We could do. How would we deal with holes when keys are destroyed? E.g. Allocate keys 1 to 100, then destroy 34, 67, 78 and 91.
This is the issue for that and its still open so I think we'll hit issues. I can try testing it without though, and if it causes a problem, look into moving it to psa-crypto.
stress_test and normal_tests pass after removing the semaphore guard request in each operation method so it looks like we can remove it.
Let's continue the discussion here and see how to address those points.
cc @ionut-arm
The text was updated successfully, but these errors were encountered: