31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

10.7 Secure Socket Streambuffer ( secure<br />

socket streambuf )<br />

1. Definition<br />

An instance sb of class secure socket streambuf can be used as an adapter: It turns a<br />

leda socket s into a C++-streambuf object. This object can be used in standard C++<br />

ostreams and istreams, which makes the communication through the socket easier. Moreover,<br />

secure socket streambuf uses cryptography to secure the communication. Every piece<br />

of data is authenticated, (possibly) compressed and encrypted before it is sent.<br />

If two parties want to use the class secure socket streambuf to exchange data they have<br />

to do the following. First they establish a connection through leda sockets. <strong>The</strong>n each<br />

party contructs an instance of the class secure socket streambuf which is attached to its<br />

socket. (An example showing how to this can be found at the end of Section 4.14; simply<br />

replace “socket streambuf ” by “secure socket streambuf ” and add the passphrase(s).)<br />

<strong>The</strong> communication between two instances of the class secure socket streambuf can be<br />

divided in two phases. In the first phase the two parties negotiate session parameters like<br />

packet sizes and they also agree on a so-called session-seed which will be explained later.<br />

In the second phase the actual user data is exchanged. Each phases is protected with<br />

cryptography. <strong>The</strong> authentication and encryption keys for the first phase are generated<br />

in a deterministic way from the user-supplied passphrase(s). <strong>The</strong>y are called master keys<br />

because they remain the same as long as the passphrases are not changed. In order to<br />

protect the master keys we use them only during the first phase, which consists of two<br />

messages from each party. After that we use the random session seed (in addition to the<br />

passphrases) to compute session keys which are used during the second phase.<br />

#include < <strong>LEDA</strong>/coding/secure socket streambuf.h ><br />

2. Creation<br />

secure socket streambuf sb(leda socket& s, const CryptByteString& auth passphrase,<br />

const CryptByteString& cipher passphrase,<br />

uint32 out buf sz = DefaultBufferSize,<br />

uint32 in buf sz = DefaultBufferSize,<br />

bool enable compression = false,<br />

bool send acknowledge = false);<br />

creates a sb and attaches it to the socket s. <strong>The</strong> two passphrases are<br />

used to generate the keys for authentication and encryption. <strong>The</strong><br />

parameters out buf sz and in buf sz determine the maximum size of<br />

the out-buffer and the in-buffer. <strong>The</strong> paramter enable compression<br />

determines whether compression is used. send acknowledge specifies<br />

whether an acknowledgement is sent for every received packet.<br />

Precondition: <strong>The</strong> connection between the server and the client<br />

must have been established when sb is created.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!