diff options
Diffstat (limited to 'tests/Test_indefinite.c')
-rw-r--r-- | tests/Test_indefinite.c | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/tests/Test_indefinite.c b/tests/Test_indefinite.c index c1613ef..9f08793 100644 --- a/tests/Test_indefinite.c +++ b/tests/Test_indefinite.c @@ -48,6 +48,8 @@ main (int argc, char *argv[]) ssize_t size; const char *treefile = getenv ("ASN1PKIX"); const char *indeffile = getenv ("ASN1INDEF"); + const char *indeffile2 = getenv ("ASN1INDEF2"); + const char *indeffile3 = getenv ("ASN1INDEF3"); int verbose = 0; if (argc > 1) @@ -59,6 +61,12 @@ main (int argc, char *argv[]) if (!indeffile) indeffile = "TestIndef.p12"; + if (!indeffile2) + indeffile2 = "TestIndef2.p12"; + + if (!indeffile3) + indeffile3 = "TestIndef3.der"; + if (verbose) { printf ("\n\n/****************************************/\n"); @@ -110,13 +118,84 @@ main (int argc, char *argv[]) if (result != ASN1_SUCCESS) { asn1_perror (result); - printf ("Cannot decode BER data (size %ld)\n", (long) size); + printf ("Cannot decode BER data (size %ld) in %s: %s\n", (long) size, indeffile, errorDescription); + exit (1); + } + + asn1_delete_structure (&asn1_element); + + /* second test */ + fd = fopen (indeffile2, "rb"); + if (fd == NULL) + { + printf ("Cannot read file %s\n", indeffile2); + exit (1); + } + size = fread (buffer, 1, sizeof (buffer), fd); + if (size <= 0) + { + printf ("Cannot read from file %s\n", indeffile2); + exit (1); + } + + fclose (fd); + + result = + asn1_create_element (definitions, "PKIX1.pkcs-12-PFX", &asn1_element); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot create PKCS12 element\n"); + exit (1); + } + + result = asn1_der_decoding (&asn1_element, buffer, size, errorDescription); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot decode BER data (size %ld) in %s: %s\n", (long) size, indeffile2, errorDescription); exit (1); } + asn1_delete_structure (&asn1_element); + + /* third test */ + fd = fopen (indeffile3, "rb"); + if (fd == NULL) + { + printf ("Cannot read file %s\n", indeffile3); + exit (1); + } + size = fread (buffer, 1, sizeof (buffer), fd); + if (size <= 0) + { + printf ("Cannot read from file %s\n", indeffile3); + exit (1); + } + + fclose (fd); + + result = + asn1_create_element (definitions, "PKIX1.pkcs-12-CertBag", &asn1_element); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot create CertBag element\n"); + exit (1); + } + + result = asn1_der_decoding (&asn1_element, buffer, size, errorDescription); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot decode DER data (size %ld) in %s: %s\n", (long) size, indeffile3, errorDescription); + exit (1); + } + + asn1_delete_structure (&asn1_element); + /* Clear the definition structures */ asn1_delete_structure (&definitions); - asn1_delete_structure (&asn1_element); if (out != stdout) fclose (out); |