Skip to content
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 missing const in function signatures #7600

Open
mpg opened this issue May 16, 2023 · 5 comments
Open

Add missing const in function signatures #7600

mpg opened this issue May 16, 2023 · 5 comments
Labels
api-break This issue/PR breaks the API and must wait for a new major version enhancement size-s Estimated task size: small (~2d)

Comments

@mpg
Copy link
Contributor

mpg commented May 16, 2023

Add missing const in function signatures. This issue is only about simple cases where the const was just forgotten and no code change is needed in order to add it.

See comments below for an incremental list.

@mpg mpg added enhancement api-break This issue/PR breaks the API and must wait for a new major version labels May 16, 2023
@mpg
Copy link
Contributor Author

mpg commented May 16, 2023

If still public: mbedtls_ecp_write_key()'s first parameter - it should always have been const, probably an oversight.

@gilles-peskine-arm
Copy link
Contributor

gilles-peskine-arm commented May 16, 2023

From what I remember from the discussions leading to 3.0, a lot of functions operating on ECP objects have to use a non-const pointer due to the lazy loading of group data, which means that mbedtls_ecp_group members have to be non-const in many low-level functions, which then infects the whole interface with non-constness.

Previous discussion: #1485

@mpg
Copy link
Contributor Author

mpg commented May 16, 2023

Yes, but that's only for functions that may end up callling mbedtls_ecp_mul(). That's not the case here. (From reading the code, and also trying to add a const and see if the compiler complains - it does not.)

@mpg
Copy link
Contributor Author

mpg commented May 16, 2023

Btw, I just checked, and mbedtls_ecp_mul() is still not quite ready yet to have its first argument const, though that would only be a moderate amount of work now that the pre-computed multiples table are stored as static data, instead of computed at runtime. The trouble is, the code still supports computing it at runtime, which is only useful when adding a new curve, as we compute the table at runtime then dump it before we add it to ecp_curves.c, and then it never needs to be computed at runtime again - see scripts/ecp_comb_table.py.

We should really get rid of that and instead compute the table for new curves in python or using a dedicated C program, but it's ridiculous to keep code in all builds of the library that's only useful when developing the library, not when using it. Especially when it shows in the API, as some parameters that should morally be const are not.

So, I'm not adding ecp_mul() & Co here. This issue is only for const qualifiers that can just be added because they were just forgotten.

@mpg mpg added the size-s Estimated task size: small (~2d) label May 16, 2023
@mpg
Copy link
Contributor Author

mpg commented May 16, 2023

Created #7601 to track preliminary work that's needed before making ecp_mul() const.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break This issue/PR breaks the API and must wait for a new major version enhancement size-s Estimated task size: small (~2d)
Projects
Status: Mbed TLS 4.0 COULD
Status: Implementation needed
Development

No branches or pull requests

2 participants