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

missing limits.h in bignum.c #4929

Closed
krisk0 opened this issue Sep 9, 2021 · 4 comments · Fixed by #5269
Closed

missing limits.h in bignum.c #4929

krisk0 opened this issue Sep 9, 2021 · 4 comments · Fixed by #5269
Assignees
Labels
bug component-crypto Crypto primitives and low-level interfaces

Comments

@krisk0
Copy link

krisk0 commented Sep 9, 2021

Summary

File library/bignum.c is using CHAR_BIT macro but does not include limits.h.

The file does not compile when other included headers do not include limits.h, for instance on Linux/glibc/gcc 10.3.0.

System information

Mbed TLS version (number or commit id): 3c28fd3
Operating system and version: Gentoo Linux x86_64, glibc
Configuration (if not default, please attach mbedtls_config.h):
Compiler and options (if you used a pre-built binary, please indicate how you obtained it): -O2 -march=native
Additional environment information:

Expected behavior

everything compiles

Actual behavior

library/bignum.c does not compile

Steps to reproduce

Attempt to build with gcc 10.3.0 on Glibc'ish Linux with MBEDTLS_BIGNUM_C is enabled

Additional information

I suggest that you add #include <limits.h> to bignum.c.

@gilles-peskine-arm
Copy link
Contributor

How are you building the library exactly? In Mbed TLS 3.0 there's an inclusion chain bignum.ccommon.hmbedtls/build_info.hmbedtls/check_config.hlimits.h. This is quite convoluted and it would be a good idea for bignum.c to include limits.h directly, but I can't see how you could end up building bignum.c without including limits.h.

This is a genuine bug in 2.16 and 2.2x where the inclusion of check_config.h is recommended, but since it goes through the user's config.h, it isn't guaranteed.

@krisk0
Copy link
Author

krisk0 commented Sep 9, 2021

Yes, my config.h did not include check_config.h. Does it need to? If yes then this is my fault.

@gilles-peskine-arm
Copy link
Contributor

With Mbed TLS 3.0.0+, there shouldn't be a way to bypass check_config.h. If you managed to do it, that's a bug of its own, please let us know how.

With Mbed TLS 2.x, it is possible to bypass check_config.h. The fact that the library doesn't build when config.h just contains #include MBEDTLS_BIGNUM_C and nothing else is a bug.

@gilles-peskine-arm gilles-peskine-arm added bug component-crypto Crypto primitives and low-level interfaces Product Backlog labels Sep 9, 2021
@krisk0
Copy link
Author

krisk0 commented Sep 9, 2021

I experimented with an old version (2.20, commit 1146b4e), but mentioned fresh commit 3c28fd3 in my bug report. Sorry for that.
If check_config.h is included by config.h, then bignum compiles.
I don't mind if you close the bug.

tom-cosgrove-arm added a commit to tom-cosgrove-arm/mbedtls that referenced this issue Nov 15, 2021
tom-cosgrove-arm added a commit to tom-cosgrove-arm/mbedtls that referenced this issue Nov 15, 2021
Fixes Mbed-TLS#4929

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
@tom-cosgrove-arm tom-cosgrove-arm self-assigned this Nov 15, 2021
daverodgman added a commit to daverodgman/mbedtls that referenced this issue Dec 6, 2021
Fixes Mbed-TLS#4929

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
gilles-peskine-arm pushed a commit to gilles-peskine-arm/mbedtls that referenced this issue Dec 6, 2021
Fixes Mbed-TLS#4929

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-crypto Crypto primitives and low-level interfaces
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants