Top Description Constructors Methods
org.bouncycastle.pqc.legacy.math.linearalgebra

public final Class BigEndianConversions

extends Object
Class Inheritance

This is a utility class containing data type conversions using big-endian byte order.
See Also
LittleEndianConversions

Constructor Summary

AccessConstructor and Description
private
BigEndianConversions()

Default constructor (private).

Method Summary

Modifier and TypeMethod and Description
public static byte[]

Returns:

the converted integer
I2OSP
(int
the integer to convert
x
)

Convert an integer to an octet string of length 4 according to IEEE 1363, Section 5.5.3.

public static byte[]

Returns:

an octet string of length oLen representing the integer x, or null if the integer is negative
I2OSP
(int
the integer to convert
x
,
int
the desired length of the octet string
oLen
)

Convert an integer to an octet string according to IEEE 1363, Section 5.5.3.

public static void
I2OSP(int
the integer to convert
input
,
byte[]
byte array holding the output
output
,
int
offset in output array where the result is stored
outOff
)

Convert an integer to an octet string of length 4 according to IEEE 1363, Section 5.5.3.

public static byte[]

Returns:

the converted integer
I2OSP
(long
the integer to convert
input
)

Convert an integer to an octet string of length 8 according to IEEE 1363, Section 5.5.3.

public static void
I2OSP(long
the integer to convert
input
,
byte[]
byte array holding the output
output
,
int
offset in output array where the result is stored
outOff
)

Convert an integer to an octet string of length 8 according to IEEE 1363, Section 5.5.3.

public static void
I2OSP(int
the integer to convert
input
,
byte[]
byte array holding the output
output
,
int
offset in output array where the result is stored
outOff
,
int
the length of the encoding
length
)

Convert an integer to an octet string of the specified length according to IEEE 1363, Section 5.5.3.

public static int

Returns:

an integer representing the octet string input, or 0 if the represented integer is negative or too large or the byte array is empty
OS2IP
(byte[]
the byte array holding the octet string
input
)

Convert an octet string to an integer according to IEEE 1363, Section 5.5.3.

public static int

Returns:

the resulting integer
OS2IP
(byte[]
the byte array
input
,
int
the offset into the byte array
inOff
)

Convert a byte array of length 4 beginning at offset into an integer.

public static int

Returns:

an integer representing the octet string bytes, or 0 if the represented integer is negative or too large or the byte array is empty
OS2IP
(byte[]
the byte array holding the octet string
input
,
int
the offset in the input byte array where the octet string starts
inOff
,
int
the length of the encoded integer
inLen
)

Convert an octet string to an integer according to IEEE 1363, Section 5.5.3.

public static long

Returns:

the resulting long integer
OS2LIP
(byte[]
the byte array
input
,
int
the offset into the byte array
inOff
)

Convert a byte array of length 8 beginning at inOff into a long integer.

public static byte[]

Returns:

the converted array
toByteArray
(final int[]
the int array
input
)

Convert an int array into a byte array.

public static byte[]

Returns:

the converted array
toByteArray
(final int[]
the int array
input
,
int
the length of the converted array
length
)

Convert an int array into a byte array of the specified length.

public static int[]

Returns:

the converted array
toIntArray
(byte[]
the byte array
input
)

Convert a byte array into an int array.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BigEndianConversionsback to summary
private BigEndianConversions()

Default constructor (private).

Method Detail

I2OSPback to summary
public static byte[] I2OSP(int x)

Convert an integer to an octet string of length 4 according to IEEE 1363, Section 5.5.3.

Parameters
x:int

the integer to convert

Returns:byte[]

the converted integer

I2OSPback to summary
public static byte[] I2OSP(int x, int oLen) throws ArithmeticException

Convert an integer to an octet string according to IEEE 1363, Section 5.5.3. Length checking is performed.

Parameters
x:int

the integer to convert

oLen:int

the desired length of the octet string

Returns:byte[]

an octet string of length oLen representing the integer x, or null if the integer is negative

Exceptions
ArithmeticException:
if x can't be encoded into oLen octets.
I2OSPback to summary
public static void I2OSP(int input, byte[] output, int outOff)

Convert an integer to an octet string of length 4 according to IEEE 1363, Section 5.5.3.

Parameters
input:int

the integer to convert

output:byte[]

byte array holding the output

outOff:int

offset in output array where the result is stored

I2OSPback to summary
public static byte[] I2OSP(long input)

Convert an integer to an octet string of length 8 according to IEEE 1363, Section 5.5.3.

Parameters
input:long

the integer to convert

Returns:byte[]

the converted integer

I2OSPback to summary
public static void I2OSP(long input, byte[] output, int outOff)

Convert an integer to an octet string of length 8 according to IEEE 1363, Section 5.5.3.

Parameters
input:long

the integer to convert

output:byte[]

byte array holding the output

outOff:int

offset in output array where the result is stored

I2OSPback to summary
public static void I2OSP(int input, byte[] output, int outOff, int length)

Convert an integer to an octet string of the specified length according to IEEE 1363, Section 5.5.3. No length checking is performed (i.e., if the integer cannot be encoded into length octets, it is truncated).

Parameters
input:int

the integer to convert

output:byte[]

byte array holding the output

outOff:int

offset in output array where the result is stored

length:int

the length of the encoding

OS2IPback to summary
public static int OS2IP(byte[] input)

Convert an octet string to an integer according to IEEE 1363, Section 5.5.3.

Parameters
input:byte[]

the byte array holding the octet string

Returns:int

an integer representing the octet string input, or 0 if the represented integer is negative or too large or the byte array is empty

Exceptions
ArithmeticException:
if the length of the given octet string is larger than 4.
OS2IPback to summary
public static int OS2IP(byte[] input, int inOff)

Convert a byte array of length 4 beginning at offset into an integer.

Parameters
input:byte[]

the byte array

inOff:int

the offset into the byte array

Returns:int

the resulting integer

OS2IPback to summary
public static int OS2IP(byte[] input, int inOff, int inLen)

Convert an octet string to an integer according to IEEE 1363, Section 5.5.3.

Parameters
input:byte[]

the byte array holding the octet string

inOff:int

the offset in the input byte array where the octet string starts

inLen:int

the length of the encoded integer

Returns:int

an integer representing the octet string bytes, or 0 if the represented integer is negative or too large or the byte array is empty

OS2LIPback to summary
public static long OS2LIP(byte[] input, int inOff)

Convert a byte array of length 8 beginning at inOff into a long integer.

Parameters
input:byte[]

the byte array

inOff:int

the offset into the byte array

Returns:long

the resulting long integer

toByteArrayback to summary
public static byte[] toByteArray(final int[] input)

Convert an int array into a byte array.

Parameters
input:int[]

the int array

Returns:byte[]

the converted array

toByteArrayback to summary
public static byte[] toByteArray(final int[] input, int length)

Convert an int array into a byte array of the specified length. No length checking is performed (i.e., if the last integer cannot be encoded into length % 4 octets, it is truncated).

Parameters
input:int[]

the int array

length:int

the length of the converted array

Returns:byte[]

the converted array

toIntArrayback to summary
public static int[] toIntArray(byte[] input)

Convert a byte array into an int array.

Parameters
input:byte[]

the byte array

Returns:int[]

the converted array