diff options
Diffstat (limited to 'asn1.c')
-rw-r--r-- | asn1.c | 60 |
1 files changed, 44 insertions, 16 deletions
@@ -1,7 +1,7 @@ /* asn1.c * Routines for ASN.1 BER dissection * - * $Id: asn1.c,v 1.5 2000/06/26 00:08:48 guy Exp $ + * $Id: asn1.c,v 1.6 2000/12/24 09:10:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -631,14 +631,15 @@ asn1_bits_decode ( ASN1_SCK *asn1, const guchar *eoc, guchar **bits, } /* - * NAME: asn1_octet_string_value_decode [API] - * SYNOPSIS: int asn1_octet_string_value_decode + * NAME: asn1_string_value_decode [API] + * SYNOPSIS: int asn1_string_value_decode * ( * ASN1_SCK *asn1, * int enc_len, * guchar **octets * ) - * DESCRIPTION: Decodes value portion of Octet String. + * DESCRIPTION: Decodes value portion of string (Octet String, various + * character string types) * Parameters: * asn1: pointer to ASN1 socket. * enc_len: length of encoding of value. @@ -646,7 +647,7 @@ asn1_bits_decode ( ASN1_SCK *asn1, const guchar *eoc, guchar **bits, * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success) */ int -asn1_octet_string_value_decode ( ASN1_SCK *asn1, int enc_len, guchar **octets) +asn1_string_value_decode ( ASN1_SCK *asn1, int enc_len, guchar **octets) { int ret; const guchar *eoc; @@ -667,25 +668,28 @@ asn1_octet_string_value_decode ( ASN1_SCK *asn1, int enc_len, guchar **octets) } /* - * NAME: asn1_octet_string_decode [API] - * SYNOPSIS: int asn1_octet_string_decode + * NAME: asn1_string_decode [API] + * SYNOPSIS: int asn1_string_decode * ( * ASN1_SCK *asn1, * guchar **octets, * guint *str_len, * guint *nbytes, + * guint expected_tag * ) - * DESCRIPTION: Decodes Octet String. + * DESCRIPTION: Decodes string (Octet String, various character string + * types) * Parameters: - * asn1: pointer to ASN1 socket. - * octets: pointer to variable we set to point to string. - * str_len: length of octet_string. - * nbytes: number of bytes used to encode. + * asn1: pointer to ASN1 socket. + * octets: pointer to variable we set to point to string. + * str_len: length of octet_string. + * nbytes: number of bytes used to encode. + * expected_tag: tag expected for this type of string. * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success) */ int -asn1_octet_string_decode ( ASN1_SCK *asn1, guchar **octets, guint *str_len, - guint *nbytes) +asn1_string_decode ( ASN1_SCK *asn1, guchar **octets, guint *str_len, + guint *nbytes, guint expected_tag) { int ret; const guchar *start; @@ -699,7 +703,7 @@ asn1_octet_string_decode ( ASN1_SCK *asn1, guchar **octets, guint *str_len, ret = asn1_header_decode (asn1, &cls, &con, &tag, &def, &enc_len); if (ret != ASN1_ERR_NOERROR) goto done; - if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OTS) { + if (cls != ASN1_UNI || con != ASN1_PRI || tag != expected_tag) { /* XXX - handle the constructed encoding? */ ret = ASN1_ERR_WRONG_TYPE; goto done; @@ -709,7 +713,7 @@ asn1_octet_string_decode ( ASN1_SCK *asn1, guchar **octets, guint *str_len, goto done; } - ret = asn1_octet_string_value_decode (asn1, enc_len, octets); + ret = asn1_string_value_decode (asn1, enc_len, octets); *str_len = enc_len; done: @@ -718,6 +722,30 @@ done: } /* + * NAME: asn1_octet_string_decode [API] + * SYNOPSIS: int asn1_octet_string_decode + * ( + * ASN1_SCK *asn1, + * guchar **octets, + * guint *str_len, + * guint *nbytes, + * ) + * DESCRIPTION: Decodes Octet String. + * Parameters: + * asn1: pointer to ASN1 socket. + * octets: pointer to variable we set to point to string. + * str_len: length of octet_string. + * nbytes: number of bytes used to encode. + * RETURNS: ASN1_ERR value (ASN1_ERR_NOERROR on success) + */ +int +asn1_octet_string_decode ( ASN1_SCK *asn1, guchar **octets, guint *str_len, + guint *nbytes) +{ + return asn1_string_decode(asn1, octets, str_len, nbytes, ASN1_OTS); +} + +/* * NAME: asn1_subid_decode * SYNOPSIS: int asn1_subid_decode * ( |