Primitive type formats

This section defines the wire format for a number of primitive types.

M_ASCIIString

This represents an arbitrary ASCII string.

Strings always include a final 0 byte, which is included in the length n below.

Field Size Format Meaning

n

4 bytes

Little-endian unsigned integer

Number of bytes in string

Content

n bytes

ASCII data

The contents of the string

Padding

0-3 bytes

0-valued bytes

Rounds length up to a multiple of 4 bytes total

M_Bignum

This represents an arbitrary integer.

All bignums are multiples of 4 bytes long. Apart from that, normally the minimal representation is used, except that 0 is always represented by 4 bytes.

Field Size Format Meaning

n

4 bytes

Little-endian unsigned integer

Number of bytes in bignum

Content

n bytes

Little-endian integer

The value of the integer

M_ByteBlock

This represents an arbitrary byte string

Field Size Format Meaning

n

4 bytes

Little-endian unsigned integer

Number of bytes in byteblock

Content

n bytes

Binary data

The contents of the byteblock

Padding

0-3 bytes

0-valued bytes

Rounds length up to a multiple of 4 bytes total

M_FileID

This represents an 11-byte string, usually a filename on a smartcard.

Field Size Format Meaning

Content

11 bytes

Binary data

The contents of the file ID

M_Hash

This represents a 20-byte string, often the result of a SHA-1 hash or similar.

Field Size Format Meaning

Content

20 bytes

Binary data

The contents of the hash

M_Hash32

This represents a 32-byte string, often the result of a SHA-256 hash or similar.

Field Size Format Meaning

Content

32 bytes

Binary data

The contents of the hash

M_Hash64

This represents a 64-byte string, often the result of a SHA-512 hash or similar.

Field Size Format Meaning

Content

64 bytes

Binary data

The contents of the hash

M_Word

This represents a 32-bit unsigned integer.

Field Size Format Meaning

Value

4 bytes

Little-endian unsigned integer

The value of the integer