mbedtls
mbedtls copied to clipboard
Move specialized constant-time functions to their respective modules
We had three purposes in creating constant_time.c
: to reduce duplication and unify the “generic” functions (partly done), to have a home for public functions (currently and in the foreseeable future, only memcmp), and to make it easier to run analyses for constant-timeness. The last point doesn't really apply since more and more parts of the library are or will be constant-time, in particular with the bignum rewrite.
So let's move the specialized functions to their respective module (and rename them accordingly, with their module's prefix):
-
mbedtls_ct_base64_enc_char
,mbedtls_ct_base64_dec_value
tobase64.c
-
mbedtls_ct_rsaes_pkcs1_v15_unpadding
torsa.c
-
mbedtls_ct_hmac
tossl_msg.c
- Probably bignum functions that operate on limb arrays as well (but not functions that operate on scalar mbedtls_mpi_uint values).
- But do create a
test_suite_constant_time
formask_of_range
andmbedtls_ct_memcpy_offset
. - And move the tests of
mbedtls_ct_hmac
to their own test suite because they take a very long time. And fix the size ofref_out
but useMBEDTLS_MAX_HASH_SIZE
.
This is a replacement for https://github.com/Mbed-TLS/mbedtls/pull/6273 which went about creating test_suite_constant_time
and moving all existing tests of constant_time.c
functions there, but without moving library functions.