blob: 2affab79b5d68b13ac0b86215f6c0fb22af815b7 [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é-Gonnard65eefc82015-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é-Gonnarda8838af2015-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é-Gonnard65eefc82015-10-23 14:08:48 +0200237 res = mbedtls_x509_crt_verify_with_profile( &crt, &ca, &crl, &compat_profile, cn_name, &flags, f_vrfy, NULL );
238
Paul Bakkerbd51b262014-07-10 15:26:12 +0200239 TEST_ASSERT( res == ( result ) );
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200240 TEST_ASSERT( flags == (uint32_t)( flags_result ) );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200241
242exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200243 mbedtls_x509_crt_free( &crt );
244 mbedtls_x509_crt_free( &ca );
245 mbedtls_x509_crl_free( &crl );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000246}
Paul Bakker33b43f12013-08-20 11:48:36 +0200247/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000248
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200249/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnard560fea32015-09-01 11:59:24 +0200250void x509_verify_callback( char *crt_file, char *ca_file,
251 int exp_ret, char *exp_vrfy_out )
252{
253 int ret;
254 mbedtls_x509_crt crt;
255 mbedtls_x509_crt ca;
256 uint32_t flags = 0;
257 verify_print_context vrfy_ctx;
258
259 mbedtls_x509_crt_init( &crt );
260 mbedtls_x509_crt_init( &ca );
261 verify_print_init( &vrfy_ctx );
262
263 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
264 TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 );
265
266 ret = mbedtls_x509_crt_verify( &crt, &ca, NULL, NULL, &flags,
267 verify_print, &vrfy_ctx );
268
269 TEST_ASSERT( ret == exp_ret );
270 TEST_ASSERT( strcmp( vrfy_ctx.buf, exp_vrfy_out ) == 0 );
271
272exit:
273 mbedtls_x509_crt_free( &crt );
274 mbedtls_x509_crt_free( &ca );
275}
276/* END_CASE */
277
278/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200279void mbedtls_x509_dn_gets( char *crt_file, char *entity, char *result_str )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000280{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200281 mbedtls_x509_crt crt;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000282 char buf[2000];
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200283 int res = 0;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000284
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285 mbedtls_x509_crt_init( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000286 memset( buf, 0, 2000 );
287
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200288 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Paul Bakker33b43f12013-08-20 11:48:36 +0200289 if( strcmp( entity, "subject" ) == 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200290 res = mbedtls_x509_dn_gets( buf, 2000, &crt.subject );
Paul Bakker33b43f12013-08-20 11:48:36 +0200291 else if( strcmp( entity, "issuer" ) == 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200292 res = mbedtls_x509_dn_gets( buf, 2000, &crt.issuer );
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200293 else
294 TEST_ASSERT( "Unknown entity" == 0 );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000295
296 TEST_ASSERT( res != -1 );
297 TEST_ASSERT( res != -2 );
298
Paul Bakker33b43f12013-08-20 11:48:36 +0200299 TEST_ASSERT( strcmp( buf, result_str ) == 0 );
Paul Bakkerbd51b262014-07-10 15:26:12 +0200300
301exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200302 mbedtls_x509_crt_free( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000303}
Paul Bakker33b43f12013-08-20 11:48:36 +0200304/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000305
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200306/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100307void mbedtls_x509_time_is_past( char *crt_file, char *entity, int result )
Paul Bakker37940d9f2009-07-10 22:38:58 +0000308{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200309 mbedtls_x509_crt crt;
Paul Bakker37940d9f2009-07-10 22:38:58 +0000310
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200311 mbedtls_x509_crt_init( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000312
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200313 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200314
Paul Bakker33b43f12013-08-20 11:48:36 +0200315 if( strcmp( entity, "valid_from" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100316 TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_from ) == result );
Paul Bakker33b43f12013-08-20 11:48:36 +0200317 else if( strcmp( entity, "valid_to" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100318 TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_to ) == result );
Paul Bakkerdbd443d2013-08-16 13:38:47 +0200319 else
320 TEST_ASSERT( "Unknown entity" == 0 );
Paul Bakkerb08e6842012-02-11 18:43:20 +0000321
Paul Bakkerbd51b262014-07-10 15:26:12 +0200322exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200323 mbedtls_x509_crt_free( &crt );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000324}
Paul Bakker33b43f12013-08-20 11:48:36 +0200325/* END_CASE */
Paul Bakker37940d9f2009-07-10 22:38:58 +0000326
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200327/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100328void mbedtls_x509_time_is_future( char *crt_file, char *entity, int result )
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100329{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200330 mbedtls_x509_crt crt;
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100331
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200332 mbedtls_x509_crt_init( &crt );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100333
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200334 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100335
336 if( strcmp( entity, "valid_from" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100337 TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_from ) == result );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100338 else if( strcmp( entity, "valid_to" ) == 0 )
Manuel Pégourié-Gonnardc730ed32015-06-02 10:38:50 +0100339 TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_to ) == result );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100340 else
341 TEST_ASSERT( "Unknown entity" == 0 );
342
Paul Bakkerbd51b262014-07-10 15:26:12 +0200343exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200344 mbedtls_x509_crt_free( &crt );
Manuel Pégourié-Gonnard6304f782014-03-10 12:26:11 +0100345}
346/* END_CASE */
347
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200348/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_FS_IO */
Paul Bakker5a5fa922014-09-26 14:53:04 +0200349void x509parse_crt_file( char *crt_file, int result )
350{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200351 mbedtls_x509_crt crt;
Paul Bakker5a5fa922014-09-26 14:53:04 +0200352
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200353 mbedtls_x509_crt_init( &crt );
Paul Bakker5a5fa922014-09-26 14:53:04 +0200354
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200355 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == result );
Paul Bakker5a5fa922014-09-26 14:53:04 +0200356
357exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200358 mbedtls_x509_crt_free( &crt );
Paul Bakker5a5fa922014-09-26 14:53:04 +0200359}
360/* END_CASE */
361
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200362/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200363void x509parse_crt( char *crt_data, char *result_str, int result )
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000364{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200365 mbedtls_x509_crt crt;
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000366 unsigned char buf[2000];
367 unsigned char output[2000];
368 int data_len, res;
369
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200370 mbedtls_x509_crt_init( &crt );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000371 memset( buf, 0, 2000 );
372 memset( output, 0, 2000 );
373
Paul Bakker33b43f12013-08-20 11:48:36 +0200374 data_len = unhexify( buf, crt_data );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000375
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200376 TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf, data_len ) == ( result ) );
Paul Bakker33b43f12013-08-20 11:48:36 +0200377 if( ( result ) == 0 )
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000378 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200379 res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
Paul Bakker33b43f12013-08-20 11:48:36 +0200380
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000381 TEST_ASSERT( res != -1 );
382 TEST_ASSERT( res != -2 );
383
Paul Bakker33b43f12013-08-20 11:48:36 +0200384 TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000385 }
Paul Bakkerb08e6842012-02-11 18:43:20 +0000386
Paul Bakkerbd51b262014-07-10 15:26:12 +0200387exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200388 mbedtls_x509_crt_free( &crt );
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000389}
Paul Bakker33b43f12013-08-20 11:48:36 +0200390/* END_CASE */
Paul Bakkerb2c38f52009-07-19 19:36:15 +0000391
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200392/* BEGIN_CASE depends_on:MBEDTLS_X509_CRL_PARSE_C */
Paul Bakker33b43f12013-08-20 11:48:36 +0200393void x509parse_crl( char *crl_data, char *result_str, int result )
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000394{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200395 mbedtls_x509_crl crl;
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000396 unsigned char buf[2000];
397 unsigned char output[2000];
398 int data_len, res;
399
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200400 mbedtls_x509_crl_init( &crl );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000401 memset( buf, 0, 2000 );
402 memset( output, 0, 2000 );
403
Paul Bakker33b43f12013-08-20 11:48:36 +0200404 data_len = unhexify( buf, crl_data );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000405
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200406 TEST_ASSERT( mbedtls_x509_crl_parse( &crl, buf, data_len ) == ( result ) );
Paul Bakker33b43f12013-08-20 11:48:36 +0200407 if( ( result ) == 0 )
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000408 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200409 res = mbedtls_x509_crl_info( (char *) output, 2000, "", &crl );
Paul Bakker33b43f12013-08-20 11:48:36 +0200410
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000411 TEST_ASSERT( res != -1 );
412 TEST_ASSERT( res != -2 );
413
Paul Bakker33b43f12013-08-20 11:48:36 +0200414 TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000415 }
Paul Bakkerb08e6842012-02-11 18:43:20 +0000416
Paul Bakkerbd51b262014-07-10 15:26:12 +0200417exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200418 mbedtls_x509_crl_free( &crl );
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000419}
Paul Bakker33b43f12013-08-20 11:48:36 +0200420/* END_CASE */
Paul Bakker6b0fa4f2009-07-20 20:35:41 +0000421
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200422/* BEGIN_CASE depends_on:MBEDTLS_X509_CSR_PARSE_C */
423void mbedtls_x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret )
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200424{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200425 mbedtls_x509_csr csr;
Paul Bakkerbd51b262014-07-10 15:26:12 +0200426 unsigned char *csr_der = NULL;
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200427 char my_out[1000];
428 size_t csr_der_len;
429 int my_ret;
430
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200431 mbedtls_x509_csr_init( &csr );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200432 memset( my_out, 0, sizeof( my_out ) );
433 csr_der = unhexify_alloc( csr_der_hex, &csr_der_len );
434
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200435 my_ret = mbedtls_x509_csr_parse_der( &csr, csr_der, csr_der_len );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200436 TEST_ASSERT( my_ret == ref_ret );
437
438 if( ref_ret == 0 )
439 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200440 size_t my_out_len = mbedtls_x509_csr_info( my_out, sizeof( my_out ), "", &csr );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200441 TEST_ASSERT( my_out_len == strlen( ref_out ) );
442 TEST_ASSERT( strcmp( my_out, ref_out ) == 0 );
443 }
444
Paul Bakkerbd51b262014-07-10 15:26:12 +0200445exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200446 mbedtls_x509_csr_free( &csr );
447 mbedtls_free( csr_der );
Manuel Pégourié-Gonnardd77cd5d2014-06-13 11:13:15 +0200448}
449/* END_CASE */
450
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200451/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
452void mbedtls_x509_crt_parse_path( char *crt_path, int ret, int nb_crt )
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100453{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200454 mbedtls_x509_crt chain, *cur;
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100455 int i;
456
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200457 mbedtls_x509_crt_init( &chain );
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100458
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200459 TEST_ASSERT( mbedtls_x509_crt_parse_path( &chain, crt_path ) == ret );
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100460
461 /* Check how many certs we got */
462 for( i = 0, cur = &chain; cur != NULL; cur = cur->next )
463 if( cur->raw.p != NULL )
464 i++;
465
466 TEST_ASSERT( i == nb_crt );
467
Paul Bakkerbd51b262014-07-10 15:26:12 +0200468exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200469 mbedtls_x509_crt_free( &chain );
Manuel Pégourié-Gonnardfbae2a12013-11-26 16:43:39 +0100470}
471/* END_CASE */
472
Janos Follath822b2c32015-10-11 10:25:22 +0200473/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
Janos Follathef4f2582015-10-11 16:17:27 +0200474void mbedtls_x509_crt_verify_chain( char *chain_paths, char *trusted_ca, int flags_result )
Janos Follath822b2c32015-10-11 10:25:22 +0200475{
476 char* act;
477 uint32_t flags;
Janos Follathef4f2582015-10-11 16:17:27 +0200478 int result, res;
Manuel Pégourié-Gonnarde670f902015-10-30 09:23:19 +0100479 mbedtls_x509_crt trusted, chain;
Janos Follath822b2c32015-10-11 10:25:22 +0200480
Janos Follathef4f2582015-10-11 16:17:27 +0200481 result= flags_result?MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:0;
482
Janos Follath822b2c32015-10-11 10:25:22 +0200483 mbedtls_x509_crt_init( &chain );
484 mbedtls_x509_crt_init( &trusted );
485
Manuel Pégourié-Gonnarda8838af2015-11-02 06:34:46 +0900486 while( ( act = mystrsep( &chain_paths, " " ) ) != NULL )
Manuel Pégourié-Gonnarde670f902015-10-30 09:23:19 +0100487 TEST_ASSERT( mbedtls_x509_crt_parse_file( &chain, act ) == 0 );
488 TEST_ASSERT( mbedtls_x509_crt_parse_file( &trusted, trusted_ca ) == 0 );
Janos Follath822b2c32015-10-11 10:25:22 +0200489
490 res = mbedtls_x509_crt_verify( &chain, &trusted, NULL, NULL, &flags, NULL, NULL );
Janos Follathef4f2582015-10-11 16:17:27 +0200491
492 TEST_ASSERT( res == ( result ) );
493 TEST_ASSERT( flags == (uint32_t)( flags_result ) );
Janos Follath822b2c32015-10-11 10:25:22 +0200494
495exit:
496 mbedtls_x509_crt_free( &trusted );
497 mbedtls_x509_crt_free( &chain );
498}
499/* END_CASE */
500
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200501/* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100502void x509_oid_desc( char *oid_str, char *ref_desc )
503{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200504 mbedtls_x509_buf oid;
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000505 const char *desc = NULL;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100506 unsigned char buf[20];
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000507 int ret;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100508
509 memset( buf, 0, sizeof buf );
510
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200511 oid.tag = MBEDTLS_ASN1_OID;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100512 oid.len = unhexify( buf, oid_str );
513 oid.p = buf;
514
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200515 ret = mbedtls_oid_get_extended_key_usage( &oid, &desc );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100516
517 if( strcmp( ref_desc, "notfound" ) == 0 )
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000518 {
519 TEST_ASSERT( ret != 0 );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100520 TEST_ASSERT( desc == NULL );
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000521 }
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100522 else
523 {
Manuel Pégourié-Gonnard48d3cef2015-03-20 18:14:26 +0000524 TEST_ASSERT( ret == 0 );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100525 TEST_ASSERT( desc != NULL );
526 TEST_ASSERT( strcmp( desc, ref_desc ) == 0 );
527 }
528}
529/* END_CASE */
530
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200531/* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100532void x509_oid_numstr( char *oid_str, char *numstr, int blen, int ret )
533{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200534 mbedtls_x509_buf oid;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100535 unsigned char oid_buf[20];
536 char num_buf[100];
537
538 memset( oid_buf, 0x00, sizeof oid_buf );
539 memset( num_buf, 0x2a, sizeof num_buf );
540
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200541 oid.tag = MBEDTLS_ASN1_OID;
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100542 oid.len = unhexify( oid_buf, oid_str );
543 oid.p = oid_buf;
544
545 TEST_ASSERT( (size_t) blen <= sizeof num_buf );
546
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200547 TEST_ASSERT( mbedtls_oid_get_numeric_string( num_buf, blen, &oid ) == ret );
Manuel Pégourié-Gonnard7afdb882014-03-28 16:06:35 +0100548
549 if( ret >= 0 )
550 {
551 TEST_ASSERT( num_buf[ret] == 0 );
552 TEST_ASSERT( strcmp( num_buf, numstr ) == 0 );
553 }
554}
555/* END_CASE */
556
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200557/* 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 +0200558void x509_check_key_usage( char *crt_file, int usage, int ret )
559{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200560 mbedtls_x509_crt crt;
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200561
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200562 mbedtls_x509_crt_init( &crt );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200563
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200564 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200565
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200566 TEST_ASSERT( mbedtls_x509_crt_check_key_usage( &crt, usage ) == ret );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200567
Paul Bakkerbd51b262014-07-10 15:26:12 +0200568exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200569 mbedtls_x509_crt_free( &crt );
Manuel Pégourié-Gonnard603116c2014-04-09 09:50:03 +0200570}
571/* END_CASE */
572
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200573/* 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 +0200574void x509_check_extended_key_usage( char *crt_file, char *usage_hex, int ret )
575{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200576 mbedtls_x509_crt crt;
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200577 char oid[50];
578 size_t len;
579
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200580 mbedtls_x509_crt_init( &crt );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200581
582 len = unhexify( (unsigned char *) oid, usage_hex );
583
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200584 TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200585
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200586 TEST_ASSERT( mbedtls_x509_crt_check_extended_key_usage( &crt, oid, len ) == ret );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200587
Paul Bakkerbd51b262014-07-10 15:26:12 +0200588exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200589 mbedtls_x509_crt_free( &crt );
Manuel Pégourié-Gonnard7afb8a02014-04-10 17:53:56 +0200590}
591/* END_CASE */
592
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200593/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT */
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200594void x509_parse_rsassa_pss_params( char *hex_params, int params_tag,
595 int ref_msg_md, int ref_mgf_md,
596 int ref_salt_len, int ref_ret )
597{
598 int my_ret;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200599 mbedtls_x509_buf params;
600 mbedtls_md_type_t my_msg_md, my_mgf_md;
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200601 int my_salt_len;
602
603 params.p = unhexify_alloc( hex_params, &params.len );
604 params.tag = params_tag;
605
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200606 my_ret = mbedtls_x509_get_rsassa_pss_params( &params, &my_msg_md, &my_mgf_md,
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200607 &my_salt_len );
608
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200609 TEST_ASSERT( my_ret == ref_ret );
610
611 if( ref_ret == 0 )
612 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200613 TEST_ASSERT( my_msg_md == (mbedtls_md_type_t) ref_msg_md );
614 TEST_ASSERT( my_mgf_md == (mbedtls_md_type_t) ref_mgf_md );
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200615 TEST_ASSERT( my_salt_len == ref_salt_len );
616 }
617
Paul Bakkerbd51b262014-07-10 15:26:12 +0200618exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200619 mbedtls_free( params.p );
Manuel Pégourié-Gonnard85403692014-06-06 14:48:38 +0200620}
621/* END_CASE */
622
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200623/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_SELF_TEST */
Paul Bakker33b43f12013-08-20 11:48:36 +0200624void x509_selftest()
Paul Bakker37940d9f2009-07-10 22:38:58 +0000625{
Andres AG93012e82016-09-09 09:10:28 +0100626 TEST_ASSERT( mbedtls_x509_self_test( 1 ) == 0 );
Paul Bakker37940d9f2009-07-10 22:38:58 +0000627}
Paul Bakker33b43f12013-08-20 11:48:36 +0200628/* END_CASE */