From d14caccbe1f54c42437b41e5a1863339f5987fc6 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 30 May 2014 14:07:02 +0200 Subject: Added check for decoding_startEnd(). --- tests/Test_encdec.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/Test_encdec.c b/tests/Test_encdec.c index 363f2ff..9b49e72 100644 --- a/tests/Test_encdec.c +++ b/tests/Test_encdec.c @@ -47,6 +47,7 @@ main (int argc, char *argv[]) char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; FILE *out, *fd; ssize_t size; + int start, end; int size2; const char *treefile = getenv ("ASN1PKIX"); const char *derfile = getenv ("ASN1CRLDER"); @@ -116,6 +117,45 @@ main (int argc, char *argv[]) exit (1); } + result = asn1_der_decoding_startEnd (asn1_element, buffer, size, "tbsCertList", &start, &end); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot find start End\n"); + exit (1); + } + if (start != 4 && end != 358) + { + printf("Error in start and end values. Have: %d..%d\n", start, end); + exit(1); + } + + result = asn1_der_decoding_startEnd (asn1_element, buffer, size, "signature", &start, &end); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot find start End\n"); + exit (1); + } + if (start != 372 && end != 503) + { + printf("Error in start and end values for signature. Have: %d..%d\n", start, end); + exit(1); + } + + result = asn1_der_decoding_startEnd (asn1_element, buffer, size, "tbsCertList.revokedCertificates.?1.userCertificate", &start, &end); + if (result != ASN1_SUCCESS) + { + asn1_perror (result); + printf ("Cannot find start End\n"); + exit (1); + } + if (start != 326 && end != 343) + { + printf("Error in start and end values for userCertificate. Have: %d..%d\n", start, end); + exit(1); + } + size2 = sizeof(buffer2); result = asn1_der_coding (asn1_element, "", buffer2, &size2, NULL); if (result != ASN1_SUCCESS) -- cgit v1.2.1