Add opaque context to mbedtls_x509_crt_ext_cb_t
Signed-off-by: Nicola Di Lieto <nicola.dilieto@gmail.com>
diff --git a/library/x509_crt.c b/library/x509_crt.c
index 5543522..99d3be2 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -893,7 +893,8 @@
static int x509_get_crt_ext( unsigned char **p,
const unsigned char *end,
mbedtls_x509_crt *crt,
- mbedtls_x509_crt_ext_cb_t cb )
+ mbedtls_x509_crt_ext_cb_t cb,
+ void *p_ctx )
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
size_t len;
@@ -959,7 +960,7 @@
/* Give the callback (if any) a chance to handle the extension */
if( cb != NULL )
{
- ret = cb( crt, &extn_oid, is_critical, *p, end_ext_octet );
+ ret = cb( p_ctx, crt, &extn_oid, is_critical, *p, end_ext_octet );
if( ret != 0 )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
*p = end_ext_octet;
@@ -1073,7 +1074,8 @@
const unsigned char *buf,
size_t buflen,
int make_copy,
- mbedtls_x509_crt_ext_cb_t cb )
+ mbedtls_x509_crt_ext_cb_t cb,
+ void *p_ctx )
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
size_t len;
@@ -1272,7 +1274,7 @@
if( crt->version == 3 )
#endif
{
- ret = x509_get_crt_ext( &p, end, crt, cb );
+ ret = x509_get_crt_ext( &p, end, crt, cb, p_ctx );
if( ret != 0 )
{
mbedtls_x509_crt_free( crt );
@@ -1336,7 +1338,8 @@
const unsigned char *buf,
size_t buflen,
int make_copy,
- mbedtls_x509_crt_ext_cb_t cb )
+ mbedtls_x509_crt_ext_cb_t cb,
+ void *p_ctx )
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
mbedtls_x509_crt *crt = chain, *prev = NULL;
@@ -1368,7 +1371,7 @@
crt = crt->next;
}
- ret = x509_crt_parse_der_core( crt, buf, buflen, make_copy, cb );
+ ret = x509_crt_parse_der_core( crt, buf, buflen, make_copy, cb, p_ctx );
if( ret != 0 )
{
if( prev )
@@ -1387,23 +1390,24 @@
const unsigned char *buf,
size_t buflen )
{
- return( mbedtls_x509_crt_parse_der_internal( chain, buf, buflen, 0, NULL ) );
+ return( mbedtls_x509_crt_parse_der_internal( chain, buf, buflen, 0, NULL, NULL ) );
}
int mbedtls_x509_crt_parse_der_with_ext_cb( mbedtls_x509_crt *chain,
const unsigned char *buf,
size_t buflen,
int make_copy,
- mbedtls_x509_crt_ext_cb_t cb )
+ mbedtls_x509_crt_ext_cb_t cb,
+ void *p_ctx )
{
- return( mbedtls_x509_crt_parse_der_internal( chain, buf, buflen, make_copy, cb ) );
+ return( mbedtls_x509_crt_parse_der_internal( chain, buf, buflen, make_copy, cb, p_ctx ) );
}
int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain,
const unsigned char *buf,
size_t buflen )
{
- return( mbedtls_x509_crt_parse_der_internal( chain, buf, buflen, 1, NULL ) );
+ return( mbedtls_x509_crt_parse_der_internal( chain, buf, buflen, 1, NULL, NULL ) );
}
/*