From 2222d689c547b9eb8063ca019607543809612ee5 Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Mon, 11 Jan 2021 18:45:22 +0100 Subject: [PATCH] Allow GCM selftest to skip non-12-byte IVs for ALT implementations Signed-off-by: Steven Cooreman --- library/gcm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/gcm.c b/library/gcm.c index 2363e584e..f237bab7d 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -819,6 +819,15 @@ int mbedtls_gcm_self_test( int verbose ) add_len_test_data[i], pt_test_data[pt_index_test_data[i]], buf, 16, tag_buf ); +#if defined(MBEDTLS_GCM_ALT) + /* Allow alternative implementations to only support 12-byte nonces. */ + if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && + iv_len_test_data[i] != 12 ) + { + mbedtls_printf( "skipped\n" ); + break; + } +#endif /* defined(MBEDTLS_GCM_ALT) */ if( ret != 0 ) goto exit;