mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-11 00:05:38 +00:00
Make x509_crl_parse() iterative
This commit is contained in:
parent
426d4ae7ff
commit
6ed2d92629
|
@ -489,15 +489,17 @@ int x509_crl_parse_der( x509_crl *chain,
|
||||||
*/
|
*/
|
||||||
int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
|
int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
|
||||||
{
|
{
|
||||||
|
#if defined(POLARSSL_PEM_PARSE_C)
|
||||||
int ret;
|
int ret;
|
||||||
|
size_t use_len;
|
||||||
|
pem_context pem;
|
||||||
|
int is_pem = 0;
|
||||||
|
|
||||||
if( chain == NULL || buf == NULL )
|
if( chain == NULL || buf == NULL )
|
||||||
return( POLARSSL_ERR_X509_BAD_INPUT_DATA );
|
return( POLARSSL_ERR_X509_BAD_INPUT_DATA );
|
||||||
|
|
||||||
#if defined(POLARSSL_PEM_PARSE_C)
|
do
|
||||||
size_t use_len;
|
{
|
||||||
pem_context pem;
|
|
||||||
|
|
||||||
pem_init( &pem );
|
pem_init( &pem );
|
||||||
ret = pem_read_buffer( &pem,
|
ret = pem_read_buffer( &pem,
|
||||||
"-----BEGIN X509 CRL-----",
|
"-----BEGIN X509 CRL-----",
|
||||||
|
@ -509,11 +511,16 @@ int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
|
||||||
/*
|
/*
|
||||||
* Was PEM encoded
|
* Was PEM encoded
|
||||||
*/
|
*/
|
||||||
|
is_pem = 1;
|
||||||
|
|
||||||
buflen -= use_len;
|
buflen -= use_len;
|
||||||
buf += use_len;
|
buf += use_len;
|
||||||
|
|
||||||
if( ( ret = x509_crl_parse_der( chain, pem.buf, pem.buflen ) ) != 0 )
|
if( ( ret = x509_crl_parse_der( chain,
|
||||||
|
pem.buf, pem.buflen ) ) != 0 )
|
||||||
|
{
|
||||||
return( ret );
|
return( ret );
|
||||||
|
}
|
||||||
|
|
||||||
pem_free( &pem );
|
pem_free( &pem );
|
||||||
}
|
}
|
||||||
|
@ -522,19 +529,14 @@ int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen )
|
||||||
pem_free( &pem );
|
pem_free( &pem );
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
while( is_pem && buflen > 0 );
|
||||||
|
|
||||||
|
if( is_pem )
|
||||||
|
return( 0 );
|
||||||
else
|
else
|
||||||
#endif /* POLARSSL_PEM_PARSE_C */
|
#endif /* POLARSSL_PEM_PARSE_C */
|
||||||
{
|
return( x509_crl_parse_der( chain, buf, buflen ) );
|
||||||
if( ( ret = x509_crl_parse_der( chain, buf, buflen ) ) != 0 )
|
|
||||||
return( ret );
|
|
||||||
|
|
||||||
buflen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( buflen > 0 )
|
|
||||||
return( x509_crl_parse( chain, buf, buflen ) );
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(POLARSSL_FS_IO)
|
#if defined(POLARSSL_FS_IO)
|
||||||
|
|
Loading…
Reference in a new issue