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

make all Error (related to mbedtls) #118

Open
codemavn opened this issue Dec 1, 2021 · 4 comments
Open

make all Error (related to mbedtls) #118

codemavn opened this issue Dec 1, 2021 · 4 comments

Comments

@codemavn
Copy link

codemavn commented Dec 1, 2021

Firstly, on the getting started it notes to install the HEAD version of mbedtls, which, at present, won't install. Given that the getting started note was from early last year, I thought I'd just use the latest version (3.0.0, 2021-07-07) but this gives me a whole host of errors:

PAL/Crypto/MbedTLS/HAPMbedTLS.c:27:15: error: implicit declaration of function 'mbedtls_sha512_starts_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int ret = mbedtls_sha512_starts_ret(ctx, 0); ^ /Library/Developer/CommandLineTools/usr/bin/clang -Wall -Wextra -Werror -DHAP_ENABLE_DEVELOPMENT_ONLY_CODE=1 -mmacosx-version-min=10.14 -DDARWIN=1 -Werror=unused-function -Wno-expansion-to-defined -Wno-nullability-completeness -Wno-deprecated-declarations -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -IHAP -IExternal/HTTP -IExternal/JSON -IExternal/Base64 -IPAL -ICommon -I/usr/local/Cellar/[email protected]/1.1.1l_1/include -I/usr/local/Cellar/mbedtls/3.0.0/include -O0 -g -DHAP_LOG_LEVEL=3 -DHAP_TESTING -IPAL/Darwin -IPAL/Darwin -ICommon -DHAP_Debug -c HAP/HAPAccessorySetupInfo.c -o Output/Darwin-x86_64-apple-darwin21.1.0/Debug/HAP/HAPAccessorySetupInfo.o PAL/Crypto/MbedTLS/HAPMbedTLS.c:27:15: note: did you mean 'mbedtls_sha512_starts'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha512.h:108:5: note: 'mbedtls_sha512_starts' declared here int mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 ); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:32:15: error: implicit declaration of function 'mbedtls_sha512_update_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int ret = mbedtls_sha512_update_ret(ctx, data, size); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:32:15: note: did you mean 'mbedtls_sha512_update'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha512.h:123:5: note: 'mbedtls_sha512_update' declared here int mbedtls_sha512_update( mbedtls_sha512_context *ctx, ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:37:15: error: implicit declaration of function 'mbedtls_sha512_finish_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int ret = mbedtls_sha512_finish_ret(ctx, md); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:37:15: note: did you mean 'mbedtls_sha512_finish'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha512.h:140:5: note: 'mbedtls_sha512_finish' declared here int mbedtls_sha512_finish( mbedtls_sha512_context *ctx, ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:122:53: error: no member named 'grp' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_group_load(&their_key.grp, MBEDTLS_ECP_DP_CURVE25519); ~~~~~~~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:124:60: error: no member named 'grp' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_point_read_binary(&their_key.grp, &their_key.Q, p, X25519_BYTES); ~~~~~~~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:124:76: error: no member named 'Q' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_point_read_binary(&their_key.grp, &their_key.Q, p, X25519_BYTES); ~~~~~~~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:144:36: error: no member named 'grp' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_mul(&key.grp, &key.Q, &key.d, &key.grp.G, blinding_rng, NULL); ~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:144:46: error: no member named 'Q' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_mul(&key.grp, &key.Q, &key.d, &key.grp.G, blinding_rng, NULL); ~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:144:54: error: no member named 'd' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_mul(&key.grp, &key.Q, &key.d, &key.grp.G, blinding_rng, NULL); ~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:144:62: error: no member named 'grp' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_mul(&key.grp, &key.Q, &key.d, &key.grp.G, blinding_rng, NULL); ~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:147:51: error: no member named 'grp' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_point_write_binary(&key.grp, &key.Q, MBEDTLS_ECP_PF_UNCOMPRESSED, &out_len, r, X25519_BYTES); ~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:147:61: error: no member named 'Q' in 'struct mbedtls_ecp_keypair' ret = mbedtls_ecp_point_write_binary(&key.grp, &key.Q, MBEDTLS_ECP_PF_UNCOMPRESSED, &out_len, r, X25519_BYTES); ~~~ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:111:119: note: expanded from macro 'WITH_ECP_KEYPAIR' #define WITH_ECP_KEYPAIR(name, X) WITH(mbedtls_ecp_keypair, name, mbedtls_ecp_keypair_init, mbedtls_ecp_keypair_free, X) ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: expanded from macro 'WITH' X; \ ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:431:15: error: implicit declaration of function 'mbedtls_sha1_starts_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int ret = mbedtls_sha1_starts_ret(&ctx); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:431:15: note: did you mean 'mbedtls_sha1_starts'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha1.h:123:5: note: 'mbedtls_sha1_starts' declared here int mbedtls_sha1_starts( mbedtls_sha1_context *ctx ); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:433:11: error: implicit declaration of function 'mbedtls_sha1_update_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = mbedtls_sha1_update_ret(&ctx, data, size); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:433:11: note: did you mean 'mbedtls_sha1_update'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha1.h:142:5: note: 'mbedtls_sha1_update' declared here int mbedtls_sha1_update( mbedtls_sha1_context *ctx, ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:435:11: error: implicit declaration of function 'mbedtls_sha1_finish_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = mbedtls_sha1_finish_ret(&ctx, md); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:435:11: note: did you mean 'mbedtls_sha1_finish'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha1.h:162:5: note: 'mbedtls_sha1_finish' declared here int mbedtls_sha1_finish( mbedtls_sha1_context *ctx, ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:443:15: error: implicit declaration of function 'mbedtls_sha256_starts_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int ret = mbedtls_sha256_starts_ret(&ctx, 0); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:443:15: note: did you mean 'mbedtls_sha256_starts'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha256.h:101:5: note: 'mbedtls_sha256_starts' declared here int mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:445:11: error: implicit declaration of function 'mbedtls_sha256_update_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = mbedtls_sha256_update_ret(&ctx, data, size); ^ /Library/Developer/CommandLineTools/usr/bin/clang -Wall -Wextra -Werror -DHAP_ENABLE_DEVELOPMENT_ONLY_CODE=1 -mmacosx-version-min=10.14 -DDARWIN=1 -Werror=unused-function -Wno-expansion-to-defined -Wno-nullability-completeness -Wno-deprecated-declarations -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -IHAP -IExternal/HTTP -IExternal/JSON -IExternal/Base64 -IPAL -ICommon -I/usr/local/Cellar/[email protected]/1.1.1l_1/include -I/usr/local/Cellar/mbedtls/3.0.0/include -O0 -g -DHAP_LOG_LEVEL=3 -DHAP_TESTING -IPAL/Darwin -IPAL/Darwin -ICommon -DHAP_Debug -c HAP/HAPAccessoryValidation.c -o Output/Darwin-x86_64-apple-darwin21.1.0/Debug/HAP/HAPAccessoryValidation.o PAL/Crypto/MbedTLS/HAPMbedTLS.c:445:11: note: did you mean 'mbedtls_sha256_update'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha256.h:116:5: note: 'mbedtls_sha256_update' declared here int mbedtls_sha256_update( mbedtls_sha256_context *ctx, ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:447:11: error: implicit declaration of function 'mbedtls_sha256_finish_ret' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ret = mbedtls_sha256_finish_ret(&ctx, md); ^ PAL/Crypto/MbedTLS/HAPMbedTLS.c:447:11: note: did you mean 'mbedtls_sha256_finish'? /usr/local/Cellar/mbedtls/3.0.0/include/mbedtls/sha256.h:133:5: note: 'mbedtls_sha256_finish' declared here int mbedtls_sha256_finish( mbedtls_sha256_context *ctx, ^

So I tried 2.27.0, but that gives me:

fatal error: 'mbedtls/sha1.h' file not found

Apologies, I'm pretty new to this type of dev work. Am I missing something here?

@codemavn
Copy link
Author

codemavn commented Dec 1, 2021

Forgot to mention, this is on macOS Monterey

@thi-days
Copy link

I'm facing the same issue here. Running MacOS Monterey (12.2.1).

@asukharev
Copy link

asukharev commented Jun 19, 2022

To fix it, you can override corresponding lines in Makefile to

CFLAGS_MbedTLS := -I/opt/local/include
LDFLAGS_MbedTLS := -L/opt/local/lib -lmbedcrypto

I'm using macports, but if you using brew, you need to find where it store libs and headers.

@m12t
Copy link

m12t commented Nov 19, 2022

If you used homebrew, changing lines 45 - 46 of Build/Docker/Makefile worked for me:

- OPENSSL_PATH = $(firstword $(wildcard /usr/local/Cellar/[email protected]/*))
- MBEDTLS_PATH = $(firstword $(wildcard /usr/include/mbedtls) $(wildcard /usr/local/Cellar/mbedtls/*))
+ OPENSSL_PATH = $(firstword $(wildcard /opt/homebrew/Cellar/[email protected]/*))
+ MBEDTLS_PATH = $(firstword $(wildcard /opt/homebrew/Cellar/mbedtls/*))

There are still downstream bugs I need to resolve. Namely, installing brew install mbedtls --HEAD caused errors. I'll update this if/when I can run a build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants