mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
Combine hex parameters in a struct
This commit is contained in:
committed by
Mohammad Azim Khan
parent
5cfc06832e
commit
d30ca130e8
@ -1,4 +1,5 @@
|
||||
/* BEGIN_HEADER */
|
||||
#include "mbedtls/bignum.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/x509_crt.h"
|
||||
#include "mbedtls/x509_crl.h"
|
||||
@ -439,8 +440,7 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
|
||||
void x509parse_crt( uint8_t * buf, uint32_t data_len, char * result_str,
|
||||
int result )
|
||||
void x509parse_crt( HexParam_t * buf, char * result_str, int result )
|
||||
{
|
||||
mbedtls_x509_crt crt;
|
||||
unsigned char output[2000];
|
||||
@ -450,7 +450,7 @@ void x509parse_crt( uint8_t * buf, uint32_t data_len, char * result_str,
|
||||
memset( output, 0, 2000 );
|
||||
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf, data_len ) == ( result ) );
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf->x, buf->len ) == ( result ) );
|
||||
if( ( result ) == 0 )
|
||||
{
|
||||
res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
|
||||
@ -467,8 +467,7 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRL_PARSE_C */
|
||||
void x509parse_crl( uint8_t * buf, uint32_t data_len, char * result_str,
|
||||
int result )
|
||||
void x509parse_crl( HexParam_t * buf, char * result_str, int result )
|
||||
{
|
||||
mbedtls_x509_crl crl;
|
||||
unsigned char output[2000];
|
||||
@ -478,7 +477,7 @@ void x509parse_crl( uint8_t * buf, uint32_t data_len, char * result_str,
|
||||
memset( output, 0, 2000 );
|
||||
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crl_parse( &crl, buf, data_len ) == ( result ) );
|
||||
TEST_ASSERT( mbedtls_x509_crl_parse( &crl, buf->x, buf->len ) == ( result ) );
|
||||
if( ( result ) == 0 )
|
||||
{
|
||||
res = mbedtls_x509_crl_info( (char *) output, 2000, "", &crl );
|
||||
@ -495,19 +494,16 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_CSR_PARSE_C */
|
||||
void mbedtls_x509_csr_parse( char * csr_der_hex, char * ref_out, int ref_ret )
|
||||
void mbedtls_x509_csr_parse( HexParam_t * csr_der, char * ref_out, int ref_ret )
|
||||
{
|
||||
mbedtls_x509_csr csr;
|
||||
unsigned char *csr_der = NULL;
|
||||
char my_out[1000];
|
||||
size_t csr_der_len;
|
||||
int my_ret;
|
||||
|
||||
mbedtls_x509_csr_init( &csr );
|
||||
memset( my_out, 0, sizeof( my_out ) );
|
||||
csr_der = unhexify_alloc( csr_der_hex, &csr_der_len );
|
||||
|
||||
my_ret = mbedtls_x509_csr_parse_der( &csr, csr_der, csr_der_len );
|
||||
my_ret = mbedtls_x509_csr_parse_der( &csr, csr_der->x, csr_der->len );
|
||||
TEST_ASSERT( my_ret == ref_ret );
|
||||
|
||||
if( ref_ret == 0 )
|
||||
@ -519,7 +515,6 @@ void mbedtls_x509_csr_parse( char * csr_der_hex, char * ref_out, int ref_ret )
|
||||
|
||||
exit:
|
||||
mbedtls_x509_csr_free( &csr );
|
||||
mbedtls_free( csr_der );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -626,7 +621,7 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */
|
||||
void x509_oid_desc( uint8_t * buf, uint32_t buf_len, char * ref_desc )
|
||||
void x509_oid_desc( HexParam_t * buf, char * ref_desc )
|
||||
{
|
||||
mbedtls_x509_buf oid;
|
||||
const char *desc = NULL;
|
||||
@ -634,8 +629,8 @@ void x509_oid_desc( uint8_t * buf, uint32_t buf_len, char * ref_desc )
|
||||
|
||||
|
||||
oid.tag = MBEDTLS_ASN1_OID;
|
||||
oid.p = buf;
|
||||
oid.len = buf_len;
|
||||
oid.p = buf->x;
|
||||
oid.len = buf->len;
|
||||
|
||||
ret = mbedtls_oid_get_extended_key_usage( &oid, &desc );
|
||||
|
||||
@ -654,8 +649,7 @@ void x509_oid_desc( uint8_t * buf, uint32_t buf_len, char * ref_desc )
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */
|
||||
void x509_oid_numstr( uint8_t * oid_buf, uint32_t oid_buf_len, char * numstr,
|
||||
int blen, int ret )
|
||||
void x509_oid_numstr( HexParam_t * oid_buf, char * numstr, int blen, int ret )
|
||||
{
|
||||
mbedtls_x509_buf oid;
|
||||
char num_buf[100];
|
||||
@ -663,8 +657,8 @@ void x509_oid_numstr( uint8_t * oid_buf, uint32_t oid_buf_len, char * numstr,
|
||||
memset( num_buf, 0x2a, sizeof num_buf );
|
||||
|
||||
oid.tag = MBEDTLS_ASN1_OID;
|
||||
oid.p = oid_buf;
|
||||
oid.len = oid_buf_len;
|
||||
oid.p = oid_buf->x;
|
||||
oid.len = oid_buf->len;
|
||||
|
||||
TEST_ASSERT( (size_t) blen <= sizeof num_buf );
|
||||
|
||||
@ -695,8 +689,8 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */
|
||||
void x509_check_extended_key_usage( char * crt_file, uint8_t * oid,
|
||||
uint32_t len, int ret )
|
||||
void x509_check_extended_key_usage( char * crt_file, HexParam_t * oid, int ret
|
||||
)
|
||||
{
|
||||
mbedtls_x509_crt crt;
|
||||
|
||||
@ -705,7 +699,7 @@ void x509_check_extended_key_usage( char * crt_file, uint8_t * oid,
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_check_extended_key_usage( &crt, oid, len ) == ret );
|
||||
TEST_ASSERT( mbedtls_x509_crt_check_extended_key_usage( &crt, (const char *)oid->x, oid->len ) == ret );
|
||||
|
||||
exit:
|
||||
mbedtls_x509_crt_free( &crt );
|
||||
@ -743,7 +737,7 @@ void x509_get_time( int tag, char * time_str, int ret, int year, int mon,
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
void x509_parse_rsassa_pss_params( char * hex_params, int params_tag,
|
||||
void x509_parse_rsassa_pss_params( HexParam_t * hex_params, int params_tag,
|
||||
int ref_msg_md, int ref_mgf_md,
|
||||
int ref_salt_len, int ref_ret )
|
||||
{
|
||||
@ -752,7 +746,8 @@ void x509_parse_rsassa_pss_params( char * hex_params, int params_tag,
|
||||
mbedtls_md_type_t my_msg_md, my_mgf_md;
|
||||
int my_salt_len;
|
||||
|
||||
params.p = unhexify_alloc( hex_params, ¶ms.len );
|
||||
params.p = hex_params->x;
|
||||
params.len = hex_params->len;
|
||||
params.tag = params_tag;
|
||||
|
||||
my_ret = mbedtls_x509_get_rsassa_pss_params( ¶ms, &my_msg_md, &my_mgf_md,
|
||||
@ -768,7 +763,7 @@ void x509_parse_rsassa_pss_params( char * hex_params, int params_tag,
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_free( params.p );
|
||||
;;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
Reference in New Issue
Block a user