Skip to content

Commit bff7733

Browse files
Merge pull request #9913 from valeriosetti/issue9892
Remove deprecated function mbedtls_x509write_crt_set_serial()
2 parents 99d8216 + 19846f5 commit bff7733

File tree

4 files changed

+4
-59
lines changed

4 files changed

+4
-59
lines changed

ChangeLog.d/9892.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Removals
2+
* Remove deprecated mbedtls_x509write_crt_set_serial(). The function was
3+
already deprecated and superseeded by
4+
mbedtls_x509write_crt_set_serial_raw().

include/mbedtls/x509_crt.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -943,28 +943,6 @@ void mbedtls_x509write_crt_init(mbedtls_x509write_cert *ctx);
943943
*/
944944
void mbedtls_x509write_crt_set_version(mbedtls_x509write_cert *ctx, int version);
945945

946-
#if defined(MBEDTLS_BIGNUM_C) && !defined(MBEDTLS_DEPRECATED_REMOVED)
947-
/**
948-
* \brief Set the serial number for a Certificate.
949-
*
950-
* \deprecated This function is deprecated and will be removed in a
951-
* future version of the library. Please use
952-
* mbedtls_x509write_crt_set_serial_raw() instead.
953-
*
954-
* \note Even though the MBEDTLS_BIGNUM_C guard looks redundant since
955-
* X509 depends on PK and PK depends on BIGNUM, this emphasizes
956-
* a direct dependency between X509 and BIGNUM which is going
957-
* to be deprecated in the future.
958-
*
959-
* \param ctx CRT context to use
960-
* \param serial serial number to set
961-
*
962-
* \return 0 if successful
963-
*/
964-
int MBEDTLS_DEPRECATED mbedtls_x509write_crt_set_serial(
965-
mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial);
966-
#endif // MBEDTLS_BIGNUM_C && !MBEDTLS_DEPRECATED_REMOVED
967-
968946
/**
969947
* \brief Set the serial number for a Certificate.
970948
*

library/x509write_crt.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,6 @@ int mbedtls_x509write_crt_set_issuer_name(mbedtls_x509write_cert *ctx,
9292
return mbedtls_x509_string_to_names(&ctx->issuer, issuer_name);
9393
}
9494

95-
#if defined(MBEDTLS_BIGNUM_C) && !defined(MBEDTLS_DEPRECATED_REMOVED)
96-
int mbedtls_x509write_crt_set_serial(mbedtls_x509write_cert *ctx,
97-
const mbedtls_mpi *serial)
98-
{
99-
int ret;
100-
size_t tmp_len;
101-
102-
/* Ensure that the MPI value fits into the buffer */
103-
tmp_len = mbedtls_mpi_size(serial);
104-
if (tmp_len > MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN) {
105-
return MBEDTLS_ERR_X509_BAD_INPUT_DATA;
106-
}
107-
108-
ctx->serial_len = tmp_len;
109-
110-
ret = mbedtls_mpi_write_binary(serial, ctx->serial, tmp_len);
111-
if (ret < 0) {
112-
return ret;
113-
}
114-
115-
return 0;
116-
}
117-
#endif // MBEDTLS_BIGNUM_C && !MBEDTLS_DEPRECATED_REMOVED
118-
11995
int mbedtls_x509write_crt_set_serial_raw(mbedtls_x509write_cert *ctx,
12096
unsigned char *serial, size_t serial_len)
12197
{

tests/suites/test_suite_x509write.function

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,8 @@ void x509_crt_check(char *subject_key_file, char *subject_pwd,
471471
mbedtls_x509write_crt_set_version(&crt, ver);
472472
}
473473

474-
#if defined(MBEDTLS_TEST_DEPRECATED) && defined(MBEDTLS_BIGNUM_C)
475-
TEST_ASSERT(mbedtls_mpi_read_binary(&serial_mpi, serial_arg->x,
476-
serial_arg->len) == 0);
477-
TEST_ASSERT(mbedtls_x509write_crt_set_serial(&crt, &serial_mpi) == 0);
478-
#else
479474
TEST_ASSERT(mbedtls_x509write_crt_set_serial_raw(&crt, serial_arg->x,
480475
serial_arg->len) == 0);
481-
#endif
482476
TEST_ASSERT(mbedtls_x509write_crt_set_validity(&crt, not_before,
483477
not_after) == 0);
484478
mbedtls_x509write_crt_set_md_alg(&crt, md_type);
@@ -665,13 +659,6 @@ void x509_set_serial_check()
665659
USE_PSA_INIT();
666660
memset(invalid_serial, 0x01, sizeof(invalid_serial));
667661

668-
#if defined(MBEDTLS_TEST_DEPRECATED) && defined(MBEDTLS_BIGNUM_C)
669-
TEST_EQUAL(mbedtls_mpi_read_binary(&serial_mpi, invalid_serial,
670-
sizeof(invalid_serial)), 0);
671-
TEST_EQUAL(mbedtls_x509write_crt_set_serial(&ctx, &serial_mpi),
672-
MBEDTLS_ERR_X509_BAD_INPUT_DATA);
673-
#endif
674-
675662
TEST_EQUAL(mbedtls_x509write_crt_set_serial_raw(&ctx, invalid_serial,
676663
sizeof(invalid_serial)),
677664
MBEDTLS_ERR_X509_BAD_INPUT_DATA);

0 commit comments

Comments
 (0)