blob: 0c547910c6ff59c5e4972c32b072483e9bd02fe1 [file] [log] [blame]
Paul Bakker33b43f12013-08-20 11:48:36 +02001/* BEGIN_HEADER */
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +00002#include "mbedtls/x509_crt.h"
3#include "mbedtls/x509_crl.h"
4#include "mbedtls/x509_csr.h"
5#include "mbedtls/pem.h"
6#include "mbedtls/oid.h"
7#include "mbedtls/base64.h"
Paul Bakkerb63b0af2011-01-13 17:54:59 +00008
Manuel Pégourié-Gonnard93080df2015-10-23 14:08:48 +02009const mbedtls_x509_crt_profile compat_profile =
10{
11 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) |
12 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_RIPEMD160 ) |
13 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 ) |
14 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) |
15 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) |
16 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA512 ),
17 0xFFFFFFF, /* Any PK alg */
18 0xFFFFFFF, /* Any curve */
19 1024,
20};
21
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +020022int verify_none( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags )
Paul Bakkerb63b0af2011-01-13 17:54:59 +000023{
Paul Bakker5a624082011-01-18 16:31:52 +000024 ((void) data);
25 ((void) crt);
26 ((void) certificate_depth);
Manuel Pégourié-Gonnarde6028c92015-04-20 12:19:02 +010027 *flags |= MBEDTLS_X509_BADCERT_OTHER;
Paul Bakkerddf26b42013-09-18 13:46:23 +020028
Paul Bakker915275b2012-09-28 07:10:55 +000029 return 0;
Paul Bakkerb63b0af2011-01-13 17:54:59 +000030}
31
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +020032int verify_all( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags )
Paul Bakkerb63b0af2011-01-13 17:54:59 +000033{
Paul Bakker5a624082011-01-18 16:31:52 +000034 ((void) data);
35 ((void) crt);
36 ((void) certificate_depth);
Paul Bakker915275b2012-09-28 07:10:55 +000037 *flags = 0;
Paul Bakker5a624082011-01-18 16:31:52 +000038
Paul Bakkerb63b0af2011-01-13 17:54:59 +000039 return 0;
40}
41
Manuel Pégourié-Gonnarde34dcd72015-11-02 06:34:46 +090042/* strsep() not available on Windows */
43char *mystrsep(char **stringp, const char *delim)
44{
45 const char *p;
46 char *ret = *stringp;
47
48 if( *stringp == NULL )
49 return( NULL );
50
51 for( ; ; (*stringp)++ )
52 {
53 if( **stringp == '\0' )
54 {
55 *stringp = NULL;
56 goto done;
57 }
58
59 for( p = delim; *p != '\0'; p++ )
60 if( **stringp == *p )
61 {
62 **stringp = '\0';
63 (*stringp)++;
64 goto done;
65 }
66 }
67
68done:
69 return( ret );
70}
71
Manuel Pégourié-Gonnard560fea32015-09-01 11:59:24 +020072#if defined(MBEDTLS_X509_CRT_PARSE_C)
73typedef struct {
74 char buf[512];
75 char *p;
76} verify_print_context;
77
78void verify_print_init( verify_print_context *ctx )
79{
80 memset( ctx, 0, sizeof( verify_print_context ) );
81 ctx->p = ctx->buf;
82}
83
84int verify_print( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags )
85{
86 int ret;
87 verify_print_context *ctx = (verify_print_context *) data;
88 char *p = ctx->p;
89 size_t n = ctx->buf + sizeof( ctx->buf ) - ctx->p;
90 ((void) flags);
91
92 ret = mbedtls_snprintf( p, n, "depth %d - serial ", certificate_depth );
93 MBEDTLS_X509_SAFE_SNPRINTF;
94
95 ret = mbedtls_x509_serial_gets( p, n, &crt->serial );
96 MBEDTLS_X509_SAFE_SNPRINTF;
97
98 ret = mbedtls_snprintf( p, n, " - subject " );
99 MBEDTLS_X509_SAFE_SNPRINTF;
100
101 ret = mbedtls_x509_dn_gets( p, n, &crt->subject );
102 MBEDTLS_X509_SAFE_SNPRINTF;
103
104 ret = mbedtls_snprintf( p, n, "\n" );
105 MBEDTLS_X509_SAFE_SNPRINTF;
106
107 ctx->p = p;
108
109 return( 0 );
110}
111#endif /* MBEDTLS_X509_CRT_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200112/* END_HEADER */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000113
Paul Bakker33b43f12013-08-20 11:48:36 +0200114/* BEGIN_DEPENDENCIES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200115 * depends_on:MBEDTLS_BIGNUM_C
Paul Bakker33b43f12013-08-20 11:48:36 +0200116 * END_DEPENDENCIES
117 */
Paul Bakker5690efc2011-05-26 13:16:06 +0000118
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200119/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200120void x509_cert_info( char *crt_file, char *result_str )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000121{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200122 mbedtls_x509_crt crt;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000123 char buf[2000];
Paul Bakker69998dd2009-07-11 19:15:20 +0000124 int res;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000125
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200126 mbedtls_x509_crt_init( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000127 memset( buf, 0, 2000 );
128
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200129 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
130 res = mbedtls_x509_crt_info( buf, 2000, "", &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000131
132 TEST_ASSERT( res != -1 );
133 TEST_ASSERT( res != -2 );
134
Paul Bakker33b43f12013-08-20 11:48:36 +0200135 TEST_ASSERT( strcmp( buf, result_str ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200136
137exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200138 mbedtls_x509_crt_free( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000139}
Paul Bakker33b43f12013-08-20 11:48:36 +0200140/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000141
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200142/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRL_PARSE_C */
143void mbedtls_x509_crl_info( char *crl_file, char *result_str )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000144{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200145 mbedtls_x509_crl crl;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000146 char buf[2000];
Paul Bakker69998dd2009-07-11 19:15:20 +0000147 int res;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000148
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200149 mbedtls_x509_crl_init( &crl );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000150 memset( buf, 0, 2000 );
151
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200152 TEST_ASSERT( mbedtls_x509_crl_parse_file( &crl, crl_file ) == 0 );
153 res = mbedtls_x509_crl_info( buf, 2000, "", &crl );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000154
155 TEST_ASSERT( res != -1 );
156 TEST_ASSERT( res != -2 );
157
Paul Bakker33b43f12013-08-20 11:48:36 +0200158 TEST_ASSERT( strcmp( buf, result_str ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200159
160exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200161 mbedtls_x509_crl_free( &crl );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000162}
Paul Bakker33b43f12013-08-20 11:48:36 +0200163/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000164
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200165/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CSR_PARSE_C */
166void mbedtls_x509_csr_info( char *csr_file, char *result_str )
Manuel Pégourié-Gonnard2a8d7fd2014-01-24 17:34:26 +0100167{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200168 mbedtls_x509_csr csr;
Manuel Pégourié-Gonnard2a8d7fd2014-01-24 17:34:26 +0100169 char buf[2000];
170 int res;
171
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200172 mbedtls_x509_csr_init( &csr );
Manuel Pégourié-Gonnard2a8d7fd2014-01-24 17:34:26 +0100173 memset( buf, 0, 2000 );
174
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200175 TEST_ASSERT( mbedtls_x509_csr_parse_file( &csr, csr_file ) == 0 );
176 res = mbedtls_x509_csr_info( buf, 2000, "", &csr );
Manuel Pégourié-Gonnard2a8d7fd2014-01-24 17:34:26 +0100177
Manuel Pégourié-Gonnard2a8d7fd2014-01-24 17:34:26 +0100178 TEST_ASSERT( res != -1 );
179 TEST_ASSERT( res != -2 );
180
181 TEST_ASSERT( strcmp( buf, result_str ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200182
183exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200184 mbedtls_x509_csr_free( &csr );
Manuel Pégourié-Gonnard2a8d7fd2014-01-24 17:34:26 +0100185}
186/* END_CASE */
187
Manuel Pégourié-Gonnardb5f48ad2015-04-20 10:38:13 +0100188/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
189void x509_verify_info( int flags, char *prefix, char *result_str )
190{
191 char buf[2000];
192 int res;
193
194 memset( buf, 0, sizeof( buf ) );
195
196 res = mbedtls_x509_crt_verify_info( buf, sizeof( buf ), prefix, flags );
197
198 TEST_ASSERT( res >= 0 );
199
200 TEST_ASSERT( strcmp( buf, result_str ) == 0 );
201}
202/* END_CASE */
203
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200204/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CRL_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200205void x509_verify( char *crt_file, char *ca_file, char *crl_file,
206 char *cn_name_str, int result, int flags_result,
207 char *verify_callback )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000208{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200209 mbedtls_x509_crt crt;
210 mbedtls_x509_crt ca;
211 mbedtls_x509_crl crl;
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200212 uint32_t flags = 0;
Paul Bakker69998dd2009-07-11 19:15:20 +0000213 int res;
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200214 int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *) = NULL;
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200215 char * cn_name = NULL;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000216
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200217 mbedtls_x509_crt_init( &crt );
218 mbedtls_x509_crt_init( &ca );
219 mbedtls_x509_crl_init( &crl );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000220
Paul Bakker33b43f12013-08-20 11:48:36 +0200221 if( strcmp( cn_name_str, "NULL" ) != 0 )
222 cn_name = cn_name_str;
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200223
Paul Bakker33b43f12013-08-20 11:48:36 +0200224 if( strcmp( verify_callback, "NULL" ) == 0 )
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200225 f_vrfy = NULL;
Paul Bakker33b43f12013-08-20 11:48:36 +0200226 else if( strcmp( verify_callback, "verify_none" ) == 0 )
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200227 f_vrfy = verify_none;
Paul Bakker33b43f12013-08-20 11:48:36 +0200228 else if( strcmp( verify_callback, "verify_all" ) == 0 )
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200229 f_vrfy = verify_all;
230 else
231 TEST_ASSERT( "No known verify callback selected" == 0 );
232
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200233 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
234 TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 );
235 TEST_ASSERT( mbedtls_x509_crl_parse_file( &crl, crl_file ) == 0 );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000236
Manuel Pégourié-Gonnard93080df2015-10-23 14:08:48 +0200237 //puts( "" );
238 res = mbedtls_x509_crt_verify_with_profile( &crt, &ca, &crl, &compat_profile, cn_name, &flags, f_vrfy, NULL );
239
240 //printf( "exp: -%04x, %08x\n", result, flags_result );
241 //printf( "got: -%04x, %08x\n", res, flags );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000242
Paul Bakkerbd51b262014-07-10 15:26:12 +0200243 TEST_ASSERT( res == ( result ) );
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200244 TEST_ASSERT( flags == (uint32_t)( flags_result ) );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200245
246exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200247 mbedtls_x509_crt_free( &crt );
248 mbedtls_x509_crt_free( &ca );
249 mbedtls_x509_crl_free( &crl );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000250}
Paul Bakker33b43f12013-08-20 11:48:36 +0200251/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000252
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200253/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnard560fea32015-09-01 11:59:24 +0200254void x509_verify_callback( char *crt_file, char *ca_file,
255 int exp_ret, char *exp_vrfy_out )
256{
257 int ret;
258 mbedtls_x509_crt crt;
259 mbedtls_x509_crt ca;
260 uint32_t flags = 0;
261 verify_print_context vrfy_ctx;
262
263 mbedtls_x509_crt_init( &crt );
264 mbedtls_x509_crt_init( &ca );
265 verify_print_init( &vrfy_ctx );
266
267 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
268 TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 );
269
270 ret = mbedtls_x509_crt_verify( &crt, &ca, NULL, NULL, &flags,
271 verify_print, &vrfy_ctx );
272
273 TEST_ASSERT( ret == exp_ret );
274 TEST_ASSERT( strcmp( vrfy_ctx.buf, exp_vrfy_out ) == 0 );
275
276exit:
277 mbedtls_x509_crt_free( &crt );
278 mbedtls_x509_crt_free( &ca );
279}
280/* END_CASE */
281
282/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200283void mbedtls_x509_dn_gets( char *crt_file, char *entity, char *result_str )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000284{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285 mbedtls_x509_crt crt;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000286 char buf[2000];
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200287 int res = 0;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000288
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200289 mbedtls_x509_crt_init( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000290 memset( buf, 0, 2000 );
291
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200292 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Paul Bakker33b43f12013-08-20 11:48:36 +0200293 if( strcmp( entity, "subject" ) == 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200294 res = mbedtls_x509_dn_gets( buf, 2000, &crt.subject );
Paul Bakker33b43f12013-08-20 11:48:36 +0200295 else if( strcmp( entity, "issuer" ) == 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200296 res = mbedtls_x509_dn_gets( buf, 2000, &crt.issuer );
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200297 else
298 TEST_ASSERT( "Unknown entity" == 0 );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000299
300 TEST_ASSERT( res != -1 );
301 TEST_ASSERT( res != -2 );
302
Paul Bakker33b43f12013-08-20 11:48:36 +0200303 TEST_ASSERT( strcmp( buf, result_str ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200304
305exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200306 mbedtls_x509_crt_free( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000307}
Paul Bakker33b43f12013-08-20 11:48:36 +0200308/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000309
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100311void mbedtls_x509_time_is_past( char *crt_file, char *entity, int result )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000312{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200313 mbedtls_x509_crt crt;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000314
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200315 mbedtls_x509_crt_init( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000316
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200317 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200318
Paul Bakker33b43f12013-08-20 11:48:36 +0200319 if( strcmp( entity, "valid_from" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100320 TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_from ) == result );
Paul Bakker33b43f12013-08-20 11:48:36 +0200321 else if( strcmp( entity, "valid_to" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100322 TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_to ) == result );
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200323 else
324 TEST_ASSERT( "Unknown entity" == 0 );
Paul Bakkerb08e6842012-02-11 18:43:20 +0000325
Paul Bakkerbd51b262014-07-10 15:26:12 +0200326exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200327 mbedtls_x509_crt_free( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000328}
Paul Bakker33b43f12013-08-20 11:48:36 +0200329/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000330
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200331/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100332void mbedtls_x509_time_is_future( char *crt_file, char *entity, int result )
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100333{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200334 mbedtls_x509_crt crt;
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100335
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200336 mbedtls_x509_crt_init( &crt );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100337
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200338 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100339
340 if( strcmp( entity, "valid_from" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100341 TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_from ) == result );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100342 else if( strcmp( entity, "valid_to" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100343 TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_to ) == result );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100344 else
345 TEST_ASSERT( "Unknown entity" == 0 );
346
Paul Bakkerbd51b262014-07-10 15:26:12 +0200347exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200348 mbedtls_x509_crt_free( &crt );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100349}
350/* END_CASE */
351
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200352/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_FS_IO */
Paul Bakker5a5fa922014-09-26 14:53:04 +0200353void x509parse_crt_file( char *crt_file, int result )
354{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200355 mbedtls_x509_crt crt;
Paul Bakker5a5fa922014-09-26 14:53:04 +0200356
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200357 mbedtls_x509_crt_init( &crt );
Paul Bakker5a5fa922014-09-26 14:53:04 +0200358
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200359 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == result );
Paul Bakker5a5fa922014-09-26 14:53:04 +0200360
361exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200362 mbedtls_x509_crt_free( &crt );
Paul Bakker5a5fa922014-09-26 14:53:04 +0200363}
364/* END_CASE */
365
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200366/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200367void x509parse_crt( char *crt_data, char *result_str, int result )
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000368{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200369 mbedtls_x509_crt crt;
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000370 unsigned char buf[2000];
371 unsigned char output[2000];
372 int data_len, res;
373
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200374 mbedtls_x509_crt_init( &crt );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000375 memset( buf, 0, 2000 );
376 memset( output, 0, 2000 );
377
Paul Bakker33b43f12013-08-20 11:48:36 +0200378 data_len = unhexify( buf, crt_data );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000379
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200380 TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf, data_len ) == ( result ) );
Paul Bakker33b43f12013-08-20 11:48:36 +0200381 if( ( result ) == 0 )
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000382 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200383 res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
Paul Bakker33b43f12013-08-20 11:48:36 +0200384
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000385 TEST_ASSERT( res != -1 );
386 TEST_ASSERT( res != -2 );
387
Paul Bakker33b43f12013-08-20 11:48:36 +0200388 TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000389 }
Paul Bakkerb08e6842012-02-11 18:43:20 +0000390
Paul Bakkerbd51b262014-07-10 15:26:12 +0200391exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200392 mbedtls_x509_crt_free( &crt );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000393}
Paul Bakker33b43f12013-08-20 11:48:36 +0200394/* END_CASE */
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000395
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200396/* BEGIN_CASE depends_on:MBEDTLS_X509_CRL_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200397void x509parse_crl( char *crl_data, char *result_str, int result )
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000398{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200399 mbedtls_x509_crl crl;
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000400 unsigned char buf[2000];
401 unsigned char output[2000];
402 int data_len, res;
403
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200404 mbedtls_x509_crl_init( &crl );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000405 memset( buf, 0, 2000 );
406 memset( output, 0, 2000 );
407
Paul Bakker33b43f12013-08-20 11:48:36 +0200408 data_len = unhexify( buf, crl_data );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000409
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200410 TEST_ASSERT( mbedtls_x509_crl_parse( &crl, buf, data_len ) == ( result ) );
Paul Bakker33b43f12013-08-20 11:48:36 +0200411 if( ( result ) == 0 )
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000412 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200413 res = mbedtls_x509_crl_info( (char *) output, 2000, "", &crl );
Paul Bakker33b43f12013-08-20 11:48:36 +0200414
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000415 TEST_ASSERT( res != -1 );
416 TEST_ASSERT( res != -2 );
417
Paul Bakker33b43f12013-08-20 11:48:36 +0200418 TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000419 }
Paul Bakkerb08e6842012-02-11 18:43:20 +0000420
Paul Bakkerbd51b262014-07-10 15:26:12 +0200421exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200422 mbedtls_x509_crl_free( &crl );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000423}
Paul Bakker33b43f12013-08-20 11:48:36 +0200424/* END_CASE */
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000425
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200426/* BEGIN_CASE depends_on:MBEDTLS_X509_CSR_PARSE_C */
427void mbedtls_x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret )
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200428{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200429 mbedtls_x509_csr csr;
Paul Bakkerbd51b262014-07-10 15:26:12 +0200430 unsigned char *csr_der = NULL;
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200431 char my_out[1000];
432 size_t csr_der_len;
433 int my_ret;
434
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200435 mbedtls_x509_csr_init( &csr );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200436 memset( my_out, 0, sizeof( my_out ) );
437 csr_der = unhexify_alloc( csr_der_hex, &csr_der_len );
438
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200439 my_ret = mbedtls_x509_csr_parse_der( &csr, csr_der, csr_der_len );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200440 TEST_ASSERT( my_ret == ref_ret );
441
442 if( ref_ret == 0 )
443 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200444 size_t my_out_len = mbedtls_x509_csr_info( my_out, sizeof( my_out ), "", &csr );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200445 TEST_ASSERT( my_out_len == strlen( ref_out ) );
446 TEST_ASSERT( strcmp( my_out, ref_out ) == 0 );
447 }
448
Paul Bakkerbd51b262014-07-10 15:26:12 +0200449exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200450 mbedtls_x509_csr_free( &csr );
451 mbedtls_free( csr_der );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200452}
453/* END_CASE */
454
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200455/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
456void mbedtls_x509_crt_parse_path( char *crt_path, int ret, int nb_crt )
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100457{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200458 mbedtls_x509_crt chain, *cur;
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100459 int i;
460
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200461 mbedtls_x509_crt_init( &chain );
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100462
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200463 TEST_ASSERT( mbedtls_x509_crt_parse_path( &chain, crt_path ) == ret );
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100464
465 /* Check how many certs we got */
466 for( i = 0, cur = &chain; cur != NULL; cur = cur->next )
467 if( cur->raw.p != NULL )
468 i++;
469
470 TEST_ASSERT( i == nb_crt );
471
Paul Bakkerbd51b262014-07-10 15:26:12 +0200472exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200473 mbedtls_x509_crt_free( &chain );
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100474}
475/* END_CASE */
476
Janos Follathc7bea312015-10-11 10:25:22 +0200477/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Janos Follath36f12342015-10-11 16:17:27 +0200478void mbedtls_x509_crt_verify_chain( char *chain_paths, char *trusted_ca, int flags_result )
Janos Follathc7bea312015-10-11 10:25:22 +0200479{
480 char* act;
481 uint32_t flags;
Janos Follath36f12342015-10-11 16:17:27 +0200482 int result, res;
Manuel Pégourié-Gonnardfd1f9e72015-10-30 09:23:19 +0100483 mbedtls_x509_crt trusted, chain;
Janos Follathc7bea312015-10-11 10:25:22 +0200484
Janos Follath36f12342015-10-11 16:17:27 +0200485 result= flags_result?MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:0;
486
Janos Follathc7bea312015-10-11 10:25:22 +0200487 mbedtls_x509_crt_init( &chain );
488 mbedtls_x509_crt_init( &trusted );
489
Manuel Pégourié-Gonnarde34dcd72015-11-02 06:34:46 +0900490 while( ( act = mystrsep( &chain_paths, " " ) ) != NULL )
Manuel Pégourié-Gonnardfd1f9e72015-10-30 09:23:19 +0100491 TEST_ASSERT( mbedtls_x509_crt_parse_file( &chain, act ) == 0 );
492 TEST_ASSERT( mbedtls_x509_crt_parse_file( &trusted, trusted_ca ) == 0 );
Janos Follathc7bea312015-10-11 10:25:22 +0200493
494 res = mbedtls_x509_crt_verify( &chain, &trusted, NULL, NULL, &flags, NULL, NULL );
Janos Follath36f12342015-10-11 16:17:27 +0200495
496 TEST_ASSERT( res == ( result ) );
497 TEST_ASSERT( flags == (uint32_t)( flags_result ) );
Janos Follathc7bea312015-10-11 10:25:22 +0200498
499exit:
500 mbedtls_x509_crt_free( &trusted );
501 mbedtls_x509_crt_free( &chain );
502}
503/* END_CASE */
504
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200505/* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100506void x509_oid_desc( char *oid_str, char *ref_desc )
507{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200508 mbedtls_x509_buf oid;
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000509 const char *desc = NULL;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100510 unsigned char buf[20];
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000511 int ret;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100512
513 memset( buf, 0, sizeof buf );
514
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200515 oid.tag = MBEDTLS_ASN1_OID;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100516 oid.len = unhexify( buf, oid_str );
517 oid.p = buf;
518
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200519 ret = mbedtls_oid_get_extended_key_usage( &oid, &desc );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100520
521 if( strcmp( ref_desc, "notfound" ) == 0 )
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000522 {
523 TEST_ASSERT( ret != 0 );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100524 TEST_ASSERT( desc == NULL );
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000525 }
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100526 else
527 {
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000528 TEST_ASSERT( ret == 0 );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100529 TEST_ASSERT( desc != NULL );
530 TEST_ASSERT( strcmp( desc, ref_desc ) == 0 );
531 }
532}
533/* END_CASE */
534
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200535/* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100536void x509_oid_numstr( char *oid_str, char *numstr, int blen, int ret )
537{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200538 mbedtls_x509_buf oid;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100539 unsigned char oid_buf[20];
540 char num_buf[100];
541
542 memset( oid_buf, 0x00, sizeof oid_buf );
543 memset( num_buf, 0x2a, sizeof num_buf );
544
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200545 oid.tag = MBEDTLS_ASN1_OID;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100546 oid.len = unhexify( oid_buf, oid_str );
547 oid.p = oid_buf;
548
549 TEST_ASSERT( (size_t) blen <= sizeof num_buf );
550
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200551 TEST_ASSERT( mbedtls_oid_get_numeric_string( num_buf, blen, &oid ) == ret );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100552
553 if( ret >= 0 )
554 {
555 TEST_ASSERT( num_buf[ret] == 0 );
556 TEST_ASSERT( strcmp( num_buf, numstr ) == 0 );
557 }
558}
559/* END_CASE */
560
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200561/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CHECK_KEY_USAGE */
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200562void x509_check_key_usage( char *crt_file, int usage, int ret )
563{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200564 mbedtls_x509_crt crt;
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200565
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200566 mbedtls_x509_crt_init( &crt );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200567
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200568 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200569
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200570 TEST_ASSERT( mbedtls_x509_crt_check_key_usage( &crt, usage ) == ret );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200571
Paul Bakkerbd51b262014-07-10 15:26:12 +0200572exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200573 mbedtls_x509_crt_free( &crt );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200574}
575/* END_CASE */
576
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200577/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200578void x509_check_extended_key_usage( char *crt_file, char *usage_hex, int ret )
579{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200580 mbedtls_x509_crt crt;
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200581 char oid[50];
582 size_t len;
583
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200584 mbedtls_x509_crt_init( &crt );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200585
586 len = unhexify( (unsigned char *) oid, usage_hex );
587
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200588 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200589
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200590 TEST_ASSERT( mbedtls_x509_crt_check_extended_key_usage( &crt, oid, len ) == ret );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200591
Paul Bakkerbd51b262014-07-10 15:26:12 +0200592exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200593 mbedtls_x509_crt_free( &crt );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200594}
595/* END_CASE */
596
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200597/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT */
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200598void x509_parse_rsassa_pss_params( char *hex_params, int params_tag,
599 int ref_msg_md, int ref_mgf_md,
600 int ref_salt_len, int ref_ret )
601{
602 int my_ret;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200603 mbedtls_x509_buf params;
604 mbedtls_md_type_t my_msg_md, my_mgf_md;
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200605 int my_salt_len;
606
607 params.p = unhexify_alloc( hex_params, &params.len );
608 params.tag = params_tag;
609
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200610 my_ret = mbedtls_x509_get_rsassa_pss_params( &params, &my_msg_md, &my_mgf_md,
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200611 &my_salt_len );
612
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200613 TEST_ASSERT( my_ret == ref_ret );
614
615 if( ref_ret == 0 )
616 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200617 TEST_ASSERT( my_msg_md == (mbedtls_md_type_t) ref_msg_md );
618 TEST_ASSERT( my_mgf_md == (mbedtls_md_type_t) ref_mgf_md );
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200619 TEST_ASSERT( my_salt_len == ref_salt_len );
620 }
621
Paul Bakkerbd51b262014-07-10 15:26:12 +0200622exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200623 mbedtls_free( params.p );
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200624}
625/* END_CASE */
626
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200627/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_SELF_TEST */
Paul Bakker33b43f12013-08-20 11:48:36 +0200628void x509_selftest()
Paul Bakker37940d9f2009-07-10 22:38:58 +0000629{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200630 TEST_ASSERT( mbedtls_x509_self_test( 0 ) == 0 );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000631}
Paul Bakker33b43f12013-08-20 11:48:36 +0200632/* END_CASE */