diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-12-24 09:10:12 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-12-24 09:10:12 +0000 |
commit | 60f9476740b196b029d68e2c05f86622610a8334 (patch) | |
tree | 46694794d0a173b5ee48a0763ed49f62aa28ef34 /asn1.c | |
parent | 57e4216961a5d0bd4f73250e2f4171a25aa176e2 (diff) |
Rename "asn1_octet_string_value_decode()" to
"asn1_string_value_decode()", as it can be used for various character
string types as well.
Turn "asn1_octet_string_decode()" into "asn1_string_decode()", which
takes an additional argument giving the tag expected for the string in
question, and make "asn1_octet_string_decode()" a wrapper around it.
Clean up the ASN.1 dissection in the Kerberos dissector, making more use
of the code in "asn1.c", wrapping more operations up in macros, and
doing some more type checking.
Use "REP" rather than "RESP" in names and strings; "REP" is what the
Kerberos spec uses.
Make the routines in the Kerberos dissector not used outside that
dissector static.
Fix some problems with the dissection of strings in the Kerberos
dissector (it was extracting the data from the wrong place in the
packet).
In Kerberos V5, the "kvno" item in the EncryptedData type is optional;
treat it as such.
Treat integers as unsigned in the Kerberos dissector.
svn path=/trunk/; revision=2777
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 * ( |