11 ((void) certificate_depth);
21 ((void) certificate_depth);
30 typedef UINT32 uint32_t;
39 #define GET_UINT32_BE(n,b,i) \
41 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
42 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
43 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
44 | ( (uint32_t) (b)[(i) + 3] ); \
49 #define PUT_UINT32_BE(n,b,i) \
51 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
52 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
53 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
54 (b)[(i) + 3] = (unsigned char) ( (n) ); \
58 int unhexify(
unsigned char *obuf,
const char *ibuf)
61 int len = strlen(ibuf) / 2;
62 assert(!(strlen(ibuf) %1));
67 if( c >=
'0' && c <=
'9' )
69 else if( c >=
'a' && c <=
'f' )
71 else if( c >=
'A' && c <=
'F' )
77 if( c2 >=
'0' && c2 <=
'9' )
79 else if( c2 >=
'a' && c2 <=
'f' )
81 else if( c2 >=
'A' && c2 <=
'F' )
86 *obuf++ = ( c << 4 ) | c2;
92 void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
104 *obuf++ =
'a' + h - 10;
109 *obuf++ =
'a' + l - 10;
125 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
129 if( rng_state != NULL )
132 for( i = 0; i < len; ++i )
143 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
145 if( rng_state != NULL )
148 memset( output, 0, len );
175 if( rng_state == NULL )
184 memcpy( output, info->
buf, use_len );
185 info->
buf += use_len;
189 if( len - use_len > 0 )
190 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
219 uint32_t i, *k, sum, delta=0x9E3779B9;
220 unsigned char result[4];
222 if( rng_state == NULL )
229 size_t use_len = ( len > 4 ) ? 4 : len;
232 for( i = 0; i < 32; i++ )
234 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
236 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
240 memcpy( output, result, use_len );
250 #ifdef POLARSSL_X509_PARSE_C
251 #ifdef POLARSSL_BIGNUM_C
254 FCT_SUITE_BGN(test_suite_x509parse)
256 #ifdef POLARSSL_PEM_C
257 #ifdef POLARSSL_FS_IO
259 FCT_TEST_BGN(x509_certificate_information_1)
266 memset( buf, 0, 2000 );
273 fct_chk( res != -1 );
274 fct_chk( res != -2 );
276 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 01\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Server 1\nissued on : 2011-02-12 14:44:06\nexpires on : 2021-02-12 14:44:06\nsigned using : RSA+SHA1\nRSA key size : 2048 bits\n" ) == 0 );
282 #ifdef POLARSSL_PEM_C
283 #ifdef POLARSSL_FS_IO
285 FCT_TEST_BGN(x509_certificate_information_2)
292 memset( buf, 0, 2000 );
299 fct_chk( res != -1 );
300 fct_chk( res != -2 );
302 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 02\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=localhost\nissued on : 2011-02-12 14:44:06\nexpires on : 2021-02-12 14:44:06\nsigned using : RSA+SHA1\nRSA key size : 2048 bits\n" ) == 0 );
308 #ifdef POLARSSL_PEM_C
309 #ifdef POLARSSL_FS_IO
311 FCT_TEST_BGN(x509_certificate_information_3)
318 memset( buf, 0, 2000 );
325 fct_chk( res != -1 );
326 fct_chk( res != -2 );
328 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 00\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nissued on : 2011-02-12 14:44:00\nexpires on : 2021-02-12 14:44:00\nsigned using : RSA+SHA1\nRSA key size : 2048 bits\n" ) == 0 );
334 #ifdef POLARSSL_PEM_C
335 #ifdef POLARSSL_FS_IO
337 FCT_TEST_BGN(x509_certificate_information_md2_digest)
344 memset( buf, 0, 2000 );
351 fct_chk( res != -1 );
352 fct_chk( res != -2 );
354 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 09\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert MD2\nissued on : 2009-07-12 10:56:59\nexpires on : 2011-07-12 10:56:59\nsigned using : RSA+MD2\nRSA key size : 2048 bits\n" ) == 0 );
360 #ifdef POLARSSL_PEM_C
361 #ifdef POLARSSL_FS_IO
363 FCT_TEST_BGN(x509_certificate_information_md4_digest)
370 memset( buf, 0, 2000 );
377 fct_chk( res != -1 );
378 fct_chk( res != -2 );
380 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 05\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert MD4\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+MD4\nRSA key size : 2048 bits\n" ) == 0 );
386 #ifdef POLARSSL_PEM_C
387 #ifdef POLARSSL_FS_IO
389 FCT_TEST_BGN(x509_certificate_information_md5_digest)
396 memset( buf, 0, 2000 );
403 fct_chk( res != -1 );
404 fct_chk( res != -2 );
406 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 06\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert MD5\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+MD5\nRSA key size : 2048 bits\n" ) == 0 );
412 #ifdef POLARSSL_PEM_C
413 #ifdef POLARSSL_FS_IO
415 FCT_TEST_BGN(x509_certificate_information_sha1_digest)
422 memset( buf, 0, 2000 );
429 fct_chk( res != -1 );
430 fct_chk( res != -2 );
432 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 07\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert SHA1\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+SHA1\nRSA key size : 2048 bits\n" ) == 0 );
438 #ifdef POLARSSL_PEM_C
439 #ifdef POLARSSL_FS_IO
441 FCT_TEST_BGN(x509_certificate_information_sha224_digest)
448 memset( buf, 0, 2000 );
455 fct_chk( res != -1 );
456 fct_chk( res != -2 );
458 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 08\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert SHA224\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+SHA224\nRSA key size : 2048 bits\n" ) == 0 );
464 #ifdef POLARSSL_PEM_C
465 #ifdef POLARSSL_FS_IO
467 FCT_TEST_BGN(x509_certificate_information_sha256_digest)
474 memset( buf, 0, 2000 );
481 fct_chk( res != -1 );
482 fct_chk( res != -2 );
484 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 09\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert SHA256\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+SHA256\nRSA key size : 2048 bits\n" ) == 0 );
490 #ifdef POLARSSL_PEM_C
491 #ifdef POLARSSL_FS_IO
493 FCT_TEST_BGN(x509_certificate_information_sha384_digest)
500 memset( buf, 0, 2000 );
507 fct_chk( res != -1 );
508 fct_chk( res != -2 );
510 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 0A\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert SHA384\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+SHA384\nRSA key size : 2048 bits\n" ) == 0 );
516 #ifdef POLARSSL_PEM_C
517 #ifdef POLARSSL_FS_IO
519 FCT_TEST_BGN(x509_certificate_information_sha512_digest)
526 memset( buf, 0, 2000 );
533 fct_chk( res != -1 );
534 fct_chk( res != -2 );
536 fct_chk( strcmp( buf,
"cert. version : 3\nserial number : 0B\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name : C=NL, O=PolarSSL, CN=PolarSSL Cert SHA512\nissued on : 2011-02-12 14:44:07\nexpires on : 2021-02-12 14:44:07\nsigned using : RSA+SHA512\nRSA key size : 2048 bits\n" ) == 0 );
542 #ifdef POLARSSL_PEM_C
543 #ifdef POLARSSL_FS_IO
545 FCT_TEST_BGN(x509_crl_information_1)
551 memset( &crl, 0,
sizeof(
x509_crl ) );
552 memset( buf, 0, 2000 );
559 fct_chk( res != -1 );
560 fct_chk( res != -2 );
562 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-20 10:24:19\nnext update : 2011-02-20 11:24:19\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+SHA1\n" ) == 0 );
568 #ifdef POLARSSL_PEM_C
569 #ifdef POLARSSL_FS_IO
571 FCT_TEST_BGN(x509_crl_information_md2_digest)
577 memset( &crl, 0,
sizeof(
x509_crl ) );
578 memset( buf, 0, 2000 );
585 fct_chk( res != -1 );
586 fct_chk( res != -2 );
588 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2009-07-19 19:56:37\nnext update : 2009-09-17 19:56:37\nRevoked certificates:\nserial number: 01 revocation date: 2009-02-09 21:12:36\nserial number: 03 revocation date: 2009-02-09 21:12:36\nsigned using : RSA+MD2\n" ) == 0 );
594 #ifdef POLARSSL_PEM_C
595 #ifdef POLARSSL_FS_IO
597 FCT_TEST_BGN(x509_crl_information_md4_digest)
603 memset( &crl, 0,
sizeof(
x509_crl ) );
604 memset( buf, 0, 2000 );
611 fct_chk( res != -1 );
612 fct_chk( res != -2 );
614 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+MD4\n" ) == 0 );
620 #ifdef POLARSSL_PEM_C
621 #ifdef POLARSSL_FS_IO
623 FCT_TEST_BGN(x509_crl_information_md5_digest)
629 memset( &crl, 0,
sizeof(
x509_crl ) );
630 memset( buf, 0, 2000 );
637 fct_chk( res != -1 );
638 fct_chk( res != -2 );
640 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+MD5\n" ) == 0 );
646 #ifdef POLARSSL_PEM_C
647 #ifdef POLARSSL_FS_IO
649 FCT_TEST_BGN(x509_crl_information_sha1_digest)
655 memset( &crl, 0,
sizeof(
x509_crl ) );
656 memset( buf, 0, 2000 );
663 fct_chk( res != -1 );
664 fct_chk( res != -2 );
666 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+SHA1\n" ) == 0 );
672 #ifdef POLARSSL_PEM_C
673 #ifdef POLARSSL_FS_IO
675 FCT_TEST_BGN(x509_crl_information_sha224_digest)
681 memset( &crl, 0,
sizeof(
x509_crl ) );
682 memset( buf, 0, 2000 );
689 fct_chk( res != -1 );
690 fct_chk( res != -2 );
692 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+SHA224\n" ) == 0 );
698 #ifdef POLARSSL_PEM_C
699 #ifdef POLARSSL_FS_IO
701 FCT_TEST_BGN(x509_crl_information_sha256_digest)
707 memset( &crl, 0,
sizeof(
x509_crl ) );
708 memset( buf, 0, 2000 );
715 fct_chk( res != -1 );
716 fct_chk( res != -2 );
718 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+SHA256\n" ) == 0 );
724 #ifdef POLARSSL_PEM_C
725 #ifdef POLARSSL_FS_IO
727 FCT_TEST_BGN(x509_crl_information_sha384_digest)
733 memset( &crl, 0,
sizeof(
x509_crl ) );
734 memset( buf, 0, 2000 );
741 fct_chk( res != -1 );
742 fct_chk( res != -2 );
744 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+SHA384\n" ) == 0 );
750 #ifdef POLARSSL_PEM_C
751 #ifdef POLARSSL_FS_IO
753 FCT_TEST_BGN(x509_crl_information_sha512_digest)
759 memset( &crl, 0,
sizeof(
x509_crl ) );
760 memset( buf, 0, 2000 );
767 fct_chk( res != -1 );
768 fct_chk( res != -2 );
770 fct_chk( strcmp( buf,
"CRL version : 1\nissuer name : C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update : 2011-02-12 14:44:07\nnext update : 2011-04-13 14:44:07\nRevoked certificates:\nserial number: 01 revocation date: 2011-02-12 14:44:07\nserial number: 03 revocation date: 2011-02-12 14:44:07\nsigned using : RSA+SHA512\n" ) == 0 );
776 #ifdef POLARSSL_MD5_C
777 #ifdef POLARSSL_PEM_C
778 #ifdef POLARSSL_FS_IO
780 FCT_TEST_BGN(x509_parse_key_1_no_password_when_required)
803 #ifdef POLARSSL_MD5_C
804 #ifdef POLARSSL_PEM_C
805 #ifdef POLARSSL_FS_IO
807 FCT_TEST_BGN(x509_parse_key_2_correct_password)
830 #ifdef POLARSSL_MD5_C
831 #ifdef POLARSSL_PEM_C
832 #ifdef POLARSSL_FS_IO
834 FCT_TEST_BGN(x509_parse_key_3_wrong_password)
857 #ifdef POLARSSL_MD5_C
858 #ifdef POLARSSL_DES_C
859 #ifdef POLARSSL_PEM_C
860 #ifdef POLARSSL_FS_IO
862 FCT_TEST_BGN(x509_parse_key_4_des_encrypted)
886 #ifdef POLARSSL_MD5_C
887 #ifdef POLARSSL_DES_C
888 #ifdef POLARSSL_PEM_C
889 #ifdef POLARSSL_FS_IO
891 FCT_TEST_BGN(x509_parse_key_5_3des_encrypted)
915 #ifdef POLARSSL_MD5_C
916 #ifdef POLARSSL_AES_C
917 #ifdef POLARSSL_PEM_C
918 #ifdef POLARSSL_FS_IO
920 FCT_TEST_BGN(x509_parse_key_6_aes_128_encrypted)
944 #ifdef POLARSSL_MD5_C
945 #ifdef POLARSSL_AES_C
946 #ifdef POLARSSL_PEM_C
947 #ifdef POLARSSL_FS_IO
949 FCT_TEST_BGN(x509_parse_key_7_aes_192_encrypted)
973 #ifdef POLARSSL_MD5_C
974 #ifdef POLARSSL_AES_C
975 #ifdef POLARSSL_PEM_C
976 #ifdef POLARSSL_FS_IO
978 FCT_TEST_BGN(x509_parse_key_8_aes_256_encrypted)
1002 #ifdef POLARSSL_MD5_C
1003 #ifdef POLARSSL_PEM_C
1004 #ifdef POLARSSL_FS_IO
1006 FCT_TEST_BGN(x509_parse_key_9_pkcs8_wrapped)
1015 fct_chk( res == 0 );
1029 #ifdef POLARSSL_DES_C
1030 #ifdef POLARSSL_SHA1_C
1031 #ifdef POLARSSL_PEM_C
1032 #ifdef POLARSSL_FS_IO
1033 #ifdef POLARSSL_PKCS12_C
1035 FCT_TEST_BGN(x509_parse_key_10_pkcs8_encrypted_sha1_3des)
1042 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_3des.key",
"PolarSSLTest" );
1044 fct_chk( res == 0 );
1060 #ifdef POLARSSL_DES_C
1061 #ifdef POLARSSL_SHA1_C
1062 #ifdef POLARSSL_PEM_C
1063 #ifdef POLARSSL_FS_IO
1064 #ifdef POLARSSL_PKCS12_C
1066 FCT_TEST_BGN(x509_parse_key_101_pkcs8_encrypted_sha1_3des_wrong_pw)
1073 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_3des.key",
"PolarSSLTes" );
1091 #ifdef POLARSSL_DES_C
1092 #ifdef POLARSSL_SHA1_C
1093 #ifdef POLARSSL_PEM_C
1094 #ifdef POLARSSL_FS_IO
1095 #ifdef POLARSSL_PKCS12_C
1097 FCT_TEST_BGN(x509_parse_key_102_pkcs8_encrypted_sha1_3des_no_pw)
1122 #ifdef POLARSSL_DES_C
1123 #ifdef POLARSSL_SHA1_C
1124 #ifdef POLARSSL_FS_IO
1125 #ifdef POLARSSL_PKCS12_C
1127 FCT_TEST_BGN(x509_parse_key_11_pkcs8_encrypted_sha1_3des_der)
1134 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_3des.der",
"PolarSSLTest" );
1136 fct_chk( res == 0 );
1151 #ifdef POLARSSL_DES_C
1152 #ifdef POLARSSL_SHA1_C
1153 #ifdef POLARSSL_PEM_C
1154 #ifdef POLARSSL_FS_IO
1155 #ifdef POLARSSL_PKCS12_C
1157 FCT_TEST_BGN(x509_parse_key_12_pkcs8_encrypted_sha1_2des)
1164 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_2des.key",
"PolarSSLTest" );
1166 fct_chk( res == 0 );
1182 #ifdef POLARSSL_DES_C
1183 #ifdef POLARSSL_SHA1_C
1184 #ifdef POLARSSL_PEM_C
1185 #ifdef POLARSSL_FS_IO
1186 #ifdef POLARSSL_PKCS12_C
1188 FCT_TEST_BGN(x509_parse_key_121_pkcs8_encrypted_sha1_2des_wrong_pw)
1195 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_2des.key",
"PolarSLTest" );
1213 #ifdef POLARSSL_DES_C
1214 #ifdef POLARSSL_SHA1_C
1215 #ifdef POLARSSL_PEM_C
1216 #ifdef POLARSSL_FS_IO
1217 #ifdef POLARSSL_PKCS12_C
1219 FCT_TEST_BGN(x509_parse_key_122_pkcs8_encrypted_sha1_2des_no_pw)
1244 #ifdef POLARSSL_ARC4_C
1245 #ifdef POLARSSL_SHA1_C
1246 #ifdef POLARSSL_PEM_C
1247 #ifdef POLARSSL_FS_IO
1248 #ifdef POLARSSL_PKCS12_C
1250 FCT_TEST_BGN(x509_parse_key_13_pkcs8_encrypted_sha1_rc4_128)
1257 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_rc4_128.key",
"PolarSSLTest" );
1259 fct_chk( res == 0 );
1275 #ifdef POLARSSL_ARC4_C
1276 #ifdef POLARSSL_SHA1_C
1277 #ifdef POLARSSL_PEM_C
1278 #ifdef POLARSSL_FS_IO
1279 #ifdef POLARSSL_PKCS12_C
1281 FCT_TEST_BGN(x509_parse_key_131_pkcs8_encrypted_sha1_rc4_128_wrong_pw)
1288 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbe_sha1_rc4_128.key",
"PolarSSLTe" );
1306 #ifdef POLARSSL_ARC4_C
1307 #ifdef POLARSSL_SHA1_C
1308 #ifdef POLARSSL_PEM_C
1309 #ifdef POLARSSL_FS_IO
1310 #ifdef POLARSSL_PKCS12_C
1312 FCT_TEST_BGN(x509_parse_key_132_pkcs8_encrypted_sha1_rc4_128_no_pw)
1337 #ifdef POLARSSL_DES_C
1338 #ifdef POLARSSL_SHA1_C
1339 #ifdef POLARSSL_PEM_C
1340 #ifdef POLARSSL_FS_IO
1341 #ifdef POLARSSL_PKCS5_C
1343 FCT_TEST_BGN(x509_parse_key_14_pkcs8_encrypted_v2_pbdfk2_3des)
1350 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbes2_pbkdf2_3des.key",
"PolarSSLTest" );
1352 fct_chk( res == 0 );
1368 #ifdef POLARSSL_DES_C
1369 #ifdef POLARSSL_SHA1_C
1370 #ifdef POLARSSL_PEM_C
1371 #ifdef POLARSSL_FS_IO
1372 #ifdef POLARSSL_PKCS5_C
1374 FCT_TEST_BGN(x509_parse_key_15_pkcs8_encrypted_v2_pbdfk2_3des_wrong_pw)
1381 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbes2_pbkdf2_3des.key",
"PolarSSLTes" );
1399 #ifdef POLARSSL_DES_C
1400 #ifdef POLARSSL_SHA1_C
1401 #ifdef POLARSSL_PEM_C
1402 #ifdef POLARSSL_FS_IO
1403 #ifdef POLARSSL_PKCS5_C
1405 FCT_TEST_BGN(x509_parse_key_16_pkcs8_encrypted_v2_pbdfk2_3des_no_pw)
1430 #ifdef POLARSSL_DES_C
1431 #ifdef POLARSSL_SHA1_C
1432 #ifdef POLARSSL_FS_IO
1433 #ifdef POLARSSL_PKCS5_C
1435 FCT_TEST_BGN(x509_parse_key_17_pkcs8_encrypted_v2_pbdfk2_3des_der)
1442 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbes2_pbkdf2_3des.der",
"PolarSSLTest" );
1444 fct_chk( res == 0 );
1459 #ifdef POLARSSL_DES_C
1460 #ifdef POLARSSL_SHA1_C
1461 #ifdef POLARSSL_FS_IO
1462 #ifdef POLARSSL_PKCS5_C
1464 FCT_TEST_BGN(x509_parse_key_18_pkcs8_encrypted_v2_pbdfk2_3des_der_wrong_pw)
1471 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbes2_pbkdf2_3des.der",
"PolarSSLTes" );
1488 #ifdef POLARSSL_DES_C
1489 #ifdef POLARSSL_SHA1_C
1490 #ifdef POLARSSL_FS_IO
1491 #ifdef POLARSSL_PKCS5_C
1493 FCT_TEST_BGN(x509_parse_key_19_pkcs8_encrypted_v2_pbdfk2_3des_der_no_pw)
1517 #ifdef POLARSSL_DES_C
1518 #ifdef POLARSSL_SHA1_C
1519 #ifdef POLARSSL_PEM_C
1520 #ifdef POLARSSL_FS_IO
1521 #ifdef POLARSSL_PKCS5_C
1523 FCT_TEST_BGN(x509_parse_key_20_pkcs8_encrypted_v2_pbdfk2_des)
1530 res =
x509parse_keyfile( &rsa,
"data_files/pkcs8_pbes2_pbkdf2_des.key",
"PolarSSLTest" );
1532 fct_chk( res == 0 );
1548 #ifdef POLARSSL_MD5_C
1549 #ifdef POLARSSL_PEM_C
1550 #ifdef POLARSSL_FS_IO
1552 FCT_TEST_BGN(x509_parse_public_key_1_pkcs8_wrapped)
1561 fct_chk( res == 0 );
1575 #ifdef POLARSSL_PEM_C
1576 #ifdef POLARSSL_FS_IO
1578 FCT_TEST_BGN(x509_get_distinguished_name_1)
1585 memset( buf, 0, 2000 );
1592 fct_chk( res != -1 );
1593 fct_chk( res != -2 );
1595 fct_chk( strcmp( buf,
"C=NL, O=PolarSSL, CN=PolarSSL Server 1" ) == 0 );
1601 #ifdef POLARSSL_PEM_C
1602 #ifdef POLARSSL_FS_IO
1604 FCT_TEST_BGN(x509_get_distinguished_name_2)
1611 memset( buf, 0, 2000 );
1618 fct_chk( res != -1 );
1619 fct_chk( res != -2 );
1621 fct_chk( strcmp( buf,
"C=NL, O=PolarSSL, CN=PolarSSL Test CA" ) == 0 );
1627 #ifdef POLARSSL_PEM_C
1628 #ifdef POLARSSL_FS_IO
1630 FCT_TEST_BGN(x509_get_distinguished_name_3)
1637 memset( buf, 0, 2000 );
1644 fct_chk( res != -1 );
1645 fct_chk( res != -2 );
1647 fct_chk( strcmp( buf,
"C=NL, O=PolarSSL, CN=localhost" ) == 0 );
1653 #ifdef POLARSSL_PEM_C
1654 #ifdef POLARSSL_FS_IO
1656 FCT_TEST_BGN(x509_get_distinguished_name_4)
1663 memset( buf, 0, 2000 );
1670 fct_chk( res != -1 );
1671 fct_chk( res != -2 );
1673 fct_chk( strcmp( buf,
"C=NL, O=PolarSSL, CN=PolarSSL Test CA" ) == 0 );
1679 #ifdef POLARSSL_PEM_C
1680 #ifdef POLARSSL_FS_IO
1682 FCT_TEST_BGN(x509_time_expired_1)
1697 #ifdef POLARSSL_PEM_C
1698 #ifdef POLARSSL_FS_IO
1700 FCT_TEST_BGN(x509_time_expired_2)
1715 #ifdef POLARSSL_PEM_C
1716 #ifdef POLARSSL_FS_IO
1718 FCT_TEST_BGN(x509_time_expired_3)
1733 #ifdef POLARSSL_PEM_C
1734 #ifdef POLARSSL_FS_IO
1736 FCT_TEST_BGN(x509_time_expired_4)
1751 #ifdef POLARSSL_PEM_C
1752 #ifdef POLARSSL_FS_IO
1754 FCT_TEST_BGN(x509_time_expired_5)
1769 #ifdef POLARSSL_PEM_C
1770 #ifdef POLARSSL_FS_IO
1772 FCT_TEST_BGN(x509_time_expired_6polarssl_fs_io)
1787 #ifdef POLARSSL_PEM_C
1788 #ifdef POLARSSL_FS_IO
1790 FCT_TEST_BGN(x509_certificate_verification_1_revoked_cert_expired_crl)
1800 memset( &crl, 0,
sizeof(
x509_crl ) );
1819 #ifdef POLARSSL_PEM_C
1820 #ifdef POLARSSL_FS_IO
1822 FCT_TEST_BGN(x509_certificate_verification_2_revoked_cert_expired_crl)
1832 memset( &crl, 0,
sizeof(
x509_crl ) );
1838 res =
x509parse_verify( &crt, &ca, &crl,
"PolarSSL Server 1", &flags, NULL, NULL );
1851 #ifdef POLARSSL_PEM_C
1852 #ifdef POLARSSL_FS_IO
1854 FCT_TEST_BGN(x509_certificate_verification_3_revoked_cert_expired_crl_cn_mismatch)
1864 memset( &crl, 0,
sizeof(
x509_crl ) );
1870 res =
x509parse_verify( &crt, &ca, &crl,
"PolarSSL Wrong CN", &flags, NULL, NULL );
1883 #ifdef POLARSSL_PEM_C
1884 #ifdef POLARSSL_FS_IO
1886 FCT_TEST_BGN(x509_certificate_verification_4_valid_cert_expired_crl)
1896 memset( &crl, 0,
sizeof(
x509_crl ) );
1915 #ifdef POLARSSL_PEM_C
1916 #ifdef POLARSSL_FS_IO
1918 FCT_TEST_BGN(x509_certificate_verification_5_revoked_cert)
1928 memset( &crl, 0,
sizeof(
x509_crl ) );
1947 #ifdef POLARSSL_PEM_C
1948 #ifdef POLARSSL_FS_IO
1950 FCT_TEST_BGN(x509_certificate_verification_6_revoked_cert)
1960 memset( &crl, 0,
sizeof(
x509_crl ) );
1966 res =
x509parse_verify( &crt, &ca, &crl,
"PolarSSL Server 1", &flags, NULL, NULL );
1979 #ifdef POLARSSL_PEM_C
1980 #ifdef POLARSSL_FS_IO
1982 FCT_TEST_BGN(x509_certificate_verification_7_revoked_cert_cn_mismatch)
1992 memset( &crl, 0,
sizeof(
x509_crl ) );
1998 res =
x509parse_verify( &crt, &ca, &crl,
"PolarSSL Wrong CN", &flags, NULL, NULL );
2011 #ifdef POLARSSL_PEM_C
2012 #ifdef POLARSSL_FS_IO
2014 FCT_TEST_BGN(x509_certificate_verification_8_valid_cert)
2024 memset( &crl, 0,
sizeof(
x509_crl ) );
2036 fct_chk( res == ( 0 ) );
2037 fct_chk( flags == ( 0 ) );
2043 #ifdef POLARSSL_PEM_C
2044 #ifdef POLARSSL_FS_IO
2046 FCT_TEST_BGN(x509_certificate_verification_9_not_trusted_cert)
2056 memset( &crl, 0,
sizeof(
x509_crl ) );
2075 #ifdef POLARSSL_PEM_C
2076 #ifdef POLARSSL_FS_IO
2078 FCT_TEST_BGN(x509_certificate_verification_10_not_trusted_cert_expired_crl)
2088 memset( &crl, 0,
sizeof(
x509_crl ) );
2107 #ifdef POLARSSL_MD4_C
2108 #ifdef POLARSSL_PEM_C
2109 #ifdef POLARSSL_FS_IO
2111 FCT_TEST_BGN(x509_certificate_verification_12_valid_cert_md4_digest)
2121 memset( &crl, 0,
sizeof(
x509_crl ) );
2133 fct_chk( res == ( 0 ) );
2134 fct_chk( flags == ( 0 ) );
2141 #ifdef POLARSSL_MD5_C
2142 #ifdef POLARSSL_PEM_C
2143 #ifdef POLARSSL_FS_IO
2145 FCT_TEST_BGN(x509_certificate_verification_13_valid_cert_md5_digest)
2155 memset( &crl, 0,
sizeof(
x509_crl ) );
2167 fct_chk( res == ( 0 ) );
2168 fct_chk( flags == ( 0 ) );
2175 #ifdef POLARSSL_SHA1_C
2176 #ifdef POLARSSL_PEM_C
2177 #ifdef POLARSSL_FS_IO
2179 FCT_TEST_BGN(x509_certificate_verification_14_valid_cert_sha1_digest)
2189 memset( &crl, 0,
sizeof(
x509_crl ) );
2201 fct_chk( res == ( 0 ) );
2202 fct_chk( flags == ( 0 ) );
2209 #ifdef POLARSSL_SHA2_C
2210 #ifdef POLARSSL_PEM_C
2211 #ifdef POLARSSL_FS_IO
2213 FCT_TEST_BGN(x509_certificate_verification_15_valid_cert_sha224_digest)
2223 memset( &crl, 0,
sizeof(
x509_crl ) );
2235 fct_chk( res == ( 0 ) );
2236 fct_chk( flags == ( 0 ) );
2243 #ifdef POLARSSL_SHA2_C
2244 #ifdef POLARSSL_PEM_C
2245 #ifdef POLARSSL_FS_IO
2247 FCT_TEST_BGN(x509_certificate_verification_16_valid_cert_sha256_digest)
2257 memset( &crl, 0,
sizeof(
x509_crl ) );
2269 fct_chk( res == ( 0 ) );
2270 fct_chk( flags == ( 0 ) );
2277 #ifdef POLARSSL_SHA4_C
2278 #ifdef POLARSSL_PEM_C
2279 #ifdef POLARSSL_FS_IO
2281 FCT_TEST_BGN(x509_certificate_verification_17_valid_cert_sha384_digest)
2291 memset( &crl, 0,
sizeof(
x509_crl ) );
2303 fct_chk( res == ( 0 ) );
2304 fct_chk( flags == ( 0 ) );
2311 #ifdef POLARSSL_SHA4_C
2312 #ifdef POLARSSL_PEM_C
2313 #ifdef POLARSSL_FS_IO
2315 FCT_TEST_BGN(x509_certificate_verification_18_valid_cert_sha512_digest)
2325 memset( &crl, 0,
sizeof(
x509_crl ) );
2337 fct_chk( res == ( 0 ) );
2338 fct_chk( flags == ( 0 ) );
2345 #ifdef POLARSSL_SHA4_C
2346 #ifdef POLARSSL_PEM_C
2347 #ifdef POLARSSL_FS_IO
2349 FCT_TEST_BGN(x509_certificate_verification_19_valid_cert_denying_callback)
2359 memset( &crl, 0,
sizeof(
x509_crl ) );
2379 #ifdef POLARSSL_PEM_C
2380 #ifdef POLARSSL_FS_IO
2382 FCT_TEST_BGN(x509_certificate_verification_20_not_trusted_cert_allowing_callback)
2392 memset( &crl, 0,
sizeof(
x509_crl ) );
2404 fct_chk( res == ( 0 ) );
2405 fct_chk( flags == ( 0 ) );
2411 #ifdef POLARSSL_PEM_C
2412 #ifdef POLARSSL_FS_IO
2414 FCT_TEST_BGN(x509_certificate_verification_21_domain_matching_wildcard_certificate)
2424 memset( &crl, 0,
sizeof(
x509_crl ) );
2426 fct_chk(
x509parse_crtfile( &crt,
"data_files/cert_example_wildcard.crt" ) == 0 );
2430 res =
x509parse_verify( &crt, &ca, &crl,
"mail.example.com", &flags, NULL, NULL );
2436 fct_chk( res == ( 0 ) );
2437 fct_chk( flags == ( 0 ) );
2443 #ifdef POLARSSL_PEM_C
2444 #ifdef POLARSSL_FS_IO
2446 FCT_TEST_BGN(x509_certificate_verification_22_domain_not_matching_wildcard_certificate)
2456 memset( &crl, 0,
sizeof(
x509_crl ) );
2458 fct_chk(
x509parse_crtfile( &crt,
"data_files/cert_example_wildcard.crt" ) == 0 );
2462 res =
x509parse_verify( &crt, &ca, &crl,
"mail.example.net", &flags, NULL, NULL );
2475 #ifdef POLARSSL_PEM_C
2476 #ifdef POLARSSL_FS_IO
2478 FCT_TEST_BGN(x509_certificate_verification_23_domain_not_matching_wildcard_certificate)
2488 memset( &crl, 0,
sizeof(
x509_crl ) );
2490 fct_chk(
x509parse_crtfile( &crt,
"data_files/cert_example_wildcard.crt" ) == 0 );
2494 res =
x509parse_verify( &crt, &ca, &crl,
"example.com", &flags, NULL, NULL );
2507 #ifdef POLARSSL_PEM_C
2508 #ifdef POLARSSL_FS_IO
2510 FCT_TEST_BGN(x509_certificate_verification_24_domain_matching_cn_of_multi_certificate)
2520 memset( &crl, 0,
sizeof(
x509_crl ) );
2526 res =
x509parse_verify( &crt, &ca, &crl,
"www.example.com", &flags, NULL, NULL );
2539 #ifdef POLARSSL_PEM_C
2540 #ifdef POLARSSL_FS_IO
2542 FCT_TEST_BGN(x509_certificate_verification_25_domain_matching_multi_certificate)
2552 memset( &crl, 0,
sizeof(
x509_crl ) );
2558 res =
x509parse_verify( &crt, &ca, &crl,
"example.net", &flags, NULL, NULL );
2564 fct_chk( res == ( 0 ) );
2565 fct_chk( flags == ( 0 ) );
2571 #ifdef POLARSSL_PEM_C
2572 #ifdef POLARSSL_FS_IO
2574 FCT_TEST_BGN(x509_certificate_verification_26_domain_not_matching_multi_certificate)
2584 memset( &crl, 0,
sizeof(
x509_crl ) );
2590 res =
x509parse_verify( &crt, &ca, &crl,
"www.example.net", &flags, NULL, NULL );
2603 #ifdef POLARSSL_PEM_C
2604 #ifdef POLARSSL_FS_IO
2606 FCT_TEST_BGN(x509_certificate_verification_27_domain_not_matching_multi_certificate)
2616 memset( &crl, 0,
sizeof(
x509_crl ) );
2622 res =
x509parse_verify( &crt, &ca, &crl,
"xample.net", &flags, NULL, NULL );
2635 #ifdef POLARSSL_PEM_C
2636 #ifdef POLARSSL_FS_IO
2638 FCT_TEST_BGN(x509_certificate_verification_27_domain_not_matching_multi_certificate)
2648 memset( &crl, 0,
sizeof(
x509_crl ) );
2654 res =
x509parse_verify( &crt, &ca, &crl,
"bexample.net", &flags, NULL, NULL );
2667 #ifdef POLARSSL_PEM_C
2668 #ifdef POLARSSL_FS_IO
2670 FCT_TEST_BGN(x509_certificate_verification_28_domain_not_matching_wildcard_in_multi_certificate)
2680 memset( &crl, 0,
sizeof(
x509_crl ) );
2686 res =
x509parse_verify( &crt, &ca, &crl,
"example.org", &flags, NULL, NULL );
2699 #ifdef POLARSSL_PEM_C
2700 #ifdef POLARSSL_FS_IO
2702 FCT_TEST_BGN(x509_certificate_verification_29_domain_matching_wildcard_in_multi_certificate)
2712 memset( &crl, 0,
sizeof(
x509_crl ) );
2718 res =
x509parse_verify( &crt, &ca, &crl,
"mail.example.org", &flags, NULL, NULL );
2724 fct_chk( res == ( 0 ) );
2725 fct_chk( flags == ( 0 ) );
2731 #ifdef POLARSSL_PEM_C
2732 #ifdef POLARSSL_FS_IO
2734 FCT_TEST_BGN(x509_certificate_verification_30_domain_matching_multi_certificate_without_cn)
2744 memset( &crl, 0,
sizeof(
x509_crl ) );
2746 fct_chk(
x509parse_crtfile( &crt,
"data_files/cert_example_multi_nocn.crt" ) == 0 );
2750 res =
x509parse_verify( &crt, &ca, &crl,
"www.shotokan-braunschweig.de", &flags, NULL, NULL );
2763 #ifdef POLARSSL_PEM_C
2764 #ifdef POLARSSL_FS_IO
2766 FCT_TEST_BGN(x509_certificate_verification_31_domain_not_matching_multi_certificate_without_cn)
2776 memset( &crl, 0,
sizeof(
x509_crl ) );
2778 fct_chk(
x509parse_crtfile( &crt,
"data_files/cert_example_multi_nocn.crt" ) == 0 );
2782 res =
x509parse_verify( &crt, &ca, &crl,
"www.example.net", &flags, NULL, NULL );
2795 #ifdef POLARSSL_MD5_C
2796 #ifdef POLARSSL_PEM_C
2797 #ifdef POLARSSL_SELF_TEST
2799 FCT_TEST_BGN(x509_parse_selftest)
2809 FCT_TEST_BGN(x509_certificate_asn1_incorrect_first_tag)
2812 unsigned char buf[2000];
2813 unsigned char output[2000];
2817 memset( buf, 0, 2000 );
2818 memset( output, 0, 2000 );
2827 fct_chk( res != -1 );
2828 fct_chk( res != -2 );
2830 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
2838 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_data_length_does_not_match)
2841 unsigned char buf[2000];
2842 unsigned char output[2000];
2846 memset( buf, 0, 2000 );
2847 memset( output, 0, 2000 );
2849 data_len =
unhexify( buf,
"300000" );
2856 fct_chk( res != -1 );
2857 fct_chk( res != -2 );
2859 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
2867 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_no_more_data)
2870 unsigned char buf[2000];
2871 unsigned char output[2000];
2875 memset( buf, 0, 2000 );
2876 memset( output, 0, 2000 );
2878 data_len =
unhexify( buf,
"3000" );
2885 fct_chk( res != -1 );
2886 fct_chk( res != -2 );
2888 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
2896 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_length_data_incorrect)
2899 unsigned char buf[2000];
2900 unsigned char output[2000];
2904 memset( buf, 0, 2000 );
2905 memset( output, 0, 2000 );
2907 data_len =
unhexify( buf,
"30023085" );
2914 fct_chk( res != -1 );
2915 fct_chk( res != -2 );
2917 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
2925 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_length_data_incomplete)
2928 unsigned char buf[2000];
2929 unsigned char output[2000];
2933 memset( buf, 0, 2000 );
2934 memset( output, 0, 2000 );
2936 data_len =
unhexify( buf,
"30023083" );
2943 fct_chk( res != -1 );
2944 fct_chk( res != -2 );
2946 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
2954 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_length_data_incomplete)
2957 unsigned char buf[2000];
2958 unsigned char output[2000];
2962 memset( buf, 0, 2000 );
2963 memset( output, 0, 2000 );
2965 data_len =
unhexify( buf,
"30023081" );
2972 fct_chk( res != -1 );
2973 fct_chk( res != -2 );
2975 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
2983 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_length_data_incomplete)
2986 unsigned char buf[2000];
2987 unsigned char output[2000];
2991 memset( buf, 0, 2000 );
2992 memset( output, 0, 2000 );
2994 data_len =
unhexify( buf,
"3003308200" );
3001 fct_chk( res != -1 );
3002 fct_chk( res != -2 );
3004 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3012 FCT_TEST_BGN(x509_certificate_asn1_correct_first_tag_second_tag_no_tbscertificate)
3015 unsigned char buf[2000];
3016 unsigned char output[2000];
3020 memset( buf, 0, 2000 );
3021 memset( output, 0, 2000 );
3023 data_len =
unhexify( buf,
"300100" );
3030 fct_chk( res != -1 );
3031 fct_chk( res != -2 );
3033 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3041 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_no_version_tag_serial_missing)
3044 unsigned char buf[2000];
3045 unsigned char output[2000];
3049 memset( buf, 0, 2000 );
3050 memset( output, 0, 2000 );
3052 data_len =
unhexify( buf,
"3003300100" );
3059 fct_chk( res != -1 );
3060 fct_chk( res != -2 );
3062 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3070 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_invalid_version_tag)
3073 unsigned char buf[2000];
3074 unsigned char output[2000];
3078 memset( buf, 0, 2000 );
3079 memset( output, 0, 2000 );
3081 data_len =
unhexify( buf,
"30053003a00101" );
3088 fct_chk( res != -1 );
3089 fct_chk( res != -2 );
3091 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3099 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_version_tag_no_length)
3102 unsigned char buf[2000];
3103 unsigned char output[2000];
3107 memset( buf, 0, 2000 );
3108 memset( output, 0, 2000 );
3110 data_len =
unhexify( buf,
"30053003a00102" );
3117 fct_chk( res != -1 );
3118 fct_chk( res != -2 );
3120 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3128 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_version_tag_invalid_length)
3131 unsigned char buf[2000];
3132 unsigned char output[2000];
3136 memset( buf, 0, 2000 );
3137 memset( output, 0, 2000 );
3139 data_len =
unhexify( buf,
"30163014a012021000000000000000000000000000000000" );
3146 fct_chk( res != -1 );
3147 fct_chk( res != -2 );
3149 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3157 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_version_tag_no_serial)
3160 unsigned char buf[2000];
3161 unsigned char output[2000];
3165 memset( buf, 0, 2000 );
3166 memset( output, 0, 2000 );
3168 data_len =
unhexify( buf,
"30073005a003020104" );
3175 fct_chk( res != -1 );
3176 fct_chk( res != -2 );
3178 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3186 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_invalid_length_version_tag)
3189 unsigned char buf[2000];
3190 unsigned char output[2000];
3194 memset( buf, 0, 2000 );
3195 memset( output, 0, 2000 );
3197 data_len =
unhexify( buf,
"30083006a00402010400" );
3204 fct_chk( res != -1 );
3205 fct_chk( res != -2 );
3207 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3215 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_incorrect_serial_tag)
3218 unsigned char buf[2000];
3219 unsigned char output[2000];
3223 memset( buf, 0, 2000 );
3224 memset( output, 0, 2000 );
3226 data_len =
unhexify( buf,
"30083006a00302010400" );
3233 fct_chk( res != -1 );
3234 fct_chk( res != -2 );
3236 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3244 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_incorrect_serial_length)
3247 unsigned char buf[2000];
3248 unsigned char output[2000];
3252 memset( buf, 0, 2000 );
3253 memset( output, 0, 2000 );
3255 data_len =
unhexify( buf,
"30083006a00302010482" );
3262 fct_chk( res != -1 );
3263 fct_chk( res != -2 );
3265 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3273 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_serial_no_alg)
3276 unsigned char buf[2000];
3277 unsigned char output[2000];
3281 memset( buf, 0, 2000 );
3282 memset( output, 0, 2000 );
3284 data_len =
unhexify( buf,
"300d300ba0030201048204deadbeef" );
3291 fct_chk( res != -1 );
3292 fct_chk( res != -2 );
3294 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3302 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_serial_no_alg_oid)
3305 unsigned char buf[2000];
3306 unsigned char output[2000];
3310 memset( buf, 0, 2000 );
3311 memset( output, 0, 2000 );
3313 data_len =
unhexify( buf,
"300e300ca0030201048204deadbeef00" );
3320 fct_chk( res != -1 );
3321 fct_chk( res != -2 );
3323 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3331 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_alg_oid_no_data_in_sequence)
3334 unsigned char buf[2000];
3335 unsigned char output[2000];
3339 memset( buf, 0, 2000 );
3340 memset( output, 0, 2000 );
3342 data_len =
unhexify( buf,
"300f300da0030201048204deadbeef3000" );
3349 fct_chk( res != -1 );
3350 fct_chk( res != -2 );
3352 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3360 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_alg_with_params)
3363 unsigned char buf[2000];
3364 unsigned char output[2000];
3368 memset( buf, 0, 2000 );
3369 memset( output, 0, 2000 );
3371 data_len =
unhexify( buf,
"30163014a0030201048204deadbeef30070604cafed00d01" );
3378 fct_chk( res != -1 );
3379 fct_chk( res != -2 );
3381 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3389 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_alg_data_no_params_unknown_version)
3392 unsigned char buf[2000];
3393 unsigned char output[2000];
3397 memset( buf, 0, 2000 );
3398 memset( output, 0, 2000 );
3400 data_len =
unhexify( buf,
"30153013a0030201048204deadbeef30060604cafed00d" );
3407 fct_chk( res != -1 );
3408 fct_chk( res != -2 );
3410 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3418 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_alg_data_unknown_version)
3421 unsigned char buf[2000];
3422 unsigned char output[2000];
3426 memset( buf, 0, 2000 );
3427 memset( output, 0, 2000 );
3429 data_len =
unhexify( buf,
"30173015a0030201048204deadbeef30080604cafed00d0500" );
3436 fct_chk( res != -1 );
3437 fct_chk( res != -2 );
3439 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3447 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_alg_data_length_mismatch)
3450 unsigned char buf[2000];
3451 unsigned char output[2000];
3455 memset( buf, 0, 2000 );
3456 memset( output, 0, 2000 );
3458 data_len =
unhexify( buf,
"30183016a0030201048204deadbeef30090604cafed00d050000" );
3465 fct_chk( res != -1 );
3466 fct_chk( res != -2 );
3468 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3476 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_alg_unknown_alg_id)
3479 unsigned char buf[2000];
3480 unsigned char output[2000];
3484 memset( buf, 0, 2000 );
3485 memset( output, 0, 2000 );
3487 data_len =
unhexify( buf,
"30173015a0030201028204deadbeef30080604cafed00d0500" );
3494 fct_chk( res != -1 );
3495 fct_chk( res != -2 );
3497 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3505 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_alg_specific_alg_id)
3508 unsigned char buf[2000];
3509 unsigned char output[2000];
3513 memset( buf, 0, 2000 );
3514 memset( output, 0, 2000 );
3516 data_len =
unhexify( buf,
"301c301aa0030201028204deadbeef300d06092a864886f70d0101020500" );
3523 fct_chk( res != -1 );
3524 fct_chk( res != -2 );
3526 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3534 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_correct_alg_unknown_specific_alg_id)
3537 unsigned char buf[2000];
3538 unsigned char output[2000];
3542 memset( buf, 0, 2000 );
3543 memset( output, 0, 2000 );
3545 data_len =
unhexify( buf,
"301c301aa0030201028204deadbeef300d06092a864886f70d0101010500" );
3552 fct_chk( res != -1 );
3553 fct_chk( res != -2 );
3555 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3563 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_no_set_data)
3566 unsigned char buf[2000];
3567 unsigned char output[2000];
3571 memset( buf, 0, 2000 );
3572 memset( output, 0, 2000 );
3574 data_len =
unhexify( buf,
"301e301ca0030201028204deadbeef300d06092a864886f70d01010205003000" );
3581 fct_chk( res != -1 );
3582 fct_chk( res != -2 );
3584 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3592 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_no_inner_seq_data)
3595 unsigned char buf[2000];
3596 unsigned char output[2000];
3600 memset( buf, 0, 2000 );
3601 memset( output, 0, 2000 );
3603 data_len =
unhexify( buf,
"3020301ea0030201028204deadbeef300d06092a864886f70d010102050030023100" );
3610 fct_chk( res != -1 );
3611 fct_chk( res != -2 );
3613 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3621 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_no_inner_set_data)
3624 unsigned char buf[2000];
3625 unsigned char output[2000];
3629 memset( buf, 0, 2000 );
3630 memset( output, 0, 2000 );
3632 data_len =
unhexify( buf,
"30223020a0030201028204deadbeef300d06092a864886f70d0101020500300431023000" );
3639 fct_chk( res != -1 );
3640 fct_chk( res != -2 );
3642 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3650 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_two_inner_set_datas)
3653 unsigned char buf[2000];
3654 unsigned char output[2000];
3658 memset( buf, 0, 2000 );
3659 memset( output, 0, 2000 );
3661 data_len =
unhexify( buf,
"30243022a0030201028204deadbeef300d06092a864886f70d01010205003006310430003000" );
3668 fct_chk( res != -1 );
3669 fct_chk( res != -2 );
3671 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3679 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_no_oid_data)
3682 unsigned char buf[2000];
3683 unsigned char output[2000];
3687 memset( buf, 0, 2000 );
3688 memset( output, 0, 2000 );
3690 data_len =
unhexify( buf,
"30243022a0030201028204deadbeef300d06092a864886f70d01010205003006310430020600" );
3697 fct_chk( res != -1 );
3698 fct_chk( res != -2 );
3700 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3708 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_invalid_tag)
3711 unsigned char buf[2000];
3712 unsigned char output[2000];
3716 memset( buf, 0, 2000 );
3717 memset( output, 0, 2000 );
3719 data_len =
unhexify( buf,
"302a3028a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600060454657374" );
3726 fct_chk( res != -1 );
3727 fct_chk( res != -2 );
3729 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3737 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_no_string_data)
3740 unsigned char buf[2000];
3741 unsigned char output[2000];
3745 memset( buf, 0, 2000 );
3746 memset( output, 0, 2000 );
3748 data_len =
unhexify( buf,
"30253023a0030201028204deadbeef300d06092a864886f70d0101020500300731053003060013" );
3755 fct_chk( res != -1 );
3756 fct_chk( res != -2 );
3758 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3766 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_issuer_no_full_following_string)
3769 unsigned char buf[2000];
3770 unsigned char output[2000];
3774 memset( buf, 0, 2000 );
3775 memset( output, 0, 2000 );
3777 data_len =
unhexify( buf,
"302b3029a0030201028204deadbeef300d06092a864886f70d0101020500300d310b3009060013045465737400" );
3784 fct_chk( res != -1 );
3785 fct_chk( res != -2 );
3787 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3795 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_issuer_no_validity)
3798 unsigned char buf[2000];
3799 unsigned char output[2000];
3803 memset( buf, 0, 2000 );
3804 memset( output, 0, 2000 );
3806 data_len =
unhexify( buf,
"302a3028a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374" );
3813 fct_chk( res != -1 );
3814 fct_chk( res != -2 );
3816 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3824 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_too_much_date_data)
3827 unsigned char buf[2000];
3828 unsigned char output[2000];
3832 memset( buf, 0, 2000 );
3833 memset( output, 0, 2000 );
3835 data_len =
unhexify( buf,
"30493047a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301d170c303930313031303030303030170c30393132333132333539353900" );
3842 fct_chk( res != -1 );
3843 fct_chk( res != -2 );
3845 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3853 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_invalid_from_date)
3856 unsigned char buf[2000];
3857 unsigned char output[2000];
3861 memset( buf, 0, 2000 );
3862 memset( output, 0, 2000 );
3864 data_len =
unhexify( buf,
"30483046a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303000000000170c303931323331323300000000" );
3871 fct_chk( res != -1 );
3872 fct_chk( res != -2 );
3874 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3882 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_invalid_to_date)
3885 unsigned char buf[2000];
3886 unsigned char output[2000];
3890 memset( buf, 0, 2000 );
3891 memset( output, 0, 2000 );
3893 data_len =
unhexify( buf,
"30483046a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323300000000" );
3900 fct_chk( res != -1 );
3901 fct_chk( res != -2 );
3903 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3911 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_validity_no_subject)
3914 unsigned char buf[2000];
3915 unsigned char output[2000];
3919 memset( buf, 0, 2000 );
3920 memset( output, 0, 2000 );
3922 data_len =
unhexify( buf,
"30493047a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c30393132333132333539353930" );
3929 fct_chk( res != -1 );
3930 fct_chk( res != -2 );
3932 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3940 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_subject_no_pubkeyinfo)
3943 unsigned char buf[2000];
3944 unsigned char output[2000];
3948 memset( buf, 0, 2000 );
3949 memset( output, 0, 2000 );
3951 data_len =
unhexify( buf,
"30563054a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374" );
3958 fct_chk( res != -1 );
3959 fct_chk( res != -2 );
3961 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3969 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_no_alg)
3972 unsigned char buf[2000];
3973 unsigned char output[2000];
3977 memset( buf, 0, 2000 );
3978 memset( output, 0, 2000 );
3980 data_len =
unhexify( buf,
"30583056a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743000" );
3987 fct_chk( res != -1 );
3988 fct_chk( res != -2 );
3990 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
3998 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_valid_subject_unknown_pk_alg)
4001 unsigned char buf[2000];
4002 unsigned char output[2000];
4006 memset( buf, 0, 2000 );
4007 memset( output, 0, 2000 );
4009 data_len =
unhexify( buf,
"30673065a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374300f300d06092A864886F70D0101000500" );
4016 fct_chk( res != -1 );
4017 fct_chk( res != -2 );
4019 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4027 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_no_bitstring)
4030 unsigned char buf[2000];
4031 unsigned char output[2000];
4035 memset( buf, 0, 2000 );
4036 memset( output, 0, 2000 );
4038 data_len =
unhexify( buf,
"30673065a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374300f300d06092A864886F70D0101010500" );
4045 fct_chk( res != -1 );
4046 fct_chk( res != -2 );
4048 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4056 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_no_bitstring_data)
4059 unsigned char buf[2000];
4060 unsigned char output[2000];
4064 memset( buf, 0, 2000 );
4065 memset( output, 0, 2000 );
4067 data_len =
unhexify( buf,
"30693067a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743011300d06092A864886F70D01010105000300" );
4074 fct_chk( res != -1 );
4075 fct_chk( res != -2 );
4077 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4085 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_invalid_bitstring_start)
4088 unsigned char buf[2000];
4089 unsigned char output[2000];
4093 memset( buf, 0, 2000 );
4094 memset( output, 0, 2000 );
4096 data_len =
unhexify( buf,
"306a3068a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743012300d06092A864886F70D0101010500030101" );
4103 fct_chk( res != -1 );
4104 fct_chk( res != -2 );
4106 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4114 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_invalid_internal_bitstring_length)
4117 unsigned char buf[2000];
4118 unsigned char output[2000];
4122 memset( buf, 0, 2000 );
4123 memset( output, 0, 2000 );
4125 data_len =
unhexify( buf,
"306d306ba0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743015300d06092A864886F70D0101010500030400300000" );
4132 fct_chk( res != -1 );
4133 fct_chk( res != -2 );
4135 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4143 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_invalid_internal_bitstring_tag)
4146 unsigned char buf[2000];
4147 unsigned char output[2000];
4151 memset( buf, 0, 2000 );
4152 memset( output, 0, 2000 );
4154 data_len =
unhexify( buf,
"306d306ba0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743015300d06092A864886F70D0101010500030400310000" );
4161 fct_chk( res != -1 );
4162 fct_chk( res != -2 );
4164 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4172 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_invalid_mpi)
4175 unsigned char buf[2000];
4176 unsigned char output[2000];
4180 memset( buf, 0, 2000 );
4181 memset( output, 0, 2000 );
4183 data_len =
unhexify( buf,
"30743072a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301c300d06092A864886F70D0101010500030b0030080202ffff0302ffff" );
4190 fct_chk( res != -1 );
4191 fct_chk( res != -2 );
4193 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4201 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_total_length_mismatch)
4204 unsigned char buf[2000];
4205 unsigned char output[2000];
4209 memset( buf, 0, 2000 );
4210 memset( output, 0, 2000 );
4212 data_len =
unhexify( buf,
"30753073a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301d300d06092A864886F70D0101010500030b0030080202ffff0202ffff00" );
4219 fct_chk( res != -1 );
4220 fct_chk( res != -2 );
4222 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4230 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_check_failed)
4233 unsigned char buf[2000];
4234 unsigned char output[2000];
4238 memset( buf, 0, 2000 );
4239 memset( output, 0, 2000 );
4241 data_len =
unhexify( buf,
"30743072a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301c300d06092A864886F70D0101010500030b0030080202ffff0202ffff" );
4248 fct_chk( res != -1 );
4249 fct_chk( res != -2 );
4251 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4259 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_pubkey_check_failed_expanded_length_notation)
4262 unsigned char buf[2000];
4263 unsigned char output[2000];
4267 memset( buf, 0, 2000 );
4268 memset( output, 0, 2000 );
4270 data_len =
unhexify( buf,
"308183308180a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210fffffffffffffffffffffffffffffffe0202ffff" );
4277 fct_chk( res != -1 );
4278 fct_chk( res != -2 );
4280 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4288 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_optional_uids_extensions_not_present)
4291 unsigned char buf[2000];
4292 unsigned char output[2000];
4296 memset( buf, 0, 2000 );
4297 memset( output, 0, 2000 );
4299 data_len =
unhexify( buf,
"308183308180a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff" );
4306 fct_chk( res != -1 );
4307 fct_chk( res != -2 );
4309 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4317 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_issuerid_wrong_tag)
4320 unsigned char buf[2000];
4321 unsigned char output[2000];
4325 memset( buf, 0, 2000 );
4326 memset( output, 0, 2000 );
4328 data_len =
unhexify( buf,
"308184308181a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff00" );
4335 fct_chk( res != -1 );
4336 fct_chk( res != -2 );
4338 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4346 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_uids_no_ext)
4349 unsigned char buf[2000];
4350 unsigned char output[2000];
4354 memset( buf, 0, 2000 );
4355 memset( output, 0, 2000 );
4357 data_len =
unhexify( buf,
"308189308186a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bb" );
4364 fct_chk( res != -1 );
4365 fct_chk( res != -2 );
4367 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4375 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_uids_invalid_length)
4378 unsigned char buf[2000];
4379 unsigned char output[2000];
4383 memset( buf, 0, 2000 );
4384 memset( output, 0, 2000 );
4386 data_len =
unhexify( buf,
"308189308186a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa185aaa201bb" );
4393 fct_chk( res != -1 );
4394 fct_chk( res != -2 );
4396 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4404 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_empty)
4407 unsigned char buf[2000];
4408 unsigned char output[2000];
4412 memset( buf, 0, 2000 );
4413 memset( output, 0, 2000 );
4415 data_len =
unhexify( buf,
"30818b308188a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba300" );
4422 fct_chk( res != -1 );
4423 fct_chk( res != -2 );
4425 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4433 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_length_mismatch)
4436 unsigned char buf[2000];
4437 unsigned char output[2000];
4441 memset( buf, 0, 2000 );
4442 memset( output, 0, 2000 );
4444 data_len =
unhexify( buf,
"30818e30818ba0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba303300000" );
4451 fct_chk( res != -1 );
4452 fct_chk( res != -2 );
4454 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4462 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_first_ext_invalid)
4465 unsigned char buf[2000];
4466 unsigned char output[2000];
4470 memset( buf, 0, 2000 );
4471 memset( output, 0, 2000 );
4473 data_len =
unhexify( buf,
"30818f30818ca0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30330023000" );
4480 fct_chk( res != -1 );
4481 fct_chk( res != -2 );
4483 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4491 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_first_ext_invalid_tag)
4494 unsigned char buf[2000];
4495 unsigned char output[2000];
4499 memset( buf, 0, 2000 );
4500 memset( output, 0, 2000 );
4502 data_len =
unhexify( buf,
"30819030818da0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba3043002310000" );
4509 fct_chk( res != -1 );
4510 fct_chk( res != -2 );
4512 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4520 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_basiccontraint_tag_bool_len_missing)
4523 unsigned char buf[2000];
4524 unsigned char output[2000];
4528 memset( buf, 0, 2000 );
4529 memset( output, 0, 2000 );
4531 data_len =
unhexify( buf,
"308198308195a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30c300a30060603551d1301010100" );
4538 fct_chk( res != -1 );
4539 fct_chk( res != -2 );
4541 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4549 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_basiccontraint_tag_data_missing)
4552 unsigned char buf[2000];
4553 unsigned char output[2000];
4557 memset( buf, 0, 2000 );
4558 memset( output, 0, 2000 );
4560 data_len =
unhexify( buf,
"308198308195a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30c300a30080603551d1301010100" );
4567 fct_chk( res != -1 );
4568 fct_chk( res != -2 );
4570 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4578 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_basiccontraint_tag_no_octet_present)
4581 unsigned char buf[2000];
4582 unsigned char output[2000];
4586 memset( buf, 0, 2000 );
4587 memset( output, 0, 2000 );
4589 data_len =
unhexify( buf,
"308198308195a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30d300b30090603551d1301010100" );
4596 fct_chk( res != -1 );
4597 fct_chk( res != -2 );
4599 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4607 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_basiccontraint_tag_octet_data_missing)
4610 unsigned char buf[2000];
4611 unsigned char output[2000];
4615 memset( buf, 0, 2000 );
4616 memset( output, 0, 2000 );
4618 data_len =
unhexify( buf,
"30819c308199a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba311300f300d0603551d130101010403300100" );
4625 fct_chk( res != -1 );
4626 fct_chk( res != -2 );
4628 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4636 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_basiccontraint_tag_no_pathlen)
4639 unsigned char buf[2000];
4640 unsigned char output[2000];
4644 memset( buf, 0, 2000 );
4645 memset( output, 0, 2000 );
4647 data_len =
unhexify( buf,
"30819f30819ca0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba314301230100603551d130101010406300402010102" );
4654 fct_chk( res != -1 );
4655 fct_chk( res != -2 );
4657 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4665 FCT_TEST_BGN(x509_certificate_asn1_tbscertificate_v3_ext_basiccontraint_tag_octet_len_mismatch)
4668 unsigned char buf[2000];
4669 unsigned char output[2000];
4673 memset( buf, 0, 2000 );
4674 memset( output, 0, 2000 );
4676 data_len =
unhexify( buf,
"3081a230819fa0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba317301530130603551d130101010409300702010102010100" );
4683 fct_chk( res != -1 );
4684 fct_chk( res != -2 );
4686 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4694 FCT_TEST_BGN(x509_certificate_asn1_correct_pubkey_no_sig_alg)
4697 unsigned char buf[2000];
4698 unsigned char output[2000];
4702 memset( buf, 0, 2000 );
4703 memset( output, 0, 2000 );
4705 data_len =
unhexify( buf,
"308183308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff" );
4712 fct_chk( res != -1 );
4713 fct_chk( res != -2 );
4715 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4723 FCT_TEST_BGN(x509_certificate_asn1_sig_alg_mismatch)
4726 unsigned char buf[2000];
4727 unsigned char output[2000];
4731 memset( buf, 0, 2000 );
4732 memset( output, 0, 2000 );
4734 data_len =
unhexify( buf,
"308192308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0102020500" );
4741 fct_chk( res != -1 );
4742 fct_chk( res != -2 );
4744 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4752 FCT_TEST_BGN(x509_certificate_asn1_sig_alg_no_sig)
4755 unsigned char buf[2000];
4756 unsigned char output[2000];
4760 memset( buf, 0, 2000 );
4761 memset( output, 0, 2000 );
4763 data_len =
unhexify( buf,
"308192308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500" );
4770 fct_chk( res != -1 );
4771 fct_chk( res != -2 );
4773 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4781 FCT_TEST_BGN(x509_certificate_asn1_signature_invalid_sig_data)
4784 unsigned char buf[2000];
4785 unsigned char output[2000];
4789 memset( buf, 0, 2000 );
4790 memset( output, 0, 2000 );
4792 data_len =
unhexify( buf,
"308195308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030100" );
4799 fct_chk( res != -1 );
4800 fct_chk( res != -2 );
4802 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4810 FCT_TEST_BGN(x509_certificate_asn1_signature_data_left)
4813 unsigned char buf[2000];
4814 unsigned char output[2000];
4818 memset( buf, 0, 2000 );
4819 memset( output, 0, 2000 );
4821 data_len =
unhexify( buf,
"308197308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff00" );
4828 fct_chk( res != -1 );
4829 fct_chk( res != -2 );
4831 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
4839 FCT_TEST_BGN(x509_certificate_asn1_correct)
4842 unsigned char buf[2000];
4843 unsigned char output[2000];
4847 memset( buf, 0, 2000 );
4848 memset( output, 0, 2000 );
4850 data_len =
unhexify( buf,
"308196308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
4857 fct_chk( res != -1 );
4858 fct_chk( res != -2 );
4860 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : ?\?=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
4868 FCT_TEST_BGN(x509_certificate_asn1_generalizedtime_instead_of_utctime)
4871 unsigned char buf[2000];
4872 unsigned char output[2000];
4876 memset( buf, 0, 2000 );
4877 memset( output, 0, 2000 );
4879 data_len =
unhexify( buf,
"308198308182a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301e180e3230313030313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
4886 fct_chk( res != -1 );
4887 fct_chk( res != -2 );
4889 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : ?\?=Test\nsubject name : ?\?=Test\nissued on : 2010-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
4897 FCT_TEST_BGN(x509_certificate_asn1_name_with_x520_cn)
4900 unsigned char buf[2000];
4901 unsigned char output[2000];
4905 memset( buf, 0, 2000 );
4906 memset( output, 0, 2000 );
4908 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550403130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
4915 fct_chk( res != -1 );
4916 fct_chk( res != -2 );
4918 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : CN=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
4926 FCT_TEST_BGN(x509_certificate_asn1_name_with_x520_c)
4929 unsigned char buf[2000];
4930 unsigned char output[2000];
4934 memset( buf, 0, 2000 );
4935 memset( output, 0, 2000 );
4937 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550406130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
4944 fct_chk( res != -1 );
4945 fct_chk( res != -2 );
4947 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : C=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
4955 FCT_TEST_BGN(x509_certificate_asn1_name_with_x520_l)
4958 unsigned char buf[2000];
4959 unsigned char output[2000];
4963 memset( buf, 0, 2000 );
4964 memset( output, 0, 2000 );
4966 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550407130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
4973 fct_chk( res != -1 );
4974 fct_chk( res != -2 );
4976 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : L=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
4984 FCT_TEST_BGN(x509_certificate_asn1_name_with_x520_st)
4987 unsigned char buf[2000];
4988 unsigned char output[2000];
4992 memset( buf, 0, 2000 );
4993 memset( output, 0, 2000 );
4995 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550408130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
5002 fct_chk( res != -1 );
5003 fct_chk( res != -2 );
5005 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : ST=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
5013 FCT_TEST_BGN(x509_certificate_asn1_name_with_x520_o)
5016 unsigned char buf[2000];
5017 unsigned char output[2000];
5021 memset( buf, 0, 2000 );
5022 memset( output, 0, 2000 );
5024 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b060355040a130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
5031 fct_chk( res != -1 );
5032 fct_chk( res != -2 );
5034 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : O=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
5042 FCT_TEST_BGN(x509_certificate_asn1_name_with_x520_ou)
5045 unsigned char buf[2000];
5046 unsigned char output[2000];
5050 memset( buf, 0, 2000 );
5051 memset( output, 0, 2000 );
5053 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b060355040b130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
5060 fct_chk( res != -1 );
5061 fct_chk( res != -2 );
5063 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : OU=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
5071 FCT_TEST_BGN(x509_certificate_asn1_name_with_unknown_x520_part)
5074 unsigned char buf[2000];
5075 unsigned char output[2000];
5079 memset( buf, 0, 2000 );
5080 memset( output, 0, 2000 );
5082 data_len =
unhexify( buf,
"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b06035504de130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
5089 fct_chk( res != -1 );
5090 fct_chk( res != -2 );
5092 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : 0xDE=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
5100 FCT_TEST_BGN(x509_certificate_asn1_name_with_pkcs9_email)
5103 unsigned char buf[2000];
5104 unsigned char output[2000];
5108 memset( buf, 0, 2000 );
5109 memset( output, 0, 2000 );
5111 data_len =
unhexify( buf,
"30819f308189a0030201008204deadbeef300d06092a864886f70d010102050030153113301106092a864886f70d010901130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
5118 fct_chk( res != -1 );
5119 fct_chk( res != -2 );
5121 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : emailAddress=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
5129 FCT_TEST_BGN(x509_certificate_asn1_name_with_unknown_pkcs9_part)
5132 unsigned char buf[2000];
5133 unsigned char output[2000];
5137 memset( buf, 0, 2000 );
5138 memset( output, 0, 2000 );
5140 data_len =
unhexify( buf,
"30819f308189a0030201008204deadbeef300d06092a864886f70d010102050030153113301106092a864886f70d0109ab130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff" );
5147 fct_chk( res != -1 );
5148 fct_chk( res != -2 );
5150 fct_chk( strcmp( (
char *) output,
"cert. version : 1\nserial number : DE:AD:BE:EF\nissuer name : 0xAB=Test\nsubject name : ?\?=Test\nissued on : 2009-01-01 00:00:00\nexpires on : 2009-12-31 23:59:59\nsigned using : RSA+MD2\nRSA key size : 128 bits\n" ) == 0 );
5158 FCT_TEST_BGN(x509_crl_asn1_incorrect_first_tag)
5161 unsigned char buf[2000];
5162 unsigned char output[2000];
5165 memset( &crl, 0,
sizeof(
x509_crl ) );
5166 memset( buf, 0, 2000 );
5167 memset( output, 0, 2000 );
5176 fct_chk( res != -1 );
5177 fct_chk( res != -2 );
5179 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5187 FCT_TEST_BGN(x509_crl_asn1_correct_first_tag_data_length_does_not_match)
5190 unsigned char buf[2000];
5191 unsigned char output[2000];
5194 memset( &crl, 0,
sizeof(
x509_crl ) );
5195 memset( buf, 0, 2000 );
5196 memset( output, 0, 2000 );
5198 data_len =
unhexify( buf,
"300000" );
5205 fct_chk( res != -1 );
5206 fct_chk( res != -2 );
5208 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5216 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_tag_missing)
5219 unsigned char buf[2000];
5220 unsigned char output[2000];
5223 memset( &crl, 0,
sizeof(
x509_crl ) );
5224 memset( buf, 0, 2000 );
5225 memset( output, 0, 2000 );
5227 data_len =
unhexify( buf,
"3000" );
5234 fct_chk( res != -1 );
5235 fct_chk( res != -2 );
5237 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5245 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_version_tag_len_missing)
5248 unsigned char buf[2000];
5249 unsigned char output[2000];
5252 memset( &crl, 0,
sizeof(
x509_crl ) );
5253 memset( buf, 0, 2000 );
5254 memset( output, 0, 2000 );
5256 data_len =
unhexify( buf,
"3003300102" );
5263 fct_chk( res != -1 );
5264 fct_chk( res != -2 );
5266 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5274 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_version_correct_alg_missing)
5277 unsigned char buf[2000];
5278 unsigned char output[2000];
5281 memset( &crl, 0,
sizeof(
x509_crl ) );
5282 memset( buf, 0, 2000 );
5283 memset( output, 0, 2000 );
5285 data_len =
unhexify( buf,
"30053003020100" );
5292 fct_chk( res != -1 );
5293 fct_chk( res != -2 );
5295 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5303 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_alg_correct_incorrect_version)
5306 unsigned char buf[2000];
5307 unsigned char output[2000];
5310 memset( &crl, 0,
sizeof(
x509_crl ) );
5311 memset( buf, 0, 2000 );
5312 memset( output, 0, 2000 );
5314 data_len =
unhexify( buf,
"300b3009020102300406000500" );
5321 fct_chk( res != -1 );
5322 fct_chk( res != -2 );
5324 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5332 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_correct_version_sig_oid1_unknown)
5335 unsigned char buf[2000];
5336 unsigned char output[2000];
5339 memset( &crl, 0,
sizeof(
x509_crl ) );
5340 memset( buf, 0, 2000 );
5341 memset( output, 0, 2000 );
5343 data_len =
unhexify( buf,
"300b3009020100300406000500" );
5350 fct_chk( res != -1 );
5351 fct_chk( res != -2 );
5353 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5361 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_sig_oid1_id_unknown)
5364 unsigned char buf[2000];
5365 unsigned char output[2000];
5368 memset( &crl, 0,
sizeof(
x509_crl ) );
5369 memset( buf, 0, 2000 );
5370 memset( output, 0, 2000 );
5372 data_len =
unhexify( buf,
"30143012020100300d06092a864886f70d01010f0500" );
5379 fct_chk( res != -1 );
5380 fct_chk( res != -2 );
5382 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5390 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_sig_oid1_correct_issuer_missing)
5393 unsigned char buf[2000];
5394 unsigned char output[2000];
5397 memset( &crl, 0,
sizeof(
x509_crl ) );
5398 memset( buf, 0, 2000 );
5399 memset( output, 0, 2000 );
5401 data_len =
unhexify( buf,
"30143012020100300d06092a864886f70d01010e0500" );
5408 fct_chk( res != -1 );
5409 fct_chk( res != -2 );
5411 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5419 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_issuer_set_missing)
5422 unsigned char buf[2000];
5423 unsigned char output[2000];
5426 memset( &crl, 0,
sizeof(
x509_crl ) );
5427 memset( buf, 0, 2000 );
5428 memset( output, 0, 2000 );
5430 data_len =
unhexify( buf,
"30163014020100300d06092a864886f70d01010e05003000" );
5437 fct_chk( res != -1 );
5438 fct_chk( res != -2 );
5440 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5448 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_correct_issuer_thisupdate_missing)
5451 unsigned char buf[2000];
5452 unsigned char output[2000];
5455 memset( &crl, 0,
sizeof(
x509_crl ) );
5456 memset( buf, 0, 2000 );
5457 memset( output, 0, 2000 );
5459 data_len =
unhexify( buf,
"30253023020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344" );
5466 fct_chk( res != -1 );
5467 fct_chk( res != -2 );
5469 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5477 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_correct_thisupdate_nextupdate_missing_entries_length_missing)
5480 unsigned char buf[2000];
5481 unsigned char output[2000];
5484 memset( &crl, 0,
sizeof(
x509_crl ) );
5485 memset( buf, 0, 2000 );
5486 memset( output, 0, 2000 );
5488 data_len =
unhexify( buf,
"30343032020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c30393031303130303030303030" );
5495 fct_chk( res != -1 );
5496 fct_chk( res != -2 );
5498 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5506 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_entries_present_invalid_sig_alg)
5509 unsigned char buf[2000];
5510 unsigned char output[2000];
5513 memset( &crl, 0,
sizeof(
x509_crl ) );
5514 memset( buf, 0, 2000 );
5515 memset( output, 0, 2000 );
5517 data_len =
unhexify( buf,
"304a3047020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030301430128202abcd170c30383132333132333539353900" );
5524 fct_chk( res != -1 );
5525 fct_chk( res != -2 );
5527 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5535 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_entries_present_date_in_entry_invalid)
5538 unsigned char buf[2000];
5539 unsigned char output[2000];
5542 memset( &crl, 0,
sizeof(
x509_crl ) );
5543 memset( buf, 0, 2000 );
5544 memset( output, 0, 2000 );
5546 data_len =
unhexify( buf,
"304a3047020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030301430128202abcd190c30383132333132333539353900" );
5553 fct_chk( res != -1 );
5554 fct_chk( res != -2 );
5556 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5564 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_sig_alg_present_sig_alg_does_not_match)
5567 unsigned char buf[2000];
5568 unsigned char output[2000];
5571 memset( &crl, 0,
sizeof(
x509_crl ) );
5572 memset( buf, 0, 2000 );
5573 memset( output, 0, 2000 );
5575 data_len =
unhexify( buf,
"30583047020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030301430128202abcd170c303831323331323335393539300d06092a864886f70d01010d0500" );
5582 fct_chk( res != -1 );
5583 fct_chk( res != -2 );
5585 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5593 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_sig_present_len_mismatch)
5596 unsigned char buf[2000];
5597 unsigned char output[2000];
5600 memset( &crl, 0,
sizeof(
x509_crl ) );
5601 memset( buf, 0, 2000 );
5602 memset( output, 0, 2000 );
5604 data_len =
unhexify( buf,
"305d3047020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030301430128202abcd170c303831323331323335393539300d06092a864886f70d01010e05000302000100" );
5611 fct_chk( res != -1 );
5612 fct_chk( res != -2 );
5614 fct_chk( strcmp( (
char *) output,
"" ) == 0 );
5622 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_sig_present)
5625 unsigned char buf[2000];
5626 unsigned char output[2000];
5629 memset( &crl, 0,
sizeof(
x509_crl ) );
5630 memset( buf, 0, 2000 );
5631 memset( output, 0, 2000 );
5633 data_len =
unhexify( buf,
"305c3047020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030301430128202abcd170c303831323331323335393539300d06092a864886f70d01010e050003020001" );
5640 fct_chk( res != -1 );
5641 fct_chk( res != -2 );
5643 fct_chk( strcmp( (
char *) output,
"CRL version : 1\nissuer name : CN=ABCD\nthis update : 2009-01-01 00:00:00\nnext update : 0000-00-00 00:00:00\nRevoked certificates:\nserial number: AB:CD revocation date: 2008-12-31 23:59:59\nsigned using : RSA+SHA224\n" ) == 0 );
5651 FCT_TEST_BGN(x509_crl_asn1_tbscertlist_no_entries)
5654 unsigned char buf[2000];
5655 unsigned char output[2000];
5658 memset( &crl, 0,
sizeof(
x509_crl ) );
5659 memset( buf, 0, 2000 );
5660 memset( output, 0, 2000 );
5662 data_len =
unhexify( buf,
"30463031020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001" );
5669 fct_chk( res != -1 );
5670 fct_chk( res != -2 );
5672 fct_chk( strcmp( (
char *) output,
"CRL version : 1\nissuer name : CN=ABCD\nthis update : 2009-01-01 00:00:00\nnext update : 0000-00-00 00:00:00\nRevoked certificates:\nsigned using : RSA+SHA224\n" ) == 0 );
5680 FCT_TEST_BGN(x509_key_asn1_incorrect_first_tag)
5683 unsigned char buf[2000];
5684 unsigned char output[2000];
5688 memset( buf, 0, 2000 );
5689 memset( output, 0, 2000 );
5704 FCT_TEST_BGN(x509_key_asn1_rsaprivatekey_incorrect_version_tag)
5707 unsigned char buf[2000];
5708 unsigned char output[2000];
5712 memset( buf, 0, 2000 );
5713 memset( output, 0, 2000 );
5715 data_len =
unhexify( buf,
"300100" );
5728 FCT_TEST_BGN(x509_key_asn1_rsaprivatekey_version_tag_missing)
5731 unsigned char buf[2000];
5732 unsigned char output[2000];
5736 memset( buf, 0, 2000 );
5737 memset( output, 0, 2000 );
5739 data_len =
unhexify( buf,
"3000" );
5752 FCT_TEST_BGN(x509_key_asn1_rsaprivatekey_invalid_version)
5755 unsigned char buf[2000];
5756 unsigned char output[2000];
5760 memset( buf, 0, 2000 );
5761 memset( output, 0, 2000 );
5763 data_len =
unhexify( buf,
"3003020101" );
5776 FCT_TEST_BGN(x509_key_asn1_rsaprivatekey_correct_version_incorrect_tag)
5779 unsigned char buf[2000];
5780 unsigned char output[2000];
5784 memset( buf, 0, 2000 );
5785 memset( output, 0, 2000 );
5787 data_len =
unhexify( buf,
"300402010000" );
5800 FCT_TEST_BGN(x509_key_asn1_rsaprivatekey_values_present_length_mismatch)
5803 unsigned char buf[2000];
5804 unsigned char output[2000];
5808 memset( buf, 0, 2000 );
5809 memset( output, 0, 2000 );
5811 data_len =
unhexify( buf,
"301c02010002010102010102010102010102010102010102010102010100" );
5824 FCT_TEST_BGN(x509_key_asn1_rsaprivatekey_values_present_check_privkey_fails)
5827 unsigned char buf[2000];
5828 unsigned char output[2000];
5832 memset( buf, 0, 2000 );
5833 memset( output, 0, 2000 );
5835 data_len =
unhexify( buf,
"301b020100020101020101020101020101020101020101020101020101" );