1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Add tests for parsing CSRs

This commit is contained in:
Manuel Pégourié-Gonnard
2014-01-24 17:34:26 +01:00
parent 5eeb32b552
commit d4fd57dda4
7 changed files with 111 additions and 0 deletions

View File

@ -1,6 +1,7 @@
/* BEGIN_HEADER */
#include <polarssl/x509_crt.h>
#include <polarssl/x509_crl.h>
#include <polarssl/x509_csr.h>
#include <polarssl/pem.h>
#include <polarssl/oid.h>
@ -75,6 +76,28 @@ void x509_crl_info( char *crl_file, char *result_str )
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CSR_PARSE_C */
void x509_csr_info( char *csr_file, char *result_str )
{
x509_csr csr;
char buf[2000];
int res;
x509_csr_init( &csr );
memset( buf, 0, 2000 );
TEST_ASSERT( x509_csr_parse_file( &csr, csr_file ) == 0 );
res = x509_csr_info( buf, 2000, "", &csr );
x509_csr_free( &csr );
TEST_ASSERT( res != -1 );
TEST_ASSERT( res != -2 );
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_CRL_PARSE_C */
void x509_verify( char *crt_file, char *ca_file, char *crl_file,
char *cn_name_str, int result, int flags_result,