4.2. Miscellaneous
Comments begin with "/*" and end with "*/".
Optional components are denoted by enclosing them in "[[ ]]" double
brackets.
Single byte entities containing uninterpreted data are of type
opaque.
4.3. Vectors
A vector (single dimensioned array) is a stream of homogeneous data
elements. The size of the vector may be specified at documentation
time or left unspecified until runtime. In either case the length
declares the number of bytes, not the number of elements, in the
vector. The syntax for specifying a new type T' that is a fixed
length vector of type T is
T T'[n];
Here T' occupies n bytes in the data stream, where n is a multiple of
the size of T. The length of the vector is not included in the
encoded stream.
In the following example, Datum is defined to be three consecutive
bytes that the protocol does not interpret, while Data is three
consecutive Datum, consuming a total of nine bytes.
opaque Datum[3]; /* three uninterpreted bytes */
Datum Data[9]; /* 3 consecutive 3 byte vectors */
RFC 2246 The TLS Protocol Version 1.0 January 1999
Variable length vectors are defined by specifying a subrange of legal
lengths, inclusively, using the notation <floor..ceiling>. When
encoded, the actual length precedes the vector's contents in the byte
stream. The length will be in the form of a number consuming as many
bytes as required to hold the vector's specified maximum (ceiling)
length. A variable length vector with an actual length field of zero
is referred to as an empty vector.
T T'<floor..ceiling>;
In the following example, mandatory is a vector that must contain
between 300 and 400 bytes of type opaque. It can never be empty. The
actual length field consumes two bytes, a uint16, sufficient to
represent the value 400 (see Section 4.4). On the other hand, longer
can represent up to 800 bytes of data, or 400 uint16 elements, and it
may be empty. Its encoding will include a two byte actual length
field prepended to the vector. The length of an encoded vector must
be an even multiple of the length of a single element (for example, a
17 byte vector of uint16 would be illegal).
opaque mandatory;
/* length field is 2 bytes, cannot be empty */
uint16 longer;
/* zero to 400 16-bit unsigned integers */
4.4. Numbers
The basic numeric data type is an unsigned byte (uint8). All larger
numeric data types are formed from fixed length series of bytes
concatenated as described in Section 4.1 and are also unsigned. The
following numeric types are predefined.
uint8 uint16[2];
uint8 uint24[3];
uint8 uint32[4];
uint8 uint64[8];
All values, here and elsewhere in the specification, are stored in
"network" or "big-endian" order; the uint32 represented by the hex
bytes 01 02 03 04 is equivalent to the decimal value 16909060.
4.5. Enumerateds
An additional sparse data type is available called enum. A field of
type enum can only assume the values declared in the definition.
Each definition is a different type. Only enumerateds of the same
type may be assigned or compared. Every element of an enumerated must
RFC 2246 The TLS Protocol Version 1.0 January 1999
be assigned a value, as demonstrated in the following example. Since
the elements of the enumerated are not ordered, they can be assigned
=4= |