This class provides Input/Output data functionality
for handshake layer. It provides read and write operations
and accumulates all sent/received handshake's data.
This class can be presented as a combination of 2 data pipes.
The first data pipe is a pipe of income data: append method
places the data at the beginning of the pipe, and read methods
consume the data from the pipe. The second pipe is an outcoming
data pipe: write operations plases the data into the pipe,
and getData methods consume the data.
It is important to note that work with pipe cound not be
started if there is unconsumed data in another pipe. It is
reasoned by the following: handshake protocol performs read
and write operations consecuently. I.e. it first reads all
income data and only than produces the responce and places it
into the stream.
The read operations of the stream presented by the methods
of SSLInputStream which in its turn is an extension of InputStream.
So this stream can be used as an InputStream parameter for
certificate generation.
Also input stream functionality supports marks. The marks
help to reset the position of the stream in case of incompleate
handshake records. Note that in case of exhausting
of income data the EndOfBufferException is thown which implies
the following:
1. the stream contains scrappy handshake record,
2. the read position should be reseted to marked,
3. and more income data is expected.
The throwing of the exception (instead of returning of -1 value
or incompleate filling of destination buffer)
helps to speed up the process of scrappy data recognition and
processing.
For more information about TLS handshake process see
TLS v 1 specification at http://www.ietf.org/rfc/rfc2246.txt.
append(byte[] src) Appends the income data to be read by handshake protocol.
The attempts to overflow the buffer by means of this methods
seem to be futile because of:
1.
Appends the income data to be read by handshake protocol.
The attempts to overflow the buffer by means of this methods
seem to be futile because of:
1. The SSL protocol specifies the maximum size of the record
and record protocol does not pass huge messages.
(see TLS v1 specification http://www.ietf.org/rfc/rfc2246.txt ,
p 6.2)
2. After each call of this method, handshake protocol should
start (and starts) the operations on received data and recognize
the fake data if such was provided (to check the size of certificate
for example).
Removes the data from the marked position to
the current read position. The method is usefull when it is needed
to delete one message from the internal buffer.