Opening a TLS connectionWe are going to look in detail at the opening of a TLS connection, both to further our understanding of ways in which security can be provided, but also in order to see a fairly rich example of protocol encoding. We are not so much interested in learning the exact details but generally in understanding how protocol packets are constructed in general, which always involves thinking of how the originator of a packet formats it so that the destination can parse it. Type-Length-Value (TLV) codingsIt is very commong when coding for a protocol that fields of multiple type will need to be encoded, and those types may be defined specifically for the protocol. For these typically a byte (if there are no more than 255 types) will be used to indicate the type, then perhaps another byte or a short will be used to indicate the length of a data field associated with the type, followed immediately by as many bytes of data as the length field indicates. This type of construction is called a TLV encoding. Using such a construction means that there can be multiple types contained within a data packet. It is also often the case that a collection of such fields is padded to fill its length out to an even number of words (or some other boundary), and the length of that padding need not be explicitly given since the receiver can figure out itself how much there must be (provided of course it knows where it was in relation to such a boundary when decoding began). TLS record typesOnce we have moved up the receiving stack to the TLS Provider level, the message that is output by TCP is interpreted as a set of TLS records. There are 4 types of such record:
|
|
|
Code linksListings
|