aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-04-07 15:39:55 -0700
committerGuy Harris <guy@alum.mit.edu>2014-04-07 22:46:30 +0000
commit26f46d40e9cc0feab71280fbff57d70beac20acc (patch)
tree13034fec7da0707974104eddd814b34bc9fe3349 /epan
parenta5cb72fe9eadfaf8cb0aefccb106a7eaad9266c9 (diff)
Handle string types with somewhat appropriate encodings.
For various string types defined in X.680, use the appropriate encoding, or ENC_ASCII|ENC_NA in some cases where we don't have an appropriate encoding yet. This most significantly fixes the handling of BMPString and UniversalString, which are supersets of ASCII (Unicode Basic Multilingual Plane and Unicode, respectively), but don't encode ASCII characters as single octets. It also fixes UTF8String to, well, properly recognize UTF-8. This also lets us get rid of the special handling of SyntaxBMPString in X.509sat (and, in fact, *requires* us to get rid of it, as, otherwise, the string value appears twice). Change-Id: I325c4e71a6110278eb23b86e0d986e6439cfc328 Reviewed-on: https://code.wireshark.org/review/994 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-ber.c82
-rw-r--r--epan/dissectors/packet-x509sat.c16
2 files changed, 83 insertions, 15 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index 851eb9bc06..05b17b4e7f 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -1506,6 +1506,7 @@ dissect_ber_constrained_octet_string(gboolean implicit_tag, asn1_ctx_t *actx, pr
gboolean pc, ind;
gint32 tag;
guint32 len;
+ guint encoding;
int hoffset;
int end_offset;
proto_item *it, *cause;
@@ -1611,7 +1612,86 @@ printf("OCTET STRING dissect_ber_octet_string(%s) entered\n", name);
length_remaining = len;
}
if (hf_id >= 0) {
- it = ber_proto_tree_add_item(actx->pinfo, tree, hf_id, tvb, offset, length_remaining, ENC_BIG_ENDIAN);
+ /*
+ * Strings are special. See X.690 section 8.20 "Encoding for
+ * values of the restricted character string types".
+ */
+ switch (tag) {
+
+ case BER_UNI_TAG_UTF8String:
+ /*
+ * UTF-8, obviously.
+ */
+ encoding = ENC_UTF_8|ENC_NA;
+ break;
+
+ case BER_UNI_TAG_NumericString:
+ case BER_UNI_TAG_PrintableString:
+ case BER_UNI_TAG_VisibleString:
+ case BER_UNI_TAG_IA5String:
+ /*
+ * (Subsets of) Boring Old ASCII, with no(?) ISO 2022
+ * escape sequences.
+ */
+ encoding = ENC_ASCII|ENC_NA;
+ break;
+
+ case BER_UNI_TAG_TeletexString:
+ /*
+ * Teletex character set, with ISO 8022 escape sequences.
+ * XXX - treat as ASCII for now. Need to handle the
+ * extensions and the escape sequences.
+ */
+ encoding = ENC_ASCII|ENC_NA;
+ break;
+
+ case BER_UNI_TAG_VideotexString:
+ /*
+ * Based on International Reference Version of ISO 646,
+ * with ISO 8022 escape sequences?
+ * XXX - treat as ASCII for now. Need to handle the
+ * C0/C1 characters and the escape sequences?
+ */
+ encoding = ENC_ASCII|ENC_NA;
+ break;
+
+ case BER_UNI_TAG_GraphicString:
+ case BER_UNI_TAG_GeneralString:
+ /*
+ * Boring Old ASCII, *with* ISO 2022 escape sequences.
+ * XXX - need to handle the escape sequences.
+ */
+ encoding = ENC_ASCII|ENC_NA;
+ break;
+
+ case BER_UNI_TAG_UniversalString:
+ /*
+ * UCS-4.
+ */
+ encoding = ENC_UCS_4|ENC_BIG_ENDIAN;
+ break;
+
+ case BER_UNI_TAG_CHARACTERSTRING:
+ /*
+ * XXX - what's the transfer syntax?
+ * Treat as ASCII for now.
+ */
+ encoding = ENC_ASCII|ENC_NA;
+ break;
+
+ case BER_UNI_TAG_BMPString:
+ /*
+ * UCS-2, not UTF-16; as it says, BMP, as in Basic
+ * Multilingual Plane.
+ */
+ encoding = ENC_UCS_2|ENC_BIG_ENDIAN;
+ break;
+
+ default:
+ encoding = ENC_BIG_ENDIAN;
+ break;
+ }
+ it = ber_proto_tree_add_item(actx->pinfo, tree, hf_id, tvb, offset, length_remaining, encoding);
actx->created_item = it;
ber_check_length(length_remaining, min_len, max_len, actx, it, FALSE);
} else {
diff --git a/epan/dissectors/packet-x509sat.c b/epan/dissectors/packet-x509sat.c
index cf240e3766..1c6a8cd898 100644
--- a/epan/dissectors/packet-x509sat.c
+++ b/epan/dissectors/packet-x509sat.c
@@ -1505,21 +1505,9 @@ dissect_x509sat_SyntaxIA5String(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, in
static int
dissect_x509sat_SyntaxBMPString(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
-#line 378 "../../asn1/x509sat/x509sat.cnf"
- tvbuff_t *wide_tvb = NULL;
- char *string;
-
offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_BMPString,
actx, tree, tvb, offset, hf_index,
- &wide_tvb);
-
-#line 383 "../../asn1/x509sat/x509sat.cnf"
- if (! wide_tvb) {
- return offset;
- }
- string = tvb_get_string_enc (wmem_packet_scope(), wide_tvb, 0, tvb_length(wide_tvb), ENC_UCS_2|ENC_BIG_ENDIAN);
- proto_item_append_text(actx->created_item, " %s", string);
-
+ NULL);
return offset;
}
@@ -1627,7 +1615,7 @@ dissect_x509sat_SyntaxGeneralString(gboolean implicit_tag _U_, tvbuff_t *tvb _U_
static int
dissect_x509sat_GUID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
-#line 392 "../../asn1/x509sat/x509sat.cnf"
+#line 378 "../../asn1/x509sat/x509sat.cnf"
gint8 ber_class;
gboolean pc;
gint32 tag;