[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU libtasn1 branch, libtasn1_3_x, updated. libtasn1_3_7-3-g195781
From: |
Nikos Mavrogiannopoulos |
Subject: |
[SCM] GNU libtasn1 branch, libtasn1_3_x, updated. libtasn1_3_7-3-g195781a |
Date: |
Wed, 20 Aug 2014 07:55:59 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU libtasn1".
http://git.savannah.gnu.org/cgit/libtasn1.git/commit/?id=195781ab04c841a0073dc2344552545075127e8b
The branch, libtasn1_3_x has been updated
via 195781ab04c841a0073dc2344552545075127e8b (commit)
via 1519e2daff51ecb9824adbd815e7e11f7b2988d3 (commit)
via d13728f319fe74101df57dfabe16907c5d517d28 (commit)
from cbe079f1496fef9c311e5d826d4acad8933d4f17 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 195781ab04c841a0073dc2344552545075127e8b
Author: Nikos Mavrogiannopoulos <address@hidden>
Date: Wed Aug 20 09:55:54 2014 +0200
doc update
commit 1519e2daff51ecb9824adbd815e7e11f7b2988d3
Author: Nikos Mavrogiannopoulos <address@hidden>
Date: Wed Aug 20 09:49:22 2014 +0200
BER decoding: corrected indefinite tag check in ANY constructions
commit d13728f319fe74101df57dfabe16907c5d517d28
Author: Nikos Mavrogiannopoulos <address@hidden>
Date: Wed Aug 20 09:53:10 2014 +0200
Added another BER-encoded PKCS #12 file to test indefinite decoding
-----------------------------------------------------------------------
Summary of changes:
NEWS | 5 +++++
lib/decoding.c | 46 ++++++++++++++++++++++++----------------------
tests/Makefile.am | 4 +++-
tests/Test_indefinite.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 74 insertions(+), 25 deletions(-)
diff --git a/NEWS b/NEWS
index 0f8e1a6..3dea1e7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
GNU Libtasn1 NEWS -*- outline -*-
+* Noteworthy changes in release 3.8 (unreleased) [stable]
+- corrected indefinite tag check in ANY constructions. That allows
+ the decoding of BER-encoded structures that contain indefinite
+ encoding within for an ANY element.
+
* Noteworthy changes in release 3.7 (released 2014-06-26) [stable]
- Fixes in length calculation in _asn1_extract_der_octet().
- Fixes in DER decoding.
diff --git a/lib/decoding.c b/lib/decoding.c
index 64cc290..e7bd19f 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -1358,6 +1358,12 @@ asn1_der_decoding (asn1_node * element, const void
*ider, int ider_len,
move = RIGHT;
break;
case ASN1_ETYPE_ANY:
+ /* Check indefinite lenth method in an EXPLICIT TAG */
+ if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
+ indefinite = 1;
+ else
+ indefinite = 0;
+
if (asn1_get_tag_der
(der + counter, ider_len, &class, &len2,
&tag) != ASN1_SUCCESS)
@@ -1397,12 +1403,6 @@ asn1_der_decoding (asn1_node * element, const void
*ider, int ider_len,
goto cleanup;
}
- /* Check indefinite lenth method in an EXPLICIT TAG */
- if ((p->type & CONST_TAG) && (der[counter - 1] == 0x80))
- indefinite = 1;
- else
- indefinite = 0;
-
result =
_asn1_get_indefinite_length_string (der + counter,
ider_len, &len2);
if (result != ASN1_SUCCESS)
@@ -1415,23 +1415,25 @@ asn1_der_decoding (asn1_node * element, const void
*ider, int ider_len,
_asn1_set_value_lv (p, der + counter, len2);
counter += len2;
- /* Check if a couple of 0x00 are present due to an EXPLICIT
TAG with
- an indefinite length method. */
- if (indefinite)
- {
- DECR_LEN(ider_len, 2);
- if (!der[counter] && !der[counter + 1])
- {
- counter += 2;
- }
- else
- {
- result = ASN1_DER_ERROR;
- warn();
- goto cleanup;
- }
- }
}
+
+ /* Check if a couple of 0x00 are present due to an EXPLICIT TAG
with
+ an indefinite length method. */
+ if (indefinite)
+ {
+ DECR_LEN(ider_len, 2);
+ if (!der[counter] && !der[counter + 1])
+ {
+ counter += 2;
+ }
+ else
+ {
+ result = ASN1_DER_ERROR;
+ warn();
+ goto cleanup;
+ }
+ }
+
move = RIGHT;
break;
default:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d28656d..a400af7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,7 +23,8 @@ AM_LDFLAGS = -no-install
LDADD = ../lib/libtasn1.la ../gl/libgnu.la
EXTRA_DIST = Test_parser.asn Test_tree.asn Test_tree_asn1_tab.c \
- Test_encoding.asn pkix.asn TestIndef.p12 choice.asn
+ Test_encoding.asn pkix.asn TestIndef.p12 choice.asn \
+ TestIndef2.p12
# For crlf.
EXTRA_DIST += crlf.cer crl.der
@@ -48,6 +49,7 @@ TESTS_ENVIRONMENT = \
ASN1PKIX=$(srcdir)/pkix.asn \
ASN1CRLDER=$(srcdir)/crl.der \
ASN1INDEF=$(srcdir)/TestIndef.p12 \
+ ASN1INDEF2=$(srcdir)/TestIndef2.p12 \
ASN1ENCODING=$(srcdir)/Test_encoding.asn \
THREADSAFETY_FILES=`find $(top_srcdir)/lib -name \*.c` \
EXEEXT=$(EXEEXT) \
diff --git a/tests/Test_indefinite.c b/tests/Test_indefinite.c
index c1613ef..b1a435a 100644
--- a/tests/Test_indefinite.c
+++ b/tests/Test_indefinite.c
@@ -48,6 +48,7 @@ main (int argc, char *argv[])
ssize_t size;
const char *treefile = getenv ("ASN1PKIX");
const char *indeffile = getenv ("ASN1INDEF");
+ const char *indeffile2 = getenv ("ASN1INDEF2");
int verbose = 0;
if (argc > 1)
@@ -59,6 +60,9 @@ main (int argc, char *argv[])
if (!indeffile)
indeffile = "TestIndef.p12";
+ if (!indeffile2)
+ indeffile = "TestIndef2.p12";
+
if (verbose)
{
printf ("\n\n/****************************************/\n");
@@ -110,13 +114,49 @@ 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\n", (long) size,
indeffile);
+ exit (1);
+ }
+
+ asn1_delete_structure (&asn1_element);
+
+ /* second test */
+ fd = fopen (indeffile2, "rb");
+ if (fd == NULL)
+ {
+ printf ("Cannot read file %s\n", indeffile);
+ exit (1);
+ }
+ size = fread (buffer, 1, sizeof (buffer), fd);
+ if (size <= 0)
+ {
+ printf ("Cannot read from file %s\n", indeffile);
+ 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\n", (long) size,
indeffile2);
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);
hooks/post-receive
--
GNU libtasn1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU libtasn1 branch, libtasn1_3_x, updated. libtasn1_3_7-3-g195781a,
Nikos Mavrogiannopoulos <=