Chapter 4. ASN.1 to CSV Type Mappings

Table of Contents

Mapping Top-Level Types
Mapping Simple Types
Mapping Complex Types
Data Conversion

Converting ASN.1 types to CSV output is not always very straightforward. It is akin to normalizing a database, except that there is only one table. For complex types, it is necessary to duplicate information across several rows.

There exists no standard for converting ASN.1 data to CSV. BER, CER, and DER data are encoded in a hierarchical format that lends itself to translation to other hierarchical formats such as XML. CSV, on the other hand, is flat data format: there are no structured types or children, and all data in a CSV file are displayed on single lines. This complicates the translation of ASN.1 to CSV, since structured data types like SEQUENCEs can be nested to an arbitrary depth or repeated an arbitrary number of times.

While these limitations make conversion a difficult problem, CSV offers some advantages over XML. CSV files are usually considerably smaller than XML, since no markup is necessary to distinguish elements. Many databases import CSV data directly into tables, so no intermediate transformations are required. CSV files can be easier to manipulate procedurally; no external XML parsers are required to read the files, and many scripting languages have built-in facilities for working with comma-delimited data.

We may divide conversion into roughly two steps: collecting the column headers and then outputting the column data. Header information comes from parsing the input specification, while the column data are found in the actual encoded content. This documentation is primarily concerned with how the column headers are collected.