summaryrefslogtreecommitdiff
path: root/lib/decoding.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2009-03-04 17:17:46 +0100
committerSimon Josefsson <simon@josefsson.org>2009-03-04 17:17:46 +0100
commit45e34b66d1c30727816cca7594b44ea212e47ad4 (patch)
treec954d417f3b8face79292904dddfe4e08876d93a /lib/decoding.c
parent7610ca58af3ccc0431e89d6ffd6279f6b10f283b (diff)
downloadlibtasn1-45e34b66d1c30727816cca7594b44ea212e47ad4.tar.gz
libtasn1-45e34b66d1c30727816cca7594b44ea212e47ad4.tar.bz2
libtasn1-45e34b66d1c30727816cca7594b44ea212e47ad4.zip
Indent code. Reproduce using 'make indent' with GNU indent 2.2.10.
Diffstat (limited to 'lib/decoding.c')
-rw-r--r--lib/decoding.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/lib/decoding.c b/lib/decoding.c
index 532b2ed..d72a4c0 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -180,11 +180,11 @@ asn1_get_length_ber (const unsigned char *ber, int ber_len, int *len)
int ret;
long err;
- ret = asn1_get_length_der( ber, ber_len, len);
+ ret = asn1_get_length_der (ber, ber_len, len);
if (ret == -1)
- { /* indefinite length method */
+ { /* indefinite length method */
ret = ber_len;
- err = _asn1_get_indefinite_length_string (ber+1, &ret);
+ err = _asn1_get_indefinite_length_string (ber + 1, &ret);
if (err != ASN1_SUCCESS)
return -3;
}
@@ -385,7 +385,7 @@ _asn1_extract_tag_der (ASN1_TYPE node, const unsigned char *der, int der_len,
&len2);
if (len3 < 0)
return ASN1_DER_ERROR;
-
+
counter += len2;
if (counter > der_len)
return ASN1_DER_ERROR;
@@ -598,45 +598,48 @@ _asn1_delete_not_used (ASN1_TYPE node)
}
static asn1_retCode
-_asn1_extract_der_octet(ASN1_TYPE node, const unsigned char *der, int der_len)
+_asn1_extract_der_octet (ASN1_TYPE node, const unsigned char *der,
+ int der_len)
{
-int len2, len3;
-int counter2, counter_end;
+ int len2, len3;
+ int counter2, counter_end;
- len2 = asn1_get_length_der (der, der_len, &len3);
- if (len2 < -1)
- return ASN1_DER_ERROR;
+ len2 = asn1_get_length_der (der, der_len, &len3);
+ if (len2 < -1)
+ return ASN1_DER_ERROR;
- counter2 = len3 + 1;
+ counter2 = len3 + 1;
- if (len2 == -1)
- counter_end = der_len - 2;
- else
- counter_end = der_len;
+ if (len2 == -1)
+ counter_end = der_len - 2;
+ else
+ counter_end = der_len;
- while (counter2 < counter_end)
- {
- len2 = asn1_get_length_der (der + counter2, der_len - counter2, &len3);
+ while (counter2 < counter_end)
+ {
+ len2 = asn1_get_length_der (der + counter2, der_len - counter2, &len3);
- if (len2 < -1)
- return ASN1_DER_ERROR;
+ if (len2 < -1)
+ return ASN1_DER_ERROR;
- if (len2 > 0)
- {
- _asn1_append_value( node, der + counter2 + len3, len2);
- }
- else
- { /* indefinite */
-
- len2 = _asn1_extract_der_octet( node, der+counter2+len3, der_len-counter2-len3);
- if (len2 < 0)
- return len2;
- }
-
- counter2 += len2 + len3 + 1;
- }
-
- return ASN1_SUCCESS;
+ if (len2 > 0)
+ {
+ _asn1_append_value (node, der + counter2 + len3, len2);
+ }
+ else
+ { /* indefinite */
+
+ len2 =
+ _asn1_extract_der_octet (node, der + counter2 + len3,
+ der_len - counter2 - len3);
+ if (len2 < 0)
+ return len2;
+ }
+
+ counter2 += len2 + len3 + 1;
+ }
+
+ return ASN1_SUCCESS;
}
@@ -692,17 +695,17 @@ _asn1_get_octet_string (const unsigned char *der, ASN1_TYPE node, int *len)
{
unsigned char temp[DER_LEN];
int ret;
-
- len2 = sizeof(temp);
+
+ len2 = sizeof (temp);
asn1_length_der (tot_len, temp, &len2);
_asn1_set_value (node, temp, len2);
tot_len += len2;
- ret = _asn1_extract_der_octet(node, der, *len);
- if (ret!=ASN1_SUCCESS)
- return ret;
+ ret = _asn1_extract_der_octet (node, der, *len);
+ if (ret != ASN1_SUCCESS)
+ return ret;
}
}
@@ -1241,7 +1244,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
if (len4 != -1)
{
len2 += len4;
- _asn1_set_value_octet (p, der+counter, len2+len3);
+ _asn1_set_value_octet (p, der + counter, len2 + len3);
counter += len2 + len3;
}
else
@@ -1261,7 +1264,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len,
return ris;
}
- _asn1_set_value_octet (p, der+counter, len2);
+ _asn1_set_value_octet (p, der + counter, len2);
counter += len2;
/* Check if a couple of 0x00 are present due to an EXPLICIT TAG with
@@ -1907,7 +1910,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
len2 += len4;
if (state == FOUND)
{
- _asn1_set_value_octet (p, der+counter, len2+len3);
+ _asn1_set_value_octet (p, der + counter, len2 + len3);
temp2 = NULL;
if (p == nodeFound)
@@ -1934,7 +1937,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName,
if (state == FOUND)
{
- _asn1_set_value_octet (p, der+counter, len2);
+ _asn1_set_value_octet (p, der + counter, len2);
if (p == nodeFound)
state = EXIT;