mbedtls
mbedtls copied to clipboard
Write unit tests for all constant-time functions
All non-static functions in constant_time.c
should have unit tests checking that they are functionally correct. Use TEST_CF_SECRET
and TEST_CF_PUBLIC
adequately so that the all.sh
components test_*_constant_flow
check that the runs are constant-time.
The definition of done for this issue is that all functions declared in include/mbedtls/constant_time.h
, library/constant_time_internal.h
or library/constant_time_invasive.h
have unit tests, except for mbedtls_ct_rsaes_pkcs1_v15_unpadding
which has its own issue.
This can be done one function at a time. All the functions concerned by this issue have fairly simple semantics, so the difficulty will be mainly in adding appropriate TEST_CF
annotations and choosing test data.
As of 52f83dc471625f503a335ccef4f4b484a2a579ef, constant_time.c
exports following functions:
Library function | Test function |
---|---|
mbedtls_ct_uint_mask |
|
mbedtls_ct_size_mask |
|
mbedtls_ct_mpi_uint_mask |
|
mbedtls_ct_size_mask_ge |
|
mbedtls_ct_size_bool_eq |
|
mbedtls_ct_mpi_uint_lt |
|
mbedtls_mpi_core_lt_ct |
mpi_core_lt_ct (test_suite_mpi ) |
mbedtls_ct_uint_if |
|
mbedtls_ct_mpi_uint_cond_assign |
|
mbedtls_ct_base64_enc_char |
enc_chars (test_suite_base64 ) |
mbedtls_ct_base64_dec_value |
dec_chars (test_suite_base64 ) |
mbedtls_ct_memcpy_if_eq |
|
mbedtls_ct_memcpy_offset |
ssl_cf_memcpy_offset (test_suite_ssl ) |
mbedtls_ct_hmac |
ssl_cf_hmac (test_suite_ssl ) |
mbedtls_ct_rsaes_pkcs1_v15_unpadding |
https://github.com/Mbed-TLS/mbedtls/issues/6272 |