From f74a86c0b0bd1195496f7a92057724c09317249d Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Sun, 20 Sep 2020 01:57:30 +0200 Subject: [PATCH] Improve FI resistance of certificate verification in ssl_srv.c Signed-off-by: Andrzej Kurek --- library/ssl_srv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 1b29cc839..96f7446e3 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -4457,6 +4457,7 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) { volatile int ret = MBEDTLS_ERR_PLATFORM_FAULT_DETECTED; + volatile int ret_fi = MBEDTLS_ERR_PLATFORM_FAULT_DETECTED; size_t i, sig_len; unsigned char hash[48]; unsigned char *hash_start = hash; @@ -4650,10 +4651,10 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) { mbedtls_platform_random_delay(); - ret = mbedtls_pk_verify( peer_pk, - md_alg, hash_start, hashlen, - ssl->in_msg + i, sig_len ); - if( ret == 0 ) + ret_fi = mbedtls_pk_verify( peer_pk, + md_alg, hash_start, hashlen, + ssl->in_msg + i, sig_len ); + if( ret == 0 && ret_fi == 0 ) { mbedtls_ssl_update_handshake_status( ssl );