add/fix tests

add explicit strict&loose base64-decode tests
This commit is contained in:
Steffen Jaeckel 2016-01-23 13:14:50 +01:00 committed by Karel Miko
parent b10f9502f8
commit 1c0edfdead
2 changed files with 17 additions and 1 deletions

View File

@ -56,6 +56,22 @@ int base64_test(void)
return 1;
}
}
x--;
memmove(&out[11], &out[10], l1 - 10);
out[10] = '\0';
l1++;
l2 = sizeof(tmp);
DO(base64_decode_ex(out, l1, tmp, &l2, 0));
if (l2 != x || memcmp(tmp, in, x)) {
fprintf(stderr, "loose base64 decoding failed %lu %lu %lu", x, l1, l2);
print_hex("is ", tmp, l2);
print_hex("should", in, x);
print_hex("input ", out, l1);
return 1;
}
l2 = sizeof(tmp);
DO(base64_decode_ex(out, l1, tmp, &l2, 1) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_INVALID_PACKET);
return 0;
}
#endif

View File

@ -392,7 +392,7 @@ static void der_cacert_test(void)
ltc_asn1_list *decoded_list, *l, *l1, *l2;
DO(base64_decode(_der_tests_cacert_root_cert, sizeof(_der_tests_cacert_root_cert), buf, &len1));
DO(base64_decode_ex(_der_tests_cacert_root_cert, sizeof(_der_tests_cacert_root_cert), buf, &len1, 0));
len2 = len1;
DO(der_decode_sequence_flexi(buf, &len2, &decoded_list));