Top Description Fields Constructors Methods
org.bouncycastle.tls

public Class ByteQueue

extends Object
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.nio.ByteBuffer

A queue for bytes. This file could be more optimized.

Field Summary

Modifier and TypeField and Description
private int
available

How many bytes in the buffer are valid data.

private byte[]
databuf

The buffer where we store our data.

private boolean
private int
skipped

How many bytes at the beginning of the buffer are skipped.

Constructor Summary

AccessConstructor and Description
public
public
ByteQueue(int capacity)

public
ByteQueue(byte[] buf, int off, int len)

Method Summary

Modifier and TypeMethod and Description
public void
addData(byte[]
A byte-array to read data from.
buf
,
int
How many bytes to skip at the beginning of the array.
off
,
int
How many bytes to read from the array.
len
)

Add some data to our buffer.

public int

Returns:

The number of bytes which are available in this buffer.
available
()

public void
copyTo(OutputStream
The OutputStream to copy the bytes to.
output
,
int
How many bytes to copy.
length
)

Copy some bytes from the beginning of the data to the provided OutputStream.

public static int

Returns:

The smallest number which can be written as 2^x which is bigger than i.
nextTwoPow
(int i)

public void
read(byte[]
The buffer where the read data will be copied to.
buf
,
int
How many bytes to skip at the beginning of buf.
offset
,
int
How many bytes to read at all.
len
,
int
How many bytes from our data to skip.
skip
)

Read data from the buffer.

public void
read(ByteBuffer
The ByteBuffer where the read data will be copied to.
buf
,
int
How many bytes to read at all.
len
,
int
How many bytes from our data to skip.
skip
)

Read data from the buffer.

pack-priv HandshakeMessageInput

Returns:

A HandshakeMessageInput over the data.
readHandshakeMessage
(int
How many bytes will be readable.
length
)

Return a HandshakeMessageInput over some bytes at the beginning of the data.

public int
public int
readUint16(int skip)

public short
readUint8(int skip)

public void
removeData(int
How many bytes to remove.
i
)

Remove some bytes from our data from the beginning.

public void
removeData(byte[]
The buffer where the removed data will be copied to.
buf
,
int
How many bytes to skip at the beginning of buf.
off
,
int
How many bytes to read at all.
len
,
int
How many bytes from our data to skip.
skip
)

Remove data from the buffer.

public void
removeData(ByteBuffer
The ByteBuffer where the removed data will be copied to.
buf
,
int
How many bytes to read at all.
len
,
int
How many bytes from our data to skip.
skip
)

Remove data from the buffer.

public byte[]
removeData(int len, int skip)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

availableback to summary
private int available

How many bytes in the buffer are valid data.

databufback to summary
private byte[] databuf

The buffer where we store our data.

readOnlyBufback to summary
private boolean readOnlyBuf
skippedback to summary
private int skipped

How many bytes at the beginning of the buffer are skipped.

Constructor Detail

ByteQueueback to summary
public ByteQueue()
ByteQueueback to summary
public ByteQueue(int capacity)
ByteQueueback to summary
public ByteQueue(byte[] buf, int off, int len)

Method Detail

addDataback to summary
public void addData(byte[] buf, int off, int len)

Add some data to our buffer.

Parameters
buf:byte[]

A byte-array to read data from.

off:int

How many bytes to skip at the beginning of the array.

len:int

How many bytes to read from the array.

availableback to summary
public int available()
Returns:int

The number of bytes which are available in this buffer.

copyToback to summary
public void copyTo(OutputStream output, int length) throws IOException

Copy some bytes from the beginning of the data to the provided OutputStream.

Parameters
output:OutputStream

The OutputStream to copy the bytes to.

length:int

How many bytes to copy.

nextTwoPowback to summary
public static int nextTwoPow(int i)
Returns:int

The smallest number which can be written as 2^x which is bigger than i.

readback to summary
public void read(byte[] buf, int offset, int len, int skip)

Read data from the buffer.

Parameters
buf:byte[]

The buffer where the read data will be copied to.

offset:int

How many bytes to skip at the beginning of buf.

len:int

How many bytes to read at all.

skip:int

How many bytes from our data to skip.

readback to summary
public void read(ByteBuffer buf, int len, int skip)

Read data from the buffer.

Parameters
buf:ByteBuffer

The ByteBuffer where the read data will be copied to.

len:int

How many bytes to read at all.

skip:int

How many bytes from our data to skip.

readHandshakeMessageback to summary
pack-priv HandshakeMessageInput readHandshakeMessage(int length)

Return a HandshakeMessageInput over some bytes at the beginning of the data.

Parameters
length:int

How many bytes will be readable.

Returns:HandshakeMessageInput

A HandshakeMessageInput over the data.

readInt32back to summary
public int readInt32()
readUint16back to summary
public int readUint16(int skip)
readUint8back to summary
public short readUint8(int skip)
removeDataback to summary
public void removeData(int i)

Remove some bytes from our data from the beginning.

Parameters
i:int

How many bytes to remove.

removeDataback to summary
public void removeData(byte[] buf, int off, int len, int skip)

Remove data from the buffer.

Parameters
buf:byte[]

The buffer where the removed data will be copied to.

off:int

How many bytes to skip at the beginning of buf.

len:int

How many bytes to read at all.

skip:int

How many bytes from our data to skip.

removeDataback to summary
public void removeData(ByteBuffer buf, int len, int skip)

Remove data from the buffer.

Parameters
buf:ByteBuffer

The ByteBuffer where the removed data will be copied to.

len:int

How many bytes to read at all.

skip:int

How many bytes from our data to skip.

removeDataback to summary
public byte[] removeData(int len, int skip)
shrinkback to summary
public void shrink()