Deprecate mbedtls_asn1_free_named_data()

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
This commit is contained in:
Glenn Strauss 2022-11-04 04:01:23 -04:00
parent 7db3124c00
commit 82ba274c01
5 changed files with 25 additions and 6 deletions

View file

@ -1,2 +1,6 @@
Features
* Shared code to free x509 structs like mbedtls_x509_named_data
New deprecations
* Deprecate mbedtls_asn1_free_named_data().
Use mbedtls_asn1_free_named_data_list()
or mbedtls_asn1_free_named_data_list_shallow()

View file

@ -24,6 +24,7 @@
#include "mbedtls/private_access.h"
#include "mbedtls/build_info.h"
#include "mbedtls/platform_util.h"
#include <stddef.h>
@ -606,22 +607,29 @@ int mbedtls_asn1_get_alg_null( unsigned char **p,
const mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( const mbedtls_asn1_named_data *list,
const char *oid, size_t len );
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
/**
* \brief Free a mbedtls_asn1_named_data entry
*
* \deprecated This function is deprecated and will be removed in a
* future version of the library.
* Please use mbedtls_asn1_free_named_data_list()
* or mbedtls_asn1_free_named_data_list_shallow().
*
* \param entry The named data entry to free.
* This function calls mbedtls_free() on
* `entry->oid.p` and `entry->val.p`.
*/
void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *entry );
void MBEDTLS_DEPRECATED mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *entry );
#endif /* MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Free all entries in a mbedtls_asn1_named_data list.
*
* \param head Pointer to the head of the list of named data entries to free.
* This function calls mbedtls_asn1_free_named_data() and
* mbedtls_free() on each list element and
* sets \c *head to \c NULL.
* This function calls mbedtls_free() on
* `entry->oid.p` and `entry->val.p` and then on `entry`
* for each list entry, and sets \c *head to \c NULL.
*/
void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head );

View file

@ -431,6 +431,7 @@ int mbedtls_asn1_get_alg_null( unsigned char **p,
return( 0 );
}
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *cur )
{
if( cur == NULL )
@ -441,6 +442,7 @@ void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *cur )
mbedtls_platform_zeroize( cur, sizeof( mbedtls_asn1_named_data ) );
}
#endif /* MBEDTLS_DEPRECATED_REMOVED */
void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head )
{

View file

@ -608,18 +608,23 @@ Find named data: first match
find_named_data:"414141":"414141":"434343":"444444":"414141":0:0
Free named data: null pointer
depends_on:MBEDTLS_TEST_DEPRECATED
free_named_data_null:
Free named data: all null
depends_on:MBEDTLS_TEST_DEPRECATED
free_named_data:0:0:0
Free named data: with oid
depends_on:MBEDTLS_TEST_DEPRECATED
free_named_data:1:0:0
Free named data: with val
depends_on:MBEDTLS_TEST_DEPRECATED
free_named_data:0:1:0
Free named data: with next
depends_on:MBEDTLS_TEST_DEPRECATED
free_named_data:0:0:1
Free named data list (empty)

View file

@ -735,7 +735,7 @@ void find_named_data( data_t *oid0, data_t *oid1, data_t *oid2, data_t *oid3,
}
/* END_CASE */
/* BEGIN_CASE */
/* BEGIN_CASE depends_on:!MBEDTLS_DEPRECATED_REMOVED */
void free_named_data_null( )
{
mbedtls_asn1_free_named_data( NULL );
@ -743,7 +743,7 @@ void free_named_data_null( )
}
/* END_CASE */
/* BEGIN_CASE */
/* BEGIN_CASE depends_on:!MBEDTLS_DEPRECATED_REMOVED */
void free_named_data( int with_oid, int with_val, int with_next )
{
mbedtls_asn1_named_data next =