mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01:00
Improve x509xrite_csr testing: extensions, version
This commit is contained in:
parent
c5ce83a3b8
commit
6c1a73e061
3 changed files with 46 additions and 6 deletions
|
|
@ -62,7 +62,8 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
|
|||
char *subject_name, char *issuer_key_file,
|
||||
char *issuer_pwd, char *issuer_name,
|
||||
char *serial_str, char *not_before, char *not_after,
|
||||
int md_type, char *cert_check_file )
|
||||
int md_type, int key_usage, int cert_type, int ver,
|
||||
char *cert_check_file )
|
||||
{
|
||||
pk_context subject_key, issuer_key;
|
||||
x509write_cert crt;
|
||||
|
|
@ -86,7 +87,9 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
|
|||
TEST_ASSERT( mpi_read_string( &serial, 10, serial_str ) == 0 );
|
||||
|
||||
x509write_crt_init( &crt );
|
||||
x509write_crt_set_serial( &crt, &serial );
|
||||
if( ver != -1 )
|
||||
x509write_crt_set_version( &crt, ver );
|
||||
TEST_ASSERT( x509write_crt_set_serial( &crt, &serial ) == 0 );
|
||||
TEST_ASSERT( x509write_crt_set_validity( &crt, not_before,
|
||||
not_after ) == 0 );
|
||||
x509write_crt_set_md_alg( &crt, md_type );
|
||||
|
|
@ -95,9 +98,16 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
|
|||
x509write_crt_set_subject_key( &crt, &subject_key );
|
||||
x509write_crt_set_issuer_key( &crt, &issuer_key );
|
||||
|
||||
TEST_ASSERT( x509write_crt_set_basic_constraints( &crt, 0, 0 ) == 0 );
|
||||
TEST_ASSERT( x509write_crt_set_subject_key_identifier( &crt ) == 0 );
|
||||
TEST_ASSERT( x509write_crt_set_authority_key_identifier( &crt ) == 0 );
|
||||
if( crt.version >= X509_CRT_VERSION_3 )
|
||||
{
|
||||
TEST_ASSERT( x509write_crt_set_basic_constraints( &crt, 0, 0 ) == 0 );
|
||||
TEST_ASSERT( x509write_crt_set_subject_key_identifier( &crt ) == 0 );
|
||||
TEST_ASSERT( x509write_crt_set_authority_key_identifier( &crt ) == 0 );
|
||||
if( key_usage != 0 )
|
||||
TEST_ASSERT( x509write_crt_set_key_usage( &crt, key_usage ) == 0 );
|
||||
if( cert_type != 0 )
|
||||
TEST_ASSERT( x509write_crt_set_ns_cert_type( &crt, cert_type ) == 0 );
|
||||
}
|
||||
|
||||
ret = x509write_crt_pem( &crt, buf, sizeof(buf),
|
||||
rnd_pseudo_rand, &rnd_info );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue