Add single function to parse ASN.1 AlgorithmIdentifier to x509.c

This commit is contained in:
Hanno Becker 2019-02-22 17:49:34 +00:00
parent 1898b68f09
commit b59d3f1692
2 changed files with 19 additions and 0 deletions

View File

@ -305,6 +305,10 @@ int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params,
int *salt_len ); int *salt_len );
#endif #endif
int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig ); int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig );
int mbedtls_x509_get_sig_alg_raw( unsigned char **p, unsigned char const *end,
mbedtls_md_type_t *md_alg,
mbedtls_pk_type_t *pk_alg,
void **sig_opts );
int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params,
mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
void **sig_opts ); void **sig_opts );

View File

@ -802,6 +802,21 @@ int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x
return( 0 ); return( 0 );
} }
int mbedtls_x509_get_sig_alg_raw( unsigned char **p, unsigned char const *end,
mbedtls_md_type_t *md_alg,
mbedtls_pk_type_t *pk_alg,
void **sig_opts )
{
int ret;
mbedtls_asn1_buf alg, params;
ret = mbedtls_asn1_get_alg( p, end, &alg, &params );
if( ret != 0 )
return( MBEDTLS_ERR_X509_INVALID_ALG + ret );
return( mbedtls_x509_get_sig_alg( &alg, &params, md_alg,
pk_alg, sig_opts ) );
}
/* /*
* Get signature algorithm from alg OID and optional parameters * Get signature algorithm from alg OID and optional parameters
*/ */