- The below diagram traces the path taken by a packet as it travels over the ppp-over-ssl tunnel.
- Each layer of protocol adds some bytes of overhead. This is illustrated in the above diagram. Note that
the SSL layer, has been shown to add "X" bytes of overhead. I am using
OpenSSL(0.9.6b and 0.9.7a) implementation for the SSL protocol.
To find out the overhead added by the SSL layer, one needs to read the standards published by netscape
here. Also more information can be found out at
this site.
- I have put up a small note about SSL handshake procedure. This gives the reader a gentle introduction
to how SSL clients and server's actually negotiate. You can find this note
here.
- You will find that SSL bundles packet as:
1-byte packet_type (Handshake, application_data etc).
2-byte Version number (major(1B), minor (1B))
2-Byte packet length
n1-byte payload;
m-byte MAC (message authentication code); e.g. SHA1 (20 Bytes), MD5 (16 Bytes)
n2-byte random padding; to make [payload + MAC + paddin_lenght + padding] a multiple of
block_size used by the cipher. (4 to 255 Bytes)
1-Byte padding_length (Hence one can add a maximum of 255 bytes of padding.
- I found the below example from
RFC2246 to calculate the overhead,
which I reproduce below (with some modifications):
Dierks & Allen Standards Track [Page 19]
RFC 2246 The TLS Protocol Version 1.0 January 1999
--SNIP--
Example: If the block length is 8 bytes, the content length
is 61 bytes, and the MAC length is 20 bytes, the length
before padding is 82 bytes (content_length(61) + MAC(20) + padding_len(1)). Thus, the
padding length modulo 8 must be equal to 6 in order to make
the total length an even multiple of 8 bytes (the block
length). The padding length can be 6, 14, 22, and so on,
through 254. If the padding length were the minimum necessary,
6, the padding would be 6 bytes, each containing the value 6.
Thus, the last 8 octets of the GenericBlockCipher before block
encryption would be xx 06 06 06 06 06 06 06, where xx is the
last octet of the MAC.
--SNIP--
- To use SSL, one needs to select a cipher suite, which includes algorithms for Key exchange (RSA, DSA etc.),
Authentication (RSA, DH etc.), Encryption (AES, DES etc.) and MAC (SHA, MD5 etc.).
One can find all the availavle cipher suites, by executing the following command:
sslvpn@mia:~/bin> openssl ciphers -v -ssl3 HIGH
ADH-AES256-SHA SSLv3 Kx=DH Au=None Enc=AES(256) Mac=SHA1
DHE-RSA-AES256-SHA SSLv3 Kx=DH Au=RSA Enc=AES(256) Mac=SHA1
DHE-DSS-AES256-SHA SSLv3 Kx=DH Au=DSS Enc=AES(256) Mac=SHA1
AES256-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(256) Mac=SHA1
KRB5-DES-CBC3-MD5 SSLv3 Kx=KRB5 Au=KRB5 Enc=3DES(168) Mac=MD5
KRB5-DES-CBC3-SHA SSLv3 Kx=KRB5 Au=KRB5 Enc=3DES(168) Mac=SHA1
EDH-RSA-DES-CBC3-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1
EDH-DSS-DES-CBC3-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1
DES-CBC3-SHA SSLv3 Kx=RSA Au=RSA Enc=3DES(168) Mac=SHA1
ADH-DES-CBC3-SHA SSLv3 Kx=DH Au=None Enc=3DES(168) Mac=SHA1
To select a particular cipher suite in stunnel, include the following line in stunnel.conf.
--SNIP--
ciphers = AES128-SHA:ADH-AES256-SHA
--SNIP--
- Let us assume that we are using AES256-SHA. Suppose that the input to the SSL layer is
a packet of length 144 bytes, then you can calculate the total overhead added by SSL as follows:
- Add 20(MAC) + 1(padding_len) = 5 Bytes to Packet. This gives 144 + 21 = 165.
- Find out what block size is used by the cipher. In our case, since we are using
aes128-cbc, the block size is 16 bytes.
- Calculate 165 % 16 = 5. Hence in order to make the packet an even multiple of 16, you will have to add
either 11 bytes (to make it 176) or 27 bytes (to make it 192) etc. of padding. The exact amount of padding added
is random, but the minimum is 4 bytes and maximum is 255 bytes.
- In this case, let us assume that we have added just 11 Bytes to make the packet to be of length 176 bytes, which
is an even multiple of 16.
- Now add the 5 byte header (type(1) + version(2) + len(2)).
- Thus we have a total packet size of 181 Bytes.
- Thus we conclude that the SSL layer adds a minimum of (5(header) + 16(MAC:MD5) +
4(padding) + 1(padding len) = 26 bytes) and maximum of (5(header) + 20(MAC:SHA1) +
255(padding) + 1(padding len) = 281 bytes).
- Assuming no compression mechanism is used in PPP or SSL (NULL by default),
we conducted a series of experiments
with random packet sizes (and cipher suite AES256-SHA)
and measured the packet length on the wire. The experimental results are
provided below:
-----------------------------------------------------
Application Data on wire Overhead
Data (no comp)
-----------------------------------------------------
100 268 168
275 444 169
350 524 174
502 684 182
613 796 183
750 924 174
849 1036 187
917 1100 183
1010 1196 186
1200 1388 186
-----------------------------------------------------
Average Overhead: 179.4
-----------------------------------------------------
- I used a very versatile program called ethereal to sniff the
packets on the wire and modudpgen to
generate the random data.