-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move constant-time functions into a separate module #3649
Comments
I wanted to add this to the "tech debt" EPIC, but we can't put an issue in more that one EPIC. Let's leave it in "2.x pre-LTS" as I think that's accurate and conveys that we want to do it sooner rather than later, but keep it in mind when we plan work on paying out tech debt. |
I suspect this will be the hard part. Ideally we want to have masks of many types, including
I'm sure we'll come up with something, I just want to share my thoughts so far and point out where I think non-trivial design work with be needed. Also, as the description says, we may also want to split and do the harder parts in a follow-up. Centralizing things and doing the trivial/easy deduplications would already be a huge win. |
There is a growing set of functions that are written to be protected against side channels that observe code and data paths. These functions are intended to be constant-time in the sense that not only does the total time taken by the function is independent of sensitive inputs, but also events such as branches and memory accesses are independent of sensitive inputs. This could also be called constant-trace.
The goal of this task is to create a new library module for these functions. The reason to have a separate module is to make reviewing, testing and static analysis simpler: if a function is in this module, it's expected to be constant-trace. Another reason to have a separate module is that we currently have some code duplication because multiple modules required identical or near-identical building blocks.
Existing constant-trace functions include (this may not be an exhaustive list!):
mbedtls_ssl_safer_memcmp
and its copies:mbedtls_nist_kw_safer_memcmp
, andsafer_memcmp
inpsa_crypto.c
.rsa.c
:mbedtls_rsa_rsaes_pkcs1_v15_decrypt
and its building blocks, apart from the call tombedtls_rsa_private
(ormbedtls_rsa_public
).ssl_msg.c
:mbedtls_ssl_cf_hmac
and its building blocks.base64.c
:mbedtls_base64_table_lookup
and its building blocks.bignum.c
:mbedtls_mpi_safe_xxx
and their building blocks;mbedtls_mpi_lt_mpi_ct()
Goals (to be done in the order described here, so as to facilitate review):
For the sake of Mbed OS, the name of the new file must be sufficiently distinctive: Mbed OS's build system does not support two
.c
files with the same name in different subprojects.Do not expose any of the new functions publicly for now. Declare them only in a header file inside
library
.mbedtls_<modulename>_xxx
). The names should be unique except for functions that have exactly the same prototype and interface.Follow-ups (some to be filed):
0
/1
or0
/~1
, to maskuint8_t
orsize_t
.This change should not be backported to long-time support branches because we don't want to disrupt the build of long-time support versions by creating a new library source file. So we'll do it in 2.2x before it becomes an LTS, but we won't do it on 2.16.
The text was updated successfully, but these errors were encountered: