Cryptography for Developers

ASN.1 Data Types

Now that we have a basic grasp of ASN.1 syntax, we can examine the data types and their encodings that make ASN.1 so useful. ASN.1 specifies many data types for a wide range of applications most of which have no bearing whatsoever on cryptography and are omitted from our discussions. Readers are encouraged to read the X.680 and X.690 series of specifications if they want to master all that ASN.1 has to offer.

Any ASN.1 encoding begins with two common bytes (or octets, groupings of eight bits) that are universally applied regardless of the type. The first byte is the type indicator, which also includes some modification bits we shall briefly touch upon. The second byte is the length header. Lengths are a bit complex at first to decode, but in practice are fairly easy to implement.

The data types we shall be examining consist of the following types.

  • Boolean

  • OCTET String

  • BIT String

  • IA5String

  • PrintableString

  • INTEGER

  • OBJECT Identifier (OID)

  • UTCTIME

  • NULL

  • SEQUENCE, SEQUENCE OF

  • SET

  • SET OF

This is enough of the types from the ASN.1 specifications to implement PKCS #1 and ANSI X9.62 standards, yet not too much to overwhelm the developer.

ASN.1 Header Byte

The header byte is always placed at the start of any ASN.1 encoding and is divides into three parts: the classification, the constructed bit, and the primitive type. The header byte is broken as shown in Figure 2.2.


Figure 2.2: The ASN.1 Header Byte

In the ASN.1 world, they label the...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Memory Chips
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.