Top Fields Constructors Methods
org.conscrypt.ct

public Class Serialization

extends Object
Class Inheritance
Annotations
@Internal
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, .OutputStream, java.util.ArrayList, org.conscrypt.Internal

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static byte
readByte(InputStream input)

Read a single byte from the input stream.

public static byte[]
readDEROctetString(byte[] input)

public static byte[]
public static byte[]
readFixedBytes(InputStream input, int
the number of bytes to read.
length
)

Read a fixed number of bytes from the input stream.

public static byte[][]
readList(byte[] input, int listWidth, int elemWidth)

public static byte[][]
readList(InputStream input, int
the width of the vector's length field, in bytes.
listWidth
,
int
the width of each element's length field, in bytes.
elemWidth
)

Read a variable length vector of variable sized elements as described by RFC5246 section 4.3.

public static long
readLong(InputStream input, int
the width of the number, in bytes.
width
)

Read a number in big endian format from the input stream.

public static int
readNumber(InputStream input, int
the width of the number, in bytes.
width
)

Read a number in big endian format from the input stream.

public static byte[]
readVariableBytes(InputStream input, int
the width of the length prefix, in bytes.
width
)

Read a length-prefixed sequence of bytes.

public static void
writeFixedBytes(OutputStream output, byte[]
the data to be written.
data
)

Write a fixed number sequence of bytes to the ouput stream.

public static void
writeNumber(OutputStream output, long
the value to be written.
value
,
int
the width of the encoded number, in bytes
width
)

Write a number to the output stream.

public static void
writeVariableBytes(OutputStream output, byte[]
the data to be written.
data
,
int
the width of the length prefix, in bytes.
width
)

Write length prefixed sequence of bytes to the ouput stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DER_LENGTH_LONG_FORM_FLAGback to summary
private static final int DER_LENGTH_LONG_FORM_FLAG
DER_TAG_MASKback to summary
private static final int DER_TAG_MASK
DER_TAG_OCTET_STRINGback to summary
private static final int DER_TAG_OCTET_STRING

Constructor Detail

Serializationback to summary
private Serialization()

Method Detail

readByteback to summary
public static byte readByte(InputStream input) throws SerializationException

Read a single byte from the input stream.

Exceptions
SerializationException:
if EOF is encountered.
readDEROctetStringback to summary
public static byte[] readDEROctetString(byte[] input) throws SerializationException
readDEROctetStringback to summary
public static byte[] readDEROctetString(InputStream input) throws SerializationException
readFixedBytesback to summary
public static byte[] readFixedBytes(InputStream input, int length) throws SerializationException

Read a fixed number of bytes from the input stream.

Parameters
length:int

the number of bytes to read.

Exceptions
SerializationException:
if EOF is encountered.
readListback to summary
public static byte[][] readList(byte[] input, int listWidth, int elemWidth) throws SerializationException
readListback to summary
public static byte[][] readList(InputStream input, int listWidth, int elemWidth) throws SerializationException

Read a variable length vector of variable sized elements as described by RFC5246 section 4.3. The vector is prefixed by its total length, in bytes and in big endian format, so is each element contained in the vector.

Parameters
listWidth:int

the width of the vector's length field, in bytes.

elemWidth:int

the width of each element's length field, in bytes.

Exceptions
SerializationException:
if EOF is encountered.
readLongback to summary
public static long readLong(InputStream input, int width) throws SerializationException

Read a number in big endian format from the input stream. This methods supports a width of up to 8 bytes.

Parameters
width:int

the width of the number, in bytes.

Exceptions
SerializationException:
if EOF is encountered.
IllegalArgumentException:
if width is negative or greater than 8
readNumberback to summary
public static int readNumber(InputStream input, int width) throws SerializationException

Read a number in big endian format from the input stream. This methods only supports a width of up to 4 bytes.

Parameters
width:int

the width of the number, in bytes.

Exceptions
SerializationException:
if EOF is encountered, or if width is negative or greater than 4
readVariableBytesback to summary
public static byte[] readVariableBytes(InputStream input, int width) throws SerializationException

Read a length-prefixed sequence of bytes. The length must be encoded in big endian format.

Parameters
width:int

the width of the length prefix, in bytes.

Exceptions
SerializationException:
if EOF is encountered, or if width is negative or greater than 4
writeFixedBytesback to summary
public static void writeFixedBytes(OutputStream output, byte[] data) throws SerializationException

Write a fixed number sequence of bytes to the ouput stream.

Parameters
data:byte[]

the data to be written.

writeNumberback to summary
public static void writeNumber(OutputStream output, long value, int width) throws SerializationException

Write a number to the output stream. The number is encoded in big endian order.

Parameters
value:long

the value to be written.

width:int

the width of the encoded number, in bytes

Exceptions
SerializationException:
if the number is too large to fit in width bytes or width is negative.
writeVariableBytesback to summary
public static void writeVariableBytes(OutputStream output, byte[] data, int width) throws SerializationException

Write length prefixed sequence of bytes to the ouput stream. The length prefix is encoded in big endian order.

Parameters
data:byte[]

the data to be written.

width:int

the width of the length prefix, in bytes.

Exceptions
SerializationException:
if the length of data is too large to fit in width bytes or width is negative.