Detect invalid padding parameters when setting up an RSA context #4523
Labels
component-crypto
Crypto primitives and low-level interfaces
enhancement
size-s
Estimated task size: small (~2d)
Context
mbedtls_rsa_init
takes two argumentspadding
andhash_id
which can be invalid. However, as an initialization function, it must return void, since it is often called in contexts that cannot jump to error handling because other objects are not initialized yet.In Mbed TLS 2.16+, there was validation through
MBEDTLS_PARAM_FAILED
ifMBEDTLS_CHECK_PARAMS
was enabled. With the removal ofMBEDTLS_CHECK_PARAMS
, there is no way to enable any validation anymore.Goal
Change to the API of the RSA module. Important requirements:
mbedtls_rsa_init
cannot return errors. (Butmbedtls_rsa_set_padding
can.)mbedtls_rsa_init
ormbedtls_rsa_set_padding
, and it is stored in the RSA context object.MBEDTLS_MD_NONE
is ok for V15 padding.)Possible solutions
This is not an exhaustive list.
mbedtls_rsa_init
set the padding to some documented default, and require the caller to callmbedtls_rsa_set_padding
if some other default is desired. Changembedtls_rsa_set_padding
to returnMBEDTLS_ERR_RSA_BAD_INPUT_DATA
if the arguments are invalid.The text was updated successfully, but these errors were encountered: