Skip to content

Commit

Permalink
libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pss_verify_ext()
Browse files Browse the repository at this point in the history
Adds fault mitigation in mbedtls_rsa_rsassa_pss_verify_ext() by using
the macro FTMN_CALLEE_DONE_MEMCMP() instead of memcmp() when checking
that the hash in the RSA signature is matching the expected value.

FTMN_CALLEE_DONE_MEMCMP() saves on success the result in a thread local
storage if fault mitigations was enabled when the function was called.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jenswi-linaro committed Oct 6, 2023
1 parent e7e0487 commit cec89b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/libmbedtls/mbedtls/library/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@

#include "mbedtls/platform.h"

#include <fault_mitigation.h>

#if !defined(MBEDTLS_RSA_ALT)

int mbedtls_rsa_import(mbedtls_rsa_context *ctx,
Expand Down Expand Up @@ -2151,7 +2153,7 @@ int mbedtls_rsa_rsassa_pss_verify_ext(mbedtls_rsa_context *ctx,
return ret;
}

if (memcmp(hash_start, result, hlen) != 0) {
if (FTMN_CALLEE_DONE_MEMCMP(memcmp, hash_start, result, hlen) != 0) {
return MBEDTLS_ERR_RSA_VERIFY_FAILED;
}

Expand Down

0 comments on commit cec89b6

Please sign in to comment.