|
@@ -11,6 +11,8 @@ int der_test(void)
|
|
|
|
|
|
#else
|
|
|
|
|
|
+#include <wchar.h>
|
|
|
+
|
|
|
#if defined(LTC_TEST_DBG) && LTC_TEST_DBG > 2
|
|
|
#define LTC_DER_TESTS_PRINT_FLEXI
|
|
|
#endif
|
|
@@ -252,7 +254,7 @@ static void s_free(void *p)
|
|
|
XFREE(p);
|
|
|
}
|
|
|
|
|
|
-static void s_der_tests_print_flexi(ltc_asn1_list* l, unsigned int level)
|
|
|
+static void s_der_tests_print_flexi_i(ltc_asn1_list* l, unsigned int level)
|
|
|
{
|
|
|
char *buf = NULL;
|
|
|
const char* name = NULL;
|
|
@@ -435,15 +437,28 @@ static void s_der_tests_print_flexi(ltc_asn1_list* l, unsigned int level)
|
|
|
}
|
|
|
|
|
|
if (ostring) {
|
|
|
- s_der_tests_print_flexi(ostring, level + 1);
|
|
|
+ s_der_tests_print_flexi_i(ostring, level + 1);
|
|
|
der_free_sequence_flexi(ostring);
|
|
|
}
|
|
|
|
|
|
if (l->child)
|
|
|
- s_der_tests_print_flexi(l->child, level + 1);
|
|
|
+ s_der_tests_print_flexi_i(l->child, level + 1);
|
|
|
|
|
|
if (l->next)
|
|
|
- s_der_tests_print_flexi(l->next, level);
|
|
|
+ s_der_tests_print_flexi_i(l->next, level);
|
|
|
+}
|
|
|
+
|
|
|
+static void s_der_tests_print_flexi(ltc_asn1_list* l)
|
|
|
+{
|
|
|
+ fprintf(stderr, "\n\n");
|
|
|
+ s_der_tests_print_flexi_i(l, 0);
|
|
|
+ fprintf(stderr, "\n\n");
|
|
|
+}
|
|
|
+
|
|
|
+#else
|
|
|
+static void s_der_tests_print_flexi(ltc_asn1_list* l)
|
|
|
+{
|
|
|
+ LTC_UNUSED_PARAM(l);
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -471,11 +486,7 @@ static void der_cacert_test(void)
|
|
|
CHECK_ASN1_TYPE(decoded_list, LTC_ASN1_SEQUENCE);
|
|
|
CHECK_ASN1_HAS_NO_DATA(decoded_list);
|
|
|
|
|
|
-#ifdef LTC_DER_TESTS_PRINT_FLEXI
|
|
|
- printf("\n\n--- test print start ---\n\n");
|
|
|
- s_der_tests_print_flexi(decoded_list, 0);
|
|
|
- printf("\n\n--- test print end ---\n\n");
|
|
|
-#endif
|
|
|
+ s_der_tests_print_flexi(decoded_list);
|
|
|
|
|
|
l = decoded_list;
|
|
|
|
|
@@ -1086,7 +1097,7 @@ static int der_choice_n_custom_test(void)
|
|
|
for (x = 0; x < sizeof(ia5buf); x++) { ia5buf[x] = 'a'; }
|
|
|
for (x = 0; x < sizeof(printbuf); x++) { printbuf[x] = 'a'; }
|
|
|
for (x = 0; x < sizeof(utf8buf)/sizeof(utf8buf[0]); x++) { utf8buf[x] = L'a'; }
|
|
|
- integer = 1;
|
|
|
+ integer = 10000;
|
|
|
boolean[0] = 1;
|
|
|
for (x = 0; x < sizeof(oidbuf)/sizeof(oidbuf[0]); x++) { oidbuf[x] = x + 1; }
|
|
|
DO(mp_init(&mpinteger));
|
|
@@ -1169,11 +1180,7 @@ static void s_der_decode_print(const void* p, unsigned long* plen)
|
|
|
{
|
|
|
ltc_asn1_list *list;
|
|
|
DO(der_decode_sequence_flexi(p, plen, &list));
|
|
|
-#ifdef LTC_DER_TESTS_PRINT_FLEXI
|
|
|
- fprintf(stderr, "\n\n");
|
|
|
- s_der_tests_print_flexi(list, 0);
|
|
|
- fprintf(stderr, "\n\n");
|
|
|
-#endif
|
|
|
+ s_der_tests_print_flexi(list);
|
|
|
der_sequence_free(list);
|
|
|
}
|
|
|
|
|
@@ -1342,11 +1349,7 @@ static void der_Xcode_test(void)
|
|
|
|
|
|
i = sizeof(teletex_neg_int);
|
|
|
DO(der_decode_sequence_flexi(teletex_neg_int, &i, &list));
|
|
|
-#ifdef LTC_DER_TESTS_PRINT_FLEXI
|
|
|
- fprintf(stderr, "\n\n");
|
|
|
- s_der_tests_print_flexi(list, 0);
|
|
|
- fprintf(stderr, "\n\n");
|
|
|
-#endif
|
|
|
+ s_der_tests_print_flexi(list);
|
|
|
if (list->child == NULL || list->child->next == NULL)
|
|
|
exit(EXIT_FAILURE);
|
|
|
ttex_neg_int[0] = *list->child->next;
|
|
@@ -1368,11 +1371,7 @@ static int s_der_decode_sequence_flexi(const void *in, unsigned long inlen, void
|
|
|
{
|
|
|
ltc_asn1_list** list = ctx;
|
|
|
if (der_decode_sequence_flexi(in, &inlen, list) == CRYPT_OK) {
|
|
|
-#ifdef LTC_DER_TESTS_PRINT_FLEXI
|
|
|
- fprintf(stderr, "\n\n");
|
|
|
- s_der_tests_print_flexi(*list, 0);
|
|
|
- fprintf(stderr, "\n\n");
|
|
|
-#endif
|
|
|
+ s_der_tests_print_flexi(*list);
|
|
|
der_sequence_free(*list);
|
|
|
}
|
|
|
return CRYPT_OK;
|
|
@@ -1400,7 +1399,9 @@ static void s_der_regression_test(void)
|
|
|
"\xaa" /* One byte padding */
|
|
|
"\x04\x82\xff\xff"; /* Start OCTET sequence of length 0xffff */
|
|
|
/* (this will include the adjacent data into the decoded certificate) */
|
|
|
- unsigned long len;
|
|
|
+ static const unsigned char utf8_length[] = "\x0c\x02\x61\x61\x61";
|
|
|
+ wchar_t wtmp[4];
|
|
|
+ unsigned long len, outlen;
|
|
|
void *x, *y;
|
|
|
ltc_asn1_list seq[2];
|
|
|
ltc_asn1_list *l;
|
|
@@ -1421,6 +1422,11 @@ static void s_der_regression_test(void)
|
|
|
|
|
|
len = sizeof(issue_507);
|
|
|
SHOULD_FAIL(der_decode_sequence_flexi(issue_507, &len, &l));
|
|
|
+
|
|
|
+ len = sizeof(utf8_length);
|
|
|
+ outlen = sizeof(wtmp)/sizeof(wtmp[0]);
|
|
|
+ DO(der_decode_utf8_string(utf8_length, len, wtmp, &outlen));
|
|
|
+ ENSURE(outlen == 2);
|
|
|
}
|
|
|
|
|
|
static void der_toolong_test(void)
|