@@ -1300,20 +1300,96 @@ fi
1300
1300
1301
1301
AC_LANG_POP ( [ C++] )
1302
1302
1303
+ #
1304
+ # Check for crypto implementation
1305
+ #
1306
+ CHIP_CRYPTO=
1307
+ CHIP_CRYPTO_MBEDTLS=0
1308
+ CHIP_CRYPTO_OPENSSL=0
1309
+
1310
+ AC_MSG_CHECKING ( [ for crypto implementation] )
1311
+
1312
+ # The user may have attempted to explicitly specify the crypto
1313
+ # implementation. Sanity check it or default to 'auto'.
1314
+
1315
+ AC_ARG_WITH ( crypto ,
1316
+ [ AS_HELP_STRING ( [ --with-crypto=CRYPTO] ,
1317
+ [ Specify the crypto implementation from one of: auto, mbedtls, or openssl @<:@ default=auto@:>@ .] ) ] ,
1318
+ [
1319
+ case "${with_crypto}" in
1320
+ auto|mbedtls|openssl)
1321
+ ;;
1322
+ *)
1323
+ AC_MSG_ERROR ( [ Invalid value ${with_crypto} for --with-crypto] )
1324
+ ;;
1325
+ esac
1326
+ ] ,
1327
+ [ with_crypto=auto] )
1328
+
1329
+ # At this point, the crypto implementation is one of the allowed
1330
+ # values. If it's 'auto' we autodetect it.
1331
+
1332
+ if test "${with_crypto}" = "auto"; then
1333
+ case ${target_os} in
1334
+
1335
+ *cygwin*|*darwin*|*linux*|*freebsd*|*netbsd*|*openbsd*)
1336
+ with_crypto=openssl
1337
+ ;;
1338
+
1339
+ *freertos*)
1340
+ with_crypto=mbedtls
1341
+ ;;
1342
+
1343
+ *)
1344
+ AC_MSG_RESULT ( [ unknown] )
1345
+ AC_MSG_ERROR ( [ Unsupported target OS ${target_os}] )
1346
+ ;;
1347
+
1348
+ esac
1349
+ fi
1350
+
1351
+ CHIP_CRYPTO=${with_crypto}
1352
+
1353
+ case ${with_crypto} in
1354
+
1355
+ mbedtls)
1356
+ CHIP_CRYPTO_MBEDTLS=1
1357
+ ;;
1358
+
1359
+ openssl)
1360
+ CHIP_CRYPTO_OPENSSL=1
1361
+ ;;
1362
+
1363
+ esac
1364
+
1365
+ AC_MSG_RESULT ( ${CHIP_CRYPTO} )
1366
+
1367
+ AC_SUBST ( CHIP_CRYPTO )
1368
+ AC_DEFINE_UNQUOTED ( [ CHIP_CRYPTO] ,[ ${CHIP_CRYPTO}] ,[ CHIP crypto implementation] )
1369
+
1370
+ AC_SUBST ( CHIP_CRYPTO_MBEDTLS )
1371
+ AM_CONDITIONAL([ CHIP_CRYPTO_MBEDTLS] , [ test "${CHIP_CRYPTO}" = "mbedtls"] )
1372
+ AC_DEFINE_UNQUOTED ( [ CHIP_CRYPTO_MBEDTLS] ,[ ${CHIP_CRYPTO_MBEDTLS}] ,[ Define to 1 if you want to use CHIP with a mbedTLS crypto implementation] )
1373
+
1374
+ AC_SUBST ( CHIP_CRYPTO_OPENSSL )
1375
+ AM_CONDITIONAL([ CHIP_CRYPTO_OPENSSL] , [ test "${CHIP_CRYPTO}" = "openssl"] )
1376
+ AC_DEFINE_UNQUOTED ( [ CHIP_CRYPTO_OPENSSL] ,[ ${CHIP_CRYPTO_OPENSSL}] ,[ Define to 1 if you want to use CHIP with an OpenSSL crypto implementation] )
1377
+
1303
1378
#
1304
1379
# Checks for libraries and packages.
1305
1380
#
1306
1381
# At minimum, the following are required:
1307
1382
#
1308
1383
# * nlassert
1309
1384
# * nlio
1310
- # * openssl
1311
1385
#
1312
1386
# The following are optional, depending on configuration:
1313
1387
#
1314
1388
# * lwip
1389
+ # * mbedtls
1315
1390
# * nlunit-test
1316
1391
# * nlfaultinjection
1392
+ # * openssl
1317
1393
#
1318
1394
# Most of these are supplied "in package"; however, they may be also
1319
1395
# supplied out of package.
@@ -1324,71 +1400,66 @@ AC_MSG_NOTICE([checking package dependencies])
1324
1400
1325
1401
AC_PATH_PROG ( [ PKG_CONFIG] ,[ pkg-config] )
1326
1402
1327
- #
1328
1403
#
1329
1404
# OpenSSL
1330
1405
#
1331
1406
1332
- NL_WITH_REQUIRED_EXTERNAL_PACKAGE( [ OpenSSL ] ,
1333
- [ OPENSSL ] ,
1334
- [ openssl ] ,
1335
- [ -lcrypto ] ,
1336
- [
1337
- # Check for required OpenSSL headers.
1338
-
1339
- AC_CHECK_HEADERS ( [ openssl/aes.h] [ openssl/bn.h] [ openssl/crypto.h] [ openssl/ec.h] [ openssl/err.h] [ openssl/evp.h] [ openssl/hmac.h] [ openssl/kdf.h] [ openssl/rand.h] [ openssl/sha.h] [ openssl/srp.h] ,
1340
-
1341
- [ ] ,
1342
- [
1343
- AC_MSG_ERROR ( The OpenSSL header "$ac_header" is required but cannot be found. )
1344
- ]
1345
- )
1346
- ]
1347
- )
1407
+ if test "${with_crypto}" = "openssl"; then
1408
+ NL_WITH_REQUIRED_EXTERNAL_PACKAGE( [ OpenSSL ] ,
1409
+ [ OPENSSL ] ,
1410
+ [ openssl ] ,
1411
+ [ -lcrypto ] ,
1412
+ [
1413
+ # Check for required OpenSSL headers.
1414
+ AC_CHECK_HEADERS ( [ openssl/aes.h] [ openssl/bn.h] [ openssl/crypto.h] [ openssl/ec.h] [ openssl/err.h] [ openssl/evp.h] [ openssl/hmac.h] [ openssl/kdf.h] [ openssl/rand.h] [ openssl/sha.h] [ openssl/srp.h] ,
1415
+ [ ] ,
1416
+ [
1417
+ AC_MSG_ERROR ( The OpenSSL header "$ac_header" is required but cannot be found. )
1418
+ ]
1419
+ )
1420
+ ]
1421
+ )
1422
+ fi
1348
1423
1349
1424
AM_CONDITIONAL([ CHIP_WITH_OPENSSL] , [ test "${nl_with_openssl}" != "no"] )
1350
1425
1351
1426
if test "${nl_with_openssl}" = "no"; then
1352
- AC_DEFINE ( [ CHIP_WITH_OPENSSL] , [ 0] , [ Define to 1 to build CHIP with OpenSSL features ] )
1427
+ AC_DEFINE ( [ CHIP_WITH_OPENSSL] , [ 0] , [ Define to 1 to build CHIP with OpenSSL] )
1353
1428
else
1354
- AC_DEFINE ( [ CHIP_WITH_OPENSSL] , [ 1] , [ Define to 1 to build CHIP with OpenSSL features ] )
1429
+ AC_DEFINE ( [ CHIP_WITH_OPENSSL] , [ 1] , [ Define to 1 to build CHIP with OpenSSL] )
1355
1430
fi
1356
1431
1357
- #
1358
1432
#
1359
1433
# mbedTLS
1360
1434
#
1361
- if test "${with_mbedtls}" != "internal"; then
1362
- with_mbedtls="no"
1363
- fi
1364
1435
1365
- NL_WITH_OPTIONAL_INTERNAL_PACKAGE(
1366
- [ mbedTLS] ,
1367
- [ MBEDTLS] ,
1368
- [ mbedtls] ,
1369
- [ ] ,
1370
- [
1371
- # At this point, the internal mbedTLS package will be neither
1372
- # configured nor built, so the normal checks we undertake for an
1373
- # external package cannot be run here. Simply set the appropriate
1374
- # variables and trust all will be well.
1375
-
1376
- MBEDTLS_CPPFLAGS="-I\${abs_top_srcdir}/third_party/mbedtls/repo/include"
1377
- MBEDTLS_LDFLAGS="-L${ac_pwd}/third_party/mbedtls"
1378
- MBEDTLS_LIBS="-lmbedtls"
1379
- ] ,
1380
- [
1381
- # Check for required mbedTLS headers.
1382
-
1383
- AC_CHECK_HEADERS ( [ mbedtls/sha1.h] [ mbedtls/sha256.h] [ mbedtls/sha512.h] [ mbedtls/md.h] [ mbedtls/hkdf.h] [ mbedtls/pkcs5.h] [ mbedtls/chachapoly.h] [ mbedtls/aes.h] [ mbedtls/ecdh.h] [ mbedtls/bignum.h] ,
1436
+ if test "${with_crypto}" = "mbedtls"; then
1437
+ NL_WITH_REQUIRED_INTERNAL_PACKAGE(
1438
+ [ mbedTLS] ,
1439
+ [ MBEDTLS] ,
1440
+ [ mbedtls] ,
1441
+ [ ] ,
1442
+ [
1443
+ # At this point, the internal mbedTLS package will be neither
1444
+ # configured nor built, so the normal checks we undertake for an
1445
+ # external package cannot be run here. Simply set the appropriate
1446
+ # variables and trust all will be well.
1384
1447
1385
- [ ] ,
1386
- [
1387
- AC_MSG_ERROR ( The mbedTLS header "$ac_header" is required but cannot be found. )
1388
- ]
1389
- )
1390
- ]
1391
- )
1448
+ MBEDTLS_CPPFLAGS="-I\${abs_top_srcdir}/third_party/mbedtls/repo/include"
1449
+ MBEDTLS_LDFLAGS="-L${ac_pwd}/third_party/mbedtls"
1450
+ MBEDTLS_LIBS="-lmbedtls"
1451
+ ] ,
1452
+ [
1453
+ # Check for required mbedTLS headers.
1454
+ AC_CHECK_HEADERS ( [ mbedtls/sha1.h] [ mbedtls/sha256.h] [ mbedtls/sha512.h] [ mbedtls/md.h] [ mbedtls/hkdf.h] [ mbedtls/pkcs5.h] [ mbedtls/chachapoly.h] [ mbedtls/aes.h] [ mbedtls/ecdh.h] [ mbedtls/bignum.h] ,
1455
+ [ ] ,
1456
+ [
1457
+ AC_MSG_ERROR ( The mbedTLS header "$ac_header" is required but cannot be found. )
1458
+ ]
1459
+ )
1460
+ ]
1461
+ )
1462
+ fi
1392
1463
1393
1464
# Depending on whether mbedTLS has been configured for an internal
1394
1465
# location, its directory stem within this package needs to be set
@@ -1413,6 +1484,14 @@ fi
1413
1484
AC_SUBST ( MBEDTLS_SUBDIRS , [ ${maybe_mbedtls_dirstem}] )
1414
1485
AM_CONDITIONAL([ CHIP_WITH_MBEDTLS_INTERNAL] , [ test "${nl_with_mbedtls}" = "internal"] )
1415
1486
1487
+ AM_CONDITIONAL([ CHIP_WITH_MBEDTLS] , [ test "${nl_with_mbedtls}" != "no"] )
1488
+
1489
+ if test "${nl_with_mbedtls}" = "no"; then
1490
+ AC_DEFINE ( [ CHIP_WITH_MBEDTLS] , [ 0] , [ Define to 1 to build CHIP with mbedTLS] )
1491
+ else
1492
+ AC_DEFINE ( [ CHIP_WITH_MBEDTLS] , [ 1] , [ Define to 1 to build CHIP with mbedTLS] )
1493
+ fi
1494
+
1416
1495
#
1417
1496
# LwIP
1418
1497
#
@@ -1843,18 +1922,19 @@ if test "${nl_cv_build_tests}" = "yes"; then
1843
1922
fi
1844
1923
fi
1845
1924
1925
+ # Add any crypto-implementation CPPFLAGS, LDFLAGS, and LIBS
1846
1926
1847
- # Add any OpenSSL CPPFLAGS, LDFLAGS, and LIBS
1848
-
1849
- CPPFLAGS="${CPPFLAGS} ${OPENSSL_CPPFLAGS}"
1850
- LDFLAGS="${LDFLAGS} ${OPENSSL_LDFLAGS}"
1851
- LIBS="${LIBS} ${OPENSSL_LIBS}"
1927
+ CRYPTO_CPPFLAGS="${CRYPTO_CPPFLAGS} ${MBEDTLS_CPPFLAGS} ${OPENSSL_CPPFLAGS}"
1928
+ CRYPTO_LDFLAGS="${CRYPTO_LDFLAGS} ${MBEDTLS_LDFLAGS} ${OPENSSL_LDFLAGS}"
1929
+ CRYPTO_LIBS="${CRYPTO_LIBS} ${MBEDTLS_LIBS} ${OPENSSL_LIBS}"
1852
1930
1853
- # Add any mbedTLS CPPFLAGS, LDFLAGS, and LIBS
1931
+ AC_SUBST ( CRYPTO_CPPFLAGS )
1932
+ AC_SUBST ( CRYPTO_LDFLAGS )
1933
+ AC_SUBST ( CRYPTO_LIBS )
1854
1934
1855
- CPPFLAGS="${CPPFLAGS} ${MBEDTLS_CPPFLAGS }"
1856
- LDFLAGS="${LDFLAGS} ${MBEDTLS_LDFLAGS }"
1857
- LIBS="${LIBS} ${MBEDTLS_LIBS }"
1935
+ CPPFLAGS="${CPPFLAGS} ${CRYPTO_CPPFLAGS }"
1936
+ LDFLAGS="${LDFLAGS} ${CRYPTO_LDFLAGS }"
1937
+ LIBS="${LIBS} ${CRYPTO_LIBS }"
1858
1938
1859
1939
# Add any code coverage CPPFLAGS, LDFLAGS, and LIBS
1860
1940
@@ -1964,6 +2044,7 @@ AC_MSG_NOTICE([
1964
2044
Target architecture : ${target_cpu}
1965
2045
Target OS : ${target_os}
1966
2046
Target style : ${CHIP_TARGET_STYLE}
2047
+ Cryptographic implementation : ${CHIP_CRYPTO}
1967
2048
Target network layer : ${with_network_layer}
1968
2049
Target network system(s) : ${CONFIG_TARGET_NETWORKS}
1969
2050
IPv4 enabled : ${enable_ipv4}
@@ -2012,14 +2093,17 @@ AC_MSG_NOTICE([
2012
2093
LwIP compile flags : ${LWIP_CPPFLAGS:--}
2013
2094
LwIP link flags : ${LWIP_LDFLAGS:--}
2014
2095
LwIP link libraries : ${LWIP_LIBS:--}
2015
- OpenSSL source : ${nl_with_openssl}
2016
- OpenSSL compile flags : ${OPENSSL_CPPFLAGS:--}
2017
- OpenSSL link flags : ${OPENSSL_LDFLAGS:--}
2018
- OpenSSL link libraries : ${OPENSSL_LIBS:--}
2019
2096
mbedTLS source : ${nl_with_mbedtls}
2020
2097
mbedTLS compile flags : ${MBEDTLS_CPPFLAGS:--}
2021
2098
mbedTLS link flags : ${MBEDTLS_LDFLAGS:--}
2022
2099
mbedTLS link libraries : ${MBEDTLS_LIBS:--}
2100
+ OpenSSL source : ${nl_with_openssl}
2101
+ OpenSSL compile flags : ${OPENSSL_CPPFLAGS:--}
2102
+ OpenSSL link flags : ${OPENSSL_LDFLAGS:--}
2103
+ OpenSSL link libraries : ${OPENSSL_LIBS:--}
2104
+ Crypto implementation compile flags : ${CRYPTO_CPPFLAGS:--}
2105
+ Crypto implementation link flags : ${CRYPTO_LDFLAGS:--}
2106
+ Crypto implementation link libraries : ${CRYPTO_LIBS:--}
2023
2107
Nlunit-test source : ${nl_with_nlunit_test:--}
2024
2108
Nlunit-test compile flags : ${NLUNIT_TEST_CPPFLAGS:--}
2025
2109
Nlunit-test link flags : ${NLUNIT_TEST_LDFLAGS:--}
0 commit comments