mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-04 17:29:58 +00:00
library: debug: adjust guards for "mbedtls_debug_print_crt"
Keep MBEDTLS_PK_WRITE_C as guard only for "debug_print_pk" but let "mbedtls_debug_print_crt" to work also when MBEDTLS_PK_WRITE_C is disabled. In this case the only public key won't be printed, but the rest of the certificate will be. This commit also updates test coverage by duplicating test cases: now there will be one case for when MBEDTLS_PK_WRITE_C is enabled and another one for !MBEDTLS_PK_WRITE_C. Signed-off-by: Valerio Setti <[email protected]>
This commit is contained in:
+7
-3
@@ -179,8 +179,9 @@ void mbedtls_debug_print_buf(const mbedtls_ssl_context *ssl, int level,
|
||||
MBEDTLS_DEBUG_PRINT_BUF_ADD_TEXT);
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C) && !defined(MBEDTLS_X509_REMOVE_INFO) && \
|
||||
defined(MBEDTLS_PK_WRITE_C)
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C) && !defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
|
||||
#if defined(MBEDTLS_PK_WRITE_C)
|
||||
static void debug_print_pk(const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const mbedtls_pk_context *pk)
|
||||
@@ -198,6 +199,7 @@ static void debug_print_pk(const mbedtls_ssl_context *ssl, int level,
|
||||
"failed to export public key from PK context");
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_PK_WRITE_C */
|
||||
|
||||
static void debug_print_line_by_line(const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line, const char *text)
|
||||
@@ -247,11 +249,13 @@ void mbedtls_debug_print_crt(const mbedtls_ssl_context *ssl, int level,
|
||||
mbedtls_x509_crt_info(buf, sizeof(buf) - 1, "", crt);
|
||||
debug_print_line_by_line(ssl, level, file, line, buf);
|
||||
|
||||
#if defined(MBEDTLS_PK_WRITE_C)
|
||||
debug_print_pk(ssl, level, file, line, "crt->PK", &crt->pk);
|
||||
#endif /* MBEDTLS_PK_WRITE_C */
|
||||
|
||||
crt = crt->next;
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_X509_REMOVE_INFO && MBEDTLS_PK_WRITE_C */
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_X509_REMOVE_INFO */
|
||||
|
||||
#endif /* MBEDTLS_DEBUG_C */
|
||||
|
||||
Reference in New Issue
Block a user