aboutsummaryrefslogtreecommitdiffstats
path: root/asn1.c
diff options
context:
space:
mode:
Diffstat (limited to 'asn1.c')
-rw-r--r--asn1.c64
1 files changed, 57 insertions, 7 deletions
diff --git a/asn1.c b/asn1.c
index 0d2c36e6aa..0b86c9ea30 100644
--- a/asn1.c
+++ b/asn1.c
@@ -1,7 +1,7 @@
/* asn1.c
* Routines for ASN.1 BER dissection
*
- * $Id: asn1.c,v 1.21 2003/08/29 19:13:28 guy Exp $
+ * $Id: asn1.c,v 1.22 2003/10/02 06:13:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -138,22 +138,21 @@ asn1_octet_decode(ASN1_SCK *asn1, guchar *ch)
}
/*
- * NAME: asn1_tag_decode
- * SYNOPSIS: int asn1_tag_decode
+ * NAME: asn1_tag_get
+ * SYNOPSIS: int asn1_tag_get
* (
* ASN1_SCK *asn1,
* guint *tag
* )
- * DESCRIPTION: Decodes a tag.
+ * DESCRIPTION: Decodes a tag number, combining it with existing tag bits.
* RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success)
*/
-int
-asn1_tag_decode(ASN1_SCK *asn1, guint *tag)
+static int
+asn1_tag_get(ASN1_SCK *asn1, guint *tag)
{
int ret;
guchar ch;
- *tag = 0;
do {
ret = asn1_octet_decode (asn1, &ch);
if (ret != ASN1_ERR_NOERROR)
@@ -165,6 +164,23 @@ asn1_tag_decode(ASN1_SCK *asn1, guint *tag)
}
/*
+ * NAME: asn1_tag_decode
+ * SYNOPSIS: int asn1_tag_decode
+ * (
+ * ASN1_SCK *asn1,
+ * guint *tag
+ * )
+ * DESCRIPTION: Decodes a tag number.
+ * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success)
+ */
+int
+asn1_tag_decode(ASN1_SCK *asn1, guint *tag)
+{
+ *tag = 0;
+ return asn1_tag_get(asn1, tag);
+}
+
+/*
* NAME: asn1_id_decode
* SYNOPSIS: int asn1_id_decode
* (
@@ -182,6 +198,7 @@ asn1_id_decode(ASN1_SCK *asn1, guint *cls, guint *con, guint *tag)
int ret;
guchar ch;
+ *tag = 0;
ret = asn1_octet_decode (asn1, &ch);
if (ret != ASN1_ERR_NOERROR)
return ret;
@@ -197,6 +214,39 @@ asn1_id_decode(ASN1_SCK *asn1, guint *cls, guint *con, guint *tag)
}
/*
+ * NAME: asn1_id_decode1
+ * SYNOPSIS: int asn1_id_decode1
+ * (
+ * ASN1_SCK *asn1,
+ * guint *tag
+ * )
+ * DESCRIPTION: Decodes an identifier.
+ * Like asn1_id_decode() except that the Class and Constructor
+ * bits are returned in the tag.
+ * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success)
+ */
+int
+asn1_id_decode1(ASN1_SCK *asn1, guint *tag)
+{
+ int ret;
+ guchar ch;
+
+ *tag = 0;
+ ret = asn1_octet_decode (asn1, &ch);
+ if (ret != ASN1_ERR_NOERROR)
+ return ret;
+
+ *tag = ch;
+ if ((*tag & 0x1F) == 0x1F) { /* high-tag-number format */
+ *tag = ch >> 5; /* leave just the Class and Constructor bits */
+ ret = asn1_tag_get (asn1, tag);
+ if (ret != ASN1_ERR_NOERROR)
+ return ret;
+ }
+ return ASN1_ERR_NOERROR;
+}
+
+/*
* NAME: asn1_length_decode
* SYNOPSIS: int asn1_length_decode
* (