HomeKitADK icon indicating copy to clipboard operation
HomeKitADK copied to clipboard

make all Error (related to mbedtls)

Open codemavn opened this issue 4 years ago • 4 comments

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 avatar Dec 01 '21 14:12 codemavn

Forgot to mention, this is on macOS Monterey

codemavn avatar Dec 01 '21 14:12 codemavn

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

thi-days avatar Feb 12 '22 17:02 thi-days

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.

asukharev avatar Jun 19 '22 17:06 asukharev

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.

m12t avatar Nov 19 '22 03:11 m12t