fix: add missing deprecation guards
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h
index 5a9da98..25d4a7b 100644
--- a/include/mbedtls/x509_crt.h
+++ b/include/mbedtls/x509_crt.h
@@ -996,7 +996,7 @@
*/
void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version );
-#if defined(MBEDTLS_BIGNUM_C)
+#if defined(MBEDTLS_BIGNUM_C) && !defined(MBEDTLS_DEPRECATED_REMOVED)
/**
* \brief Set the serial number for a Certificate.
*
@@ -1014,8 +1014,9 @@
*
* \return 0 if successful
*/
-int mbedtls_x509write_crt_set_serial( mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial );
-#endif
+int MBEDTLS_DEPRECATED mbedtls_x509write_crt_set_serial(
+ mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial );
+#endif // MBEDTLS_BIGNUM_C && !MBEDTLS_DEPRECATED_REMOVED
/**
* \brief Set the serial number for a Certificate.
diff --git a/library/x509write_crt.c b/library/x509write_crt.c
index 618c51e..04226b8 100644
--- a/library/x509write_crt.c
+++ b/library/x509write_crt.c
@@ -100,7 +100,7 @@
return mbedtls_x509_string_to_names( &ctx->issuer, issuer_name );
}
-#if defined(MBEDTLS_BIGNUM_C)
+#if defined(MBEDTLS_BIGNUM_C) && !defined(MBEDTLS_DEPRECATED_REMOVED)
int mbedtls_x509write_crt_set_serial( mbedtls_x509write_cert *ctx,
const mbedtls_mpi *serial )
{
@@ -126,7 +126,7 @@
return( 0 );
}
-#endif
+#endif // MBEDTLS_BIGNUM_C && !MBEDTLS_DEPRECATED_REMOVED
int mbedtls_x509write_crt_set_serial_new( mbedtls_x509write_cert *ctx,
char* serial_buff, size_t serial_buff_len)
diff --git a/programs/x509/cert_write.c b/programs/x509/cert_write.c
index be3464e..f9d5102 100644
--- a/programs/x509/cert_write.c
+++ b/programs/x509/cert_write.c
@@ -723,7 +723,7 @@
mbedtls_x509write_crt_set_version( &crt, opt.version );
mbedtls_x509write_crt_set_md_alg( &crt, opt.md );
-#if defined(MBEDTLS_BIGNUM_C)
+#if defined(MBEDTLS_BIGNUM_C) && !defined(MBEDTLS_DEPRECATED_REMOVED)
ret = mbedtls_x509write_crt_set_serial( &crt, &serial );
if( ret != 0 )
{
diff --git a/tests/suites/test_suite_x509write.function b/tests/suites/test_suite_x509write.function
index c6ebc22..77115ca 100644
--- a/tests/suites/test_suite_x509write.function
+++ b/tests/suites/test_suite_x509write.function
@@ -377,14 +377,11 @@
if( pk_wrap == 2 )
TEST_ASSERT( mbedtls_pk_get_type( &issuer_key ) == MBEDTLS_PK_OPAQUE );
-#if !defined(MBEDTLS_BIGNUM_C)
- TEST_ASSERT( mbedtls_test_read_mpi( &serial, serial_str ) == 0 );
-#endif
-
if( ver != -1 )
mbedtls_x509write_crt_set_version( &crt, ver );
-#if !defined(MBEDTLS_BIGNUM_C)
+#if defined(MBEDTLS_BIGNUM_C) && !defined(MBEDTLS_DEPRECATED_REMOVED)
+ TEST_ASSERT( mbedtls_test_read_mpi( &serial, serial_str ) == 0 );
TEST_ASSERT( mbedtls_x509write_crt_set_serial( &crt, &serial ) == 0 );
#else
TEST_ASSERT( mbedtls_x509write_crt_set_serial_new( &crt, serial_str,