Skip to content

Commit

Permalink
meson.build: implement mbedtls support
Browse files Browse the repository at this point in the history
  • Loading branch information
iameli committed Dec 5, 2023
1 parent 1f0a5de commit add8305
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crypto/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test_apps = [
'env',
]

if not use_openssl and not use_nss
if not use_openssl and not use_nss and not use_mbedtls
test_apps += ['sha1_driver']
endif

Expand All @@ -20,7 +20,7 @@ foreach test_name : test_apps
test(test_name, test_exe, args: ['-v'])
endforeach

if not use_openssl and not use_nss
if not use_openssl and not use_nss and not use_mbedtls
test_exe = executable('aes_calc',
'aes_calc.c', '../../test/getopt_s.c', '../../test/util.c',
include_directories: [config_incs, crypto_incs, srtp2_incs, test_incs],
Expand Down
21 changes: 21 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ endif

use_openssl = false
use_nss = false
use_mbedtls = false

crypto_library = get_option('crypto-library')
if crypto_library == 'openssl'
Expand Down Expand Up @@ -152,6 +153,17 @@ elif crypto_library == 'nss'
if get_option('crypto-library-kdf').enabled()
error('KDF support has not been implemented for NSS')
endif
elif crypto_library == 'mbedtls'
mbedtls_dep = dependency('mbedtls', required: true)
srtp2_deps += [mbedtls_dep]
cdata.set('GCM', true)
cdata.set('MBEDTLS', true)
cdata.set('USE_EXTERNAL_CRYPTO', true)
use_mbedtls = true
# TODO(RLB): Use NSS for KDF
if get_option('crypto-library-kdf').enabled()
error('KDF support has not been implemented for mbedtls')
endif
endif

configure_file(output: 'config.h', configuration: cdata)
Expand Down Expand Up @@ -189,6 +201,11 @@ elif use_nss
'crypto/cipher/aes_icm_nss.c',
'crypto/cipher/aes_gcm_nss.c',
)
elif use_mbedtls
ciphers_sources += files(
'crypto/cipher/aes_icm_mbedtls.c',
'crypto/cipher/aes_gcm_mbedtls.c',
)
else
ciphers_sources += files(
'crypto/cipher/aes.c',
Expand All @@ -210,6 +227,10 @@ elif use_nss
hashes_sources += files(
'crypto/hash/hmac_nss.c',
)
elif use_mbedtls
hashes_sources += files(
'crypto/hash/hmac_mbedtls.c',
)
else
hashes_sources += files(
'crypto/hash/hmac.c',
Expand Down
4 changes: 2 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ option('log-stdout', type : 'boolean', value : false,
description : 'Redirect logging to stdout')
option('log-file', type : 'string', value : '',
description : 'Write logging output into this file')
option('crypto-library', type: 'combo', choices : ['none', 'openssl', 'nss'], value : 'none',
description : 'What external crypto library to leverage, if any (OpenSSL or NSS)')
option('crypto-library', type: 'combo', choices : ['none', 'openssl', 'nss', 'mbedtls'], value : 'none',
description : 'What external crypto library to leverage, if any (OpenSSL, NSS, or mbedtls)')
option('crypto-library-kdf', type : 'feature', value : 'auto',
description : 'Use the external crypto library for Key Derivation Function support')
option('fuzzer', type : 'feature', value : 'disabled',
Expand Down
2 changes: 1 addition & 1 deletion test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if can_run_rtpw
endif

rtpw_test_gcm_sh = find_program('rtpw_test_gcm.sh', required: false)
if (use_openssl or use_nss) and rtpw_test_gcm_sh.found()
if (use_openssl or use_nss or use_mbedtls) and rtpw_test_gcm_sh.found()
test('rtpw_test_gcm', rtpw_test_gcm_sh,
args: ['-w', words_txt],
depends: rtpw_exe,
Expand Down

0 comments on commit add8305

Please sign in to comment.