summaryrefslogtreecommitdiff
path: root/lib/decoding.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-06-04 17:21:15 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-06-04 17:21:15 +0200
commitcf99716e175b6380bde113f415477948d70bdbda (patch)
tree94448037c0c3a16f77cffc4c5564dc3938be6e5b /lib/decoding.c
parente7272b364e63548be8b92a6ae6236393a77d3cba (diff)
downloadlibtasn1-cf99716e175b6380bde113f415477948d70bdbda.tar.gz
libtasn1-cf99716e175b6380bde113f415477948d70bdbda.tar.bz2
libtasn1-cf99716e175b6380bde113f415477948d70bdbda.zip
Optimized _asn1_append_sequence_set() by caching the tail of the element to append on.
Diffstat (limited to 'lib/decoding.c')
-rw-r--r--lib/decoding.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/decoding.c b/lib/decoding.c
index c79a5c4..199580c 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -899,6 +899,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
asn1_node node, p, p2, p3;
char temp[128];
int counter, len2, len3, len4, move, ris, tlen;
+ asn1_node ptail = NULL;
unsigned char class;
unsigned long tag;
int indefinite, result, total_len = ider_len;
@@ -1290,7 +1291,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
{ /* indefinite length method */
if (!HAVE_TWO(ider_len) || ((der[counter]) || der[counter + 1]))
{
- _asn1_append_sequence_set (p);
+ _asn1_append_sequence_set (p, &ptail);
p = p->down;
while (p->right)
p = p->right;
@@ -1299,6 +1300,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
}
p->tmp_ival = 0;
+ ptail = NULL; /* finished decoding this structure */
DECR_LEN(ider_len, 2);
counter += 2;
}
@@ -1306,7 +1308,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
{ /* definite length method */
if (len2 > counter)
{
- _asn1_append_sequence_set (p);
+ _asn1_append_sequence_set (p, &ptail);
p = p->down;
while (p->right)
p = p->right;
@@ -1315,6 +1317,8 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
}
p->tmp_ival = 0;
+ ptail = NULL; /* finished decoding this structure */
+
if (len2 != counter)
{
result = ASN1_DER_ERROR;
@@ -1351,7 +1355,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len,
|| (type_field (p2->type) == ASN1_ETYPE_SIZE))
p2 = p2->right;
if (p2->right == NULL)
- _asn1_append_sequence_set (p);
+ _asn1_append_sequence_set (p, &ptail);
p = p2;
}
}