Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 1 | /* BEGIN_HEADER */ |
Rich Evans | ce2f237 | 2015-02-06 13:57:42 +0000 | [diff] [blame] | 2 | #include "polarssl/x509_crt.h" |
| 3 | #include "polarssl/x509_crl.h" |
| 4 | #include "polarssl/x509_csr.h" |
| 5 | #include "polarssl/pem.h" |
| 6 | #include "polarssl/oid.h" |
| 7 | #include "polarssl/base64.h" |
Paul Bakker | b63b0af | 2011-01-13 17:54:59 +0000 | [diff] [blame] | 8 | |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 9 | int verify_none( void *data, x509_crt *crt, int certificate_depth, int *flags ) |
Paul Bakker | b63b0af | 2011-01-13 17:54:59 +0000 | [diff] [blame] | 10 | { |
Paul Bakker | 5a62408 | 2011-01-18 16:31:52 +0000 | [diff] [blame] | 11 | ((void) data); |
| 12 | ((void) crt); |
| 13 | ((void) certificate_depth); |
Paul Bakker | 915275b | 2012-09-28 07:10:55 +0000 | [diff] [blame] | 14 | *flags |= BADCERT_OTHER; |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 15 | |
Paul Bakker | 915275b | 2012-09-28 07:10:55 +0000 | [diff] [blame] | 16 | return 0; |
Paul Bakker | b63b0af | 2011-01-13 17:54:59 +0000 | [diff] [blame] | 17 | } |
| 18 | |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 19 | int verify_all( void *data, x509_crt *crt, int certificate_depth, int *flags ) |
Paul Bakker | b63b0af | 2011-01-13 17:54:59 +0000 | [diff] [blame] | 20 | { |
Paul Bakker | 5a62408 | 2011-01-18 16:31:52 +0000 | [diff] [blame] | 21 | ((void) data); |
| 22 | ((void) crt); |
| 23 | ((void) certificate_depth); |
Paul Bakker | 915275b | 2012-09-28 07:10:55 +0000 | [diff] [blame] | 24 | *flags = 0; |
Paul Bakker | 5a62408 | 2011-01-18 16:31:52 +0000 | [diff] [blame] | 25 | |
Paul Bakker | b63b0af | 2011-01-13 17:54:59 +0000 | [diff] [blame] | 26 | return 0; |
| 27 | } |
| 28 | |
Manuel Pégourié-Gonnard | 15f1088 | 2015-09-01 11:59:24 +0200 | [diff] [blame] | 29 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
| 30 | typedef struct { |
| 31 | char buf[512]; |
| 32 | char *p; |
| 33 | } verify_print_context; |
| 34 | |
| 35 | void verify_print_init( verify_print_context *ctx ) |
| 36 | { |
| 37 | memset( ctx, 0, sizeof( verify_print_context ) ); |
| 38 | ctx->p = ctx->buf; |
| 39 | } |
| 40 | |
| 41 | #if defined(_MSC_VER) && !defined snprintf |
| 42 | #define snprintf _snprintf |
| 43 | #endif |
| 44 | |
| 45 | #define SAFE_SNPRINTF \ |
| 46 | do \ |
| 47 | { \ |
| 48 | if( ret < 0 || (size_t) ret > n ) \ |
| 49 | { \ |
| 50 | p[n - 1] = '\0'; \ |
| 51 | return( -1 ); \ |
| 52 | } \ |
| 53 | \ |
| 54 | n -= (unsigned int) ret; \ |
| 55 | p += (unsigned int) ret; \ |
| 56 | } while( 0 ) |
| 57 | |
| 58 | int verify_print( void *data, x509_crt *crt, int certificate_depth, int *flags ) |
| 59 | { |
| 60 | int ret; |
| 61 | verify_print_context *ctx = (verify_print_context *) data; |
| 62 | char *p = ctx->p; |
| 63 | size_t n = ctx->buf + sizeof( ctx->buf ) - ctx->p; |
| 64 | ((void) flags); |
| 65 | |
| 66 | ret = polarssl_snprintf( p, n, "depth %d - serial ", certificate_depth ); |
| 67 | SAFE_SNPRINTF; |
| 68 | |
| 69 | ret = x509_serial_gets( p, n, &crt->serial ); |
| 70 | SAFE_SNPRINTF; |
| 71 | |
| 72 | ret = polarssl_snprintf( p, n, " - subject " ); |
| 73 | SAFE_SNPRINTF; |
| 74 | |
| 75 | ret = x509_dn_gets( p, n, &crt->subject ); |
| 76 | SAFE_SNPRINTF; |
| 77 | |
| 78 | ret = polarssl_snprintf( p, n, "\n" ); |
| 79 | SAFE_SNPRINTF; |
| 80 | |
| 81 | ctx->p = p; |
| 82 | |
| 83 | return( 0 ); |
| 84 | } |
| 85 | #endif /* POLARSSL_X509_CRT_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 86 | /* END_HEADER */ |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 87 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 88 | /* BEGIN_DEPENDENCIES |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 89 | * depends_on:POLARSSL_BIGNUM_C |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 90 | * END_DEPENDENCIES |
| 91 | */ |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 92 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 93 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 94 | void x509_cert_info( char *crt_file, char *result_str ) |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 95 | { |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 96 | x509_crt crt; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 97 | char buf[2000]; |
Paul Bakker | 69998dd | 2009-07-11 19:15:20 +0000 | [diff] [blame] | 98 | int res; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 99 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 100 | x509_crt_init( &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 101 | memset( buf, 0, 2000 ); |
| 102 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 103 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
| 104 | res = x509_crt_info( buf, 2000, "", &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 105 | |
| 106 | TEST_ASSERT( res != -1 ); |
| 107 | TEST_ASSERT( res != -2 ); |
| 108 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 109 | TEST_ASSERT( strcmp( buf, result_str ) == 0 ); |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 110 | |
| 111 | exit: |
| 112 | x509_crt_free( &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 113 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 114 | /* END_CASE */ |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 115 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 116 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRL_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 117 | void x509_crl_info( char *crl_file, char *result_str ) |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 118 | { |
| 119 | x509_crl crl; |
| 120 | char buf[2000]; |
Paul Bakker | 69998dd | 2009-07-11 19:15:20 +0000 | [diff] [blame] | 121 | int res; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 122 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 123 | x509_crl_init( &crl ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 124 | memset( buf, 0, 2000 ); |
| 125 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 126 | TEST_ASSERT( x509_crl_parse_file( &crl, crl_file ) == 0 ); |
| 127 | res = x509_crl_info( buf, 2000, "", &crl ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 128 | |
| 129 | TEST_ASSERT( res != -1 ); |
| 130 | TEST_ASSERT( res != -2 ); |
| 131 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 132 | TEST_ASSERT( strcmp( buf, result_str ) == 0 ); |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 133 | |
| 134 | exit: |
| 135 | x509_crl_free( &crl ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 136 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 137 | /* END_CASE */ |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 138 | |
Manuel Pégourié-Gonnard | 2a8d7fd | 2014-01-24 17:34:26 +0100 | [diff] [blame] | 139 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CSR_PARSE_C */ |
| 140 | void x509_csr_info( char *csr_file, char *result_str ) |
| 141 | { |
| 142 | x509_csr csr; |
| 143 | char buf[2000]; |
| 144 | int res; |
| 145 | |
| 146 | x509_csr_init( &csr ); |
| 147 | memset( buf, 0, 2000 ); |
| 148 | |
| 149 | TEST_ASSERT( x509_csr_parse_file( &csr, csr_file ) == 0 ); |
| 150 | res = x509_csr_info( buf, 2000, "", &csr ); |
| 151 | |
Manuel Pégourié-Gonnard | 2a8d7fd | 2014-01-24 17:34:26 +0100 | [diff] [blame] | 152 | TEST_ASSERT( res != -1 ); |
| 153 | TEST_ASSERT( res != -2 ); |
| 154 | |
| 155 | TEST_ASSERT( strcmp( buf, result_str ) == 0 ); |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 156 | |
| 157 | exit: |
| 158 | x509_csr_free( &csr ); |
Manuel Pégourié-Gonnard | 2a8d7fd | 2014-01-24 17:34:26 +0100 | [diff] [blame] | 159 | } |
| 160 | /* END_CASE */ |
| 161 | |
Manuel Pégourié-Gonnard | 39a183a | 2015-04-17 16:14:32 +0200 | [diff] [blame] | 162 | /* BEGIN_CASE depends_on:POLARSSL_X509_CRT_PARSE_C */ |
| 163 | void x509_verify_info( int flags, char *prefix, char *result_str ) |
| 164 | { |
| 165 | char buf[2000]; |
| 166 | int res; |
| 167 | |
| 168 | memset( buf, 0, sizeof( buf ) ); |
| 169 | |
| 170 | res = x509_crt_verify_info( buf, sizeof( buf ), prefix, flags ); |
| 171 | |
| 172 | TEST_ASSERT( res >= 0 ); |
| 173 | |
| 174 | TEST_ASSERT( strcmp( buf, result_str ) == 0 ); |
| 175 | } |
| 176 | /* END_CASE */ |
| 177 | |
Manuel Pégourié-Gonnard | cbf3ef3 | 2013-09-23 12:20:02 +0200 | [diff] [blame] | 178 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_CRL_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 179 | void x509_verify( char *crt_file, char *ca_file, char *crl_file, |
| 180 | char *cn_name_str, int result, int flags_result, |
| 181 | char *verify_callback ) |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 182 | { |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 183 | x509_crt crt; |
| 184 | x509_crt ca; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 185 | x509_crl crl; |
| 186 | int flags = 0; |
Paul Bakker | 69998dd | 2009-07-11 19:15:20 +0000 | [diff] [blame] | 187 | int res; |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 188 | int (*f_vrfy)(void *, x509_crt *, int, int *) = NULL; |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 189 | char * cn_name = NULL; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 190 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 191 | x509_crt_init( &crt ); |
| 192 | x509_crt_init( &ca ); |
| 193 | x509_crl_init( &crl ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 194 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 195 | if( strcmp( cn_name_str, "NULL" ) != 0 ) |
| 196 | cn_name = cn_name_str; |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 197 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 198 | if( strcmp( verify_callback, "NULL" ) == 0 ) |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 199 | f_vrfy = NULL; |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 200 | else if( strcmp( verify_callback, "verify_none" ) == 0 ) |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 201 | f_vrfy = verify_none; |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 202 | else if( strcmp( verify_callback, "verify_all" ) == 0 ) |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 203 | f_vrfy = verify_all; |
| 204 | else |
| 205 | TEST_ASSERT( "No known verify callback selected" == 0 ); |
| 206 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 207 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
| 208 | TEST_ASSERT( x509_crt_parse_file( &ca, ca_file ) == 0 ); |
| 209 | TEST_ASSERT( x509_crl_parse_file( &crl, crl_file ) == 0 ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 210 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 211 | res = x509_crt_verify( &crt, &ca, &crl, cn_name, &flags, f_vrfy, NULL ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 212 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 213 | TEST_ASSERT( res == ( result ) ); |
| 214 | TEST_ASSERT( flags == ( flags_result ) ); |
| 215 | |
| 216 | exit: |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 217 | x509_crt_free( &crt ); |
| 218 | x509_crt_free( &ca ); |
Paul Bakker | b08e684 | 2012-02-11 18:43:20 +0000 | [diff] [blame] | 219 | x509_crl_free( &crl ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 220 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 221 | /* END_CASE */ |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 222 | |
Manuel Pégourié-Gonnard | 15f1088 | 2015-09-01 11:59:24 +0200 | [diff] [blame] | 223 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */ |
| 224 | void x509_verify_callback( char *crt_file, char *ca_file, |
| 225 | int exp_ret, char *exp_vrfy_out ) |
| 226 | { |
| 227 | int ret; |
| 228 | x509_crt crt; |
| 229 | x509_crt ca; |
| 230 | int flags = 0; |
| 231 | verify_print_context vrfy_ctx; |
| 232 | |
| 233 | x509_crt_init( &crt ); |
| 234 | x509_crt_init( &ca ); |
| 235 | verify_print_init( &vrfy_ctx ); |
| 236 | |
| 237 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
| 238 | TEST_ASSERT( x509_crt_parse_file( &ca, ca_file ) == 0 ); |
| 239 | |
| 240 | ret = x509_crt_verify( &crt, &ca, NULL, NULL, &flags, |
| 241 | verify_print, &vrfy_ctx ); |
| 242 | |
| 243 | TEST_ASSERT( ret == exp_ret ); |
| 244 | TEST_ASSERT( strcmp( vrfy_ctx.buf, exp_vrfy_out ) == 0 ); |
| 245 | |
| 246 | exit: |
| 247 | x509_crt_free( &crt ); |
| 248 | x509_crt_free( &ca ); |
| 249 | } |
| 250 | /* END_CASE */ |
| 251 | |
Manuel Pégourié-Gonnard | 8f63e95 | 2015-09-01 18:44:47 +0200 | [diff] [blame] | 252 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 253 | void x509_dn_gets( char *crt_file, char *entity, char *result_str ) |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 254 | { |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 255 | x509_crt crt; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 256 | char buf[2000]; |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 257 | int res = 0; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 258 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 259 | x509_crt_init( &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 260 | memset( buf, 0, 2000 ); |
| 261 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 262 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 263 | if( strcmp( entity, "subject" ) == 0 ) |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 264 | res = x509_dn_gets( buf, 2000, &crt.subject ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 265 | else if( strcmp( entity, "issuer" ) == 0 ) |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 266 | res = x509_dn_gets( buf, 2000, &crt.issuer ); |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 267 | else |
| 268 | TEST_ASSERT( "Unknown entity" == 0 ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 269 | |
| 270 | TEST_ASSERT( res != -1 ); |
| 271 | TEST_ASSERT( res != -2 ); |
| 272 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 273 | TEST_ASSERT( strcmp( buf, result_str ) == 0 ); |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 274 | |
| 275 | exit: |
| 276 | x509_crt_free( &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 277 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 278 | /* END_CASE */ |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 279 | |
Manuel Pégourié-Gonnard | 8f63e95 | 2015-09-01 18:44:47 +0200 | [diff] [blame] | 280 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 281 | void x509_time_expired( char *crt_file, char *entity, int result ) |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 282 | { |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 283 | x509_crt crt; |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 284 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 285 | x509_crt_init( &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 286 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 287 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 288 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 289 | if( strcmp( entity, "valid_from" ) == 0 ) |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 290 | TEST_ASSERT( x509_time_expired( &crt.valid_from ) == result ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 291 | else if( strcmp( entity, "valid_to" ) == 0 ) |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 292 | TEST_ASSERT( x509_time_expired( &crt.valid_to ) == result ); |
Paul Bakker | dbd443d | 2013-08-16 13:38:47 +0200 | [diff] [blame] | 293 | else |
| 294 | TEST_ASSERT( "Unknown entity" == 0 ); |
Paul Bakker | b08e684 | 2012-02-11 18:43:20 +0000 | [diff] [blame] | 295 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 296 | exit: |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 297 | x509_crt_free( &crt ); |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 298 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 299 | /* END_CASE */ |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 300 | |
Manuel Pégourié-Gonnard | 8f63e95 | 2015-09-01 18:44:47 +0200 | [diff] [blame] | 301 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */ |
Manuel Pégourié-Gonnard | 6304f78 | 2014-03-10 12:26:11 +0100 | [diff] [blame] | 302 | void x509_time_future( char *crt_file, char *entity, int result ) |
| 303 | { |
| 304 | x509_crt crt; |
| 305 | |
| 306 | x509_crt_init( &crt ); |
| 307 | |
| 308 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
| 309 | |
| 310 | if( strcmp( entity, "valid_from" ) == 0 ) |
| 311 | TEST_ASSERT( x509_time_future( &crt.valid_from ) == result ); |
| 312 | else if( strcmp( entity, "valid_to" ) == 0 ) |
| 313 | TEST_ASSERT( x509_time_future( &crt.valid_to ) == result ); |
| 314 | else |
| 315 | TEST_ASSERT( "Unknown entity" == 0 ); |
| 316 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 317 | exit: |
Manuel Pégourié-Gonnard | 6304f78 | 2014-03-10 12:26:11 +0100 | [diff] [blame] | 318 | x509_crt_free( &crt ); |
| 319 | } |
| 320 | /* END_CASE */ |
| 321 | |
Paul Bakker | 5a5fa92 | 2014-09-26 14:53:04 +0200 | [diff] [blame] | 322 | /* BEGIN_CASE depends_on:POLARSSL_X509_CRT_PARSE_C:POLARSSL_FS_IO */ |
| 323 | void x509parse_crt_file( char *crt_file, int result ) |
| 324 | { |
| 325 | x509_crt crt; |
| 326 | |
| 327 | x509_crt_init( &crt ); |
| 328 | |
| 329 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == result ); |
| 330 | |
| 331 | exit: |
| 332 | x509_crt_free( &crt ); |
| 333 | } |
| 334 | /* END_CASE */ |
| 335 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 336 | /* BEGIN_CASE depends_on:POLARSSL_X509_CRT_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 337 | void x509parse_crt( char *crt_data, char *result_str, int result ) |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 338 | { |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 339 | x509_crt crt; |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 340 | unsigned char buf[2000]; |
| 341 | unsigned char output[2000]; |
| 342 | int data_len, res; |
| 343 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 344 | x509_crt_init( &crt ); |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 345 | memset( buf, 0, 2000 ); |
| 346 | memset( output, 0, 2000 ); |
| 347 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 348 | data_len = unhexify( buf, crt_data ); |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 349 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 350 | TEST_ASSERT( x509_crt_parse( &crt, buf, data_len ) == ( result ) ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 351 | if( ( result ) == 0 ) |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 352 | { |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 353 | res = x509_crt_info( (char *) output, 2000, "", &crt ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 354 | |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 355 | TEST_ASSERT( res != -1 ); |
| 356 | TEST_ASSERT( res != -2 ); |
| 357 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 358 | TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 ); |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 359 | } |
Paul Bakker | b08e684 | 2012-02-11 18:43:20 +0000 | [diff] [blame] | 360 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 361 | exit: |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 362 | x509_crt_free( &crt ); |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 363 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 364 | /* END_CASE */ |
Paul Bakker | b2c38f5 | 2009-07-19 19:36:15 +0000 | [diff] [blame] | 365 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 366 | /* BEGIN_CASE depends_on:POLARSSL_X509_CRL_PARSE_C */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 367 | void x509parse_crl( char *crl_data, char *result_str, int result ) |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 368 | { |
| 369 | x509_crl crl; |
| 370 | unsigned char buf[2000]; |
| 371 | unsigned char output[2000]; |
| 372 | int data_len, res; |
| 373 | |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 374 | x509_crl_init( &crl ); |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 375 | memset( buf, 0, 2000 ); |
| 376 | memset( output, 0, 2000 ); |
| 377 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 378 | data_len = unhexify( buf, crl_data ); |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 379 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 380 | TEST_ASSERT( x509_crl_parse( &crl, buf, data_len ) == ( result ) ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 381 | if( ( result ) == 0 ) |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 382 | { |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 383 | res = x509_crl_info( (char *) output, 2000, "", &crl ); |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 384 | |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 385 | TEST_ASSERT( res != -1 ); |
| 386 | TEST_ASSERT( res != -2 ); |
| 387 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 388 | TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 ); |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 389 | } |
Paul Bakker | b08e684 | 2012-02-11 18:43:20 +0000 | [diff] [blame] | 390 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 391 | exit: |
Paul Bakker | b08e684 | 2012-02-11 18:43:20 +0000 | [diff] [blame] | 392 | x509_crl_free( &crl ); |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 393 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 394 | /* END_CASE */ |
Paul Bakker | 6b0fa4f | 2009-07-20 20:35:41 +0000 | [diff] [blame] | 395 | |
Manuel Pégourié-Gonnard | d77cd5d | 2014-06-13 11:13:15 +0200 | [diff] [blame] | 396 | /* BEGIN_CASE depends_on:POLARSSL_X509_CSR_PARSE_C */ |
| 397 | void x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret ) |
| 398 | { |
| 399 | x509_csr csr; |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 400 | unsigned char *csr_der = NULL; |
Manuel Pégourié-Gonnard | d77cd5d | 2014-06-13 11:13:15 +0200 | [diff] [blame] | 401 | char my_out[1000]; |
| 402 | size_t csr_der_len; |
| 403 | int my_ret; |
| 404 | |
| 405 | x509_csr_init( &csr ); |
| 406 | memset( my_out, 0, sizeof( my_out ) ); |
| 407 | csr_der = unhexify_alloc( csr_der_hex, &csr_der_len ); |
| 408 | |
Manuel Pégourié-Gonnard | f3b4724 | 2014-06-16 18:06:48 +0200 | [diff] [blame] | 409 | my_ret = x509_csr_parse_der( &csr, csr_der, csr_der_len ); |
Manuel Pégourié-Gonnard | d77cd5d | 2014-06-13 11:13:15 +0200 | [diff] [blame] | 410 | TEST_ASSERT( my_ret == ref_ret ); |
| 411 | |
| 412 | if( ref_ret == 0 ) |
| 413 | { |
| 414 | size_t my_out_len = x509_csr_info( my_out, sizeof( my_out ), "", &csr ); |
| 415 | TEST_ASSERT( my_out_len == strlen( ref_out ) ); |
| 416 | TEST_ASSERT( strcmp( my_out, ref_out ) == 0 ); |
| 417 | } |
| 418 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 419 | exit: |
Manuel Pégourié-Gonnard | d77cd5d | 2014-06-13 11:13:15 +0200 | [diff] [blame] | 420 | x509_csr_free( &csr ); |
| 421 | polarssl_free( csr_der ); |
| 422 | } |
| 423 | /* END_CASE */ |
| 424 | |
Manuel Pégourié-Gonnard | fbae2a1 | 2013-11-26 16:43:39 +0100 | [diff] [blame] | 425 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */ |
| 426 | void x509_crt_parse_path( char *crt_path, int ret, int nb_crt ) |
| 427 | { |
| 428 | x509_crt chain, *cur; |
| 429 | int i; |
| 430 | |
| 431 | x509_crt_init( &chain ); |
| 432 | |
| 433 | TEST_ASSERT( x509_crt_parse_path( &chain, crt_path ) == ret ); |
| 434 | |
| 435 | /* Check how many certs we got */ |
| 436 | for( i = 0, cur = &chain; cur != NULL; cur = cur->next ) |
| 437 | if( cur->raw.p != NULL ) |
| 438 | i++; |
| 439 | |
| 440 | TEST_ASSERT( i == nb_crt ); |
| 441 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 442 | exit: |
Paul Bakker | a2ffccd | 2013-12-02 21:56:37 +0100 | [diff] [blame] | 443 | x509_crt_free( &chain ); |
Manuel Pégourié-Gonnard | fbae2a1 | 2013-11-26 16:43:39 +0100 | [diff] [blame] | 444 | } |
| 445 | /* END_CASE */ |
| 446 | |
Manuel Pégourié-Gonnard | 0f7b619 | 2014-06-24 11:37:54 +0200 | [diff] [blame] | 447 | /* BEGIN_CASE depends_on:POLARSSL_X509_USE_C */ |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 448 | void x509_oid_desc( char *oid_str, char *ref_desc ) |
| 449 | { |
| 450 | x509_buf oid; |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 451 | const char *desc = NULL; |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 452 | unsigned char buf[20]; |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 453 | int ret; |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 454 | |
| 455 | memset( buf, 0, sizeof buf ); |
| 456 | |
| 457 | oid.tag = ASN1_OID; |
| 458 | oid.len = unhexify( buf, oid_str ); |
| 459 | oid.p = buf; |
| 460 | |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 461 | ret = oid_get_extended_key_usage( &oid, &desc ); |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 462 | |
| 463 | if( strcmp( ref_desc, "notfound" ) == 0 ) |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 464 | { |
| 465 | TEST_ASSERT( ret != 0 ); |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 466 | TEST_ASSERT( desc == NULL ); |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 467 | } |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 468 | else |
| 469 | { |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 470 | TEST_ASSERT( ret == 0 ); |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 471 | TEST_ASSERT( desc != NULL ); |
| 472 | TEST_ASSERT( strcmp( desc, ref_desc ) == 0 ); |
| 473 | } |
| 474 | } |
| 475 | /* END_CASE */ |
| 476 | |
Manuel Pégourié-Gonnard | 0f7b619 | 2014-06-24 11:37:54 +0200 | [diff] [blame] | 477 | /* BEGIN_CASE depends_on:POLARSSL_X509_USE_C */ |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 478 | void x509_oid_numstr( char *oid_str, char *numstr, int blen, int ret ) |
| 479 | { |
| 480 | x509_buf oid; |
| 481 | unsigned char oid_buf[20]; |
| 482 | char num_buf[100]; |
| 483 | |
| 484 | memset( oid_buf, 0x00, sizeof oid_buf ); |
| 485 | memset( num_buf, 0x2a, sizeof num_buf ); |
| 486 | |
| 487 | oid.tag = ASN1_OID; |
| 488 | oid.len = unhexify( oid_buf, oid_str ); |
| 489 | oid.p = oid_buf; |
| 490 | |
| 491 | TEST_ASSERT( (size_t) blen <= sizeof num_buf ); |
| 492 | |
Manuel Pégourié-Gonnard | 079333b | 2015-03-20 18:14:26 +0000 | [diff] [blame] | 493 | TEST_ASSERT( oid_get_numeric_string( num_buf, blen, &oid ) == ret ); |
Manuel Pégourié-Gonnard | 7afdb88 | 2014-03-28 16:06:35 +0100 | [diff] [blame] | 494 | |
| 495 | if( ret >= 0 ) |
| 496 | { |
| 497 | TEST_ASSERT( num_buf[ret] == 0 ); |
| 498 | TEST_ASSERT( strcmp( num_buf, numstr ) == 0 ); |
| 499 | } |
| 500 | } |
| 501 | /* END_CASE */ |
| 502 | |
Paul Bakker | 5b11d02 | 2014-07-10 13:54:38 +0200 | [diff] [blame] | 503 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_CHECK_KEY_USAGE */ |
Manuel Pégourié-Gonnard | 603116c | 2014-04-09 09:50:03 +0200 | [diff] [blame] | 504 | void x509_check_key_usage( char *crt_file, int usage, int ret ) |
| 505 | { |
| 506 | x509_crt crt; |
| 507 | |
| 508 | x509_crt_init( &crt ); |
| 509 | |
| 510 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
| 511 | |
| 512 | TEST_ASSERT( x509_crt_check_key_usage( &crt, usage ) == ret ); |
| 513 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 514 | exit: |
Manuel Pégourié-Gonnard | 603116c | 2014-04-09 09:50:03 +0200 | [diff] [blame] | 515 | x509_crt_free( &crt ); |
| 516 | } |
| 517 | /* END_CASE */ |
| 518 | |
Paul Bakker | 5b11d02 | 2014-07-10 13:54:38 +0200 | [diff] [blame] | 519 | /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE */ |
Manuel Pégourié-Gonnard | 7afb8a0 | 2014-04-10 17:53:56 +0200 | [diff] [blame] | 520 | void x509_check_extended_key_usage( char *crt_file, char *usage_hex, int ret ) |
| 521 | { |
| 522 | x509_crt crt; |
| 523 | char oid[50]; |
| 524 | size_t len; |
| 525 | |
| 526 | x509_crt_init( &crt ); |
| 527 | |
| 528 | len = unhexify( (unsigned char *) oid, usage_hex ); |
| 529 | |
| 530 | TEST_ASSERT( x509_crt_parse_file( &crt, crt_file ) == 0 ); |
| 531 | |
| 532 | TEST_ASSERT( x509_crt_check_extended_key_usage( &crt, oid, len ) == ret ); |
| 533 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 534 | exit: |
Manuel Pégourié-Gonnard | 7afb8a0 | 2014-04-10 17:53:56 +0200 | [diff] [blame] | 535 | x509_crt_free( &crt ); |
| 536 | } |
| 537 | /* END_CASE */ |
| 538 | |
Manuel Pégourié-Gonnard | d1539b1 | 2014-06-06 16:42:37 +0200 | [diff] [blame] | 539 | /* BEGIN_CASE depends_on:POLARSSL_X509_CRT_PARSE_C:POLARSSL_X509_RSASSA_PSS_SUPPORT */ |
Manuel Pégourié-Gonnard | 8540369 | 2014-06-06 14:48:38 +0200 | [diff] [blame] | 540 | void x509_parse_rsassa_pss_params( char *hex_params, int params_tag, |
| 541 | int ref_msg_md, int ref_mgf_md, |
| 542 | int ref_salt_len, int ref_ret ) |
| 543 | { |
| 544 | int my_ret; |
| 545 | x509_buf params; |
| 546 | md_type_t my_msg_md, my_mgf_md; |
| 547 | int my_salt_len; |
| 548 | |
| 549 | params.p = unhexify_alloc( hex_params, ¶ms.len ); |
| 550 | params.tag = params_tag; |
| 551 | |
| 552 | my_ret = x509_get_rsassa_pss_params( ¶ms, &my_msg_md, &my_mgf_md, |
| 553 | &my_salt_len ); |
| 554 | |
Manuel Pégourié-Gonnard | 8540369 | 2014-06-06 14:48:38 +0200 | [diff] [blame] | 555 | TEST_ASSERT( my_ret == ref_ret ); |
| 556 | |
| 557 | if( ref_ret == 0 ) |
| 558 | { |
| 559 | TEST_ASSERT( my_msg_md == (md_type_t) ref_msg_md ); |
| 560 | TEST_ASSERT( my_mgf_md == (md_type_t) ref_mgf_md ); |
| 561 | TEST_ASSERT( my_salt_len == ref_salt_len ); |
| 562 | } |
| 563 | |
Paul Bakker | bd51b26 | 2014-07-10 15:26:12 +0200 | [diff] [blame] | 564 | exit: |
Manuel Pégourié-Gonnard | 8540369 | 2014-06-06 14:48:38 +0200 | [diff] [blame] | 565 | polarssl_free( params.p ); |
| 566 | } |
| 567 | /* END_CASE */ |
| 568 | |
Manuel Pégourié-Gonnard | 2014016 | 2013-10-10 12:48:03 +0200 | [diff] [blame] | 569 | /* BEGIN_CASE depends_on:POLARSSL_X509_CRT_PARSE_C:POLARSSL_SELF_TEST */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 570 | void x509_selftest() |
Paul Bakker | 37940d9f | 2009-07-10 22:38:58 +0000 | [diff] [blame] | 571 | { |
| 572 | TEST_ASSERT( x509_self_test( 0 ) == 0 ); |
| 573 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 574 | /* END_CASE */ |