diff --git a/include/mbedtls/x509.h b/include/mbedtls/x509.h index c02c7c8ba..8297910cc 100644 --- a/include/mbedtls/x509.h +++ b/include/mbedtls/x509.h @@ -305,6 +305,10 @@ int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params, int *salt_len ); #endif 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, mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, void **sig_opts ); diff --git a/library/x509.c b/library/x509.c index be170bb46..05d995c59 100644 --- a/library/x509.c +++ b/library/x509.c @@ -802,6 +802,21 @@ int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x 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, ¶ms ); + if( ret != 0 ) + return( MBEDTLS_ERR_X509_INVALID_ALG + ret ); + + return( mbedtls_x509_get_sig_alg( &alg, ¶ms, md_alg, + pk_alg, sig_opts ) ); +} + /* * Get signature algorithm from alg OID and optional parameters */