Class LittleEndianConversions
java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.LittleEndianConversions
This is a utility class containing data type conversions using little-endian
byte order.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
I2OSP
(int x) Convert an integer to an octet string of length 4.static void
I2OSP
(int value, byte[] output, int outOff) Convert an integer into a byte array beginning at the specified offset.static void
I2OSP
(int value, byte[] output, int outOff, int outLen) Convert an integer to a byte array beginning at the specified offset.static byte[]
I2OSP
(long input) Convert an integer to a byte array of length 8.static void
I2OSP
(long input, byte[] output, int outOff) Convert an integer to a byte array of length 8.static int
OS2IP
(byte[] input) Convert an octet string of length 4 to an integer.static int
OS2IP
(byte[] input, int inOff) Convert an byte array of length 4 beginning at offset into an integer.static int
OS2IP
(byte[] input, int inOff, int inLen) Convert a byte array of the given length beginning at offset into an integer.static long
OS2LIP
(byte[] input, int inOff) Convert a byte array of length 8 beginning at inOff into a long integer.static byte[]
toByteArray
(int[] input, int outLen) Convert an int array to a byte array of the specified length.static int[]
toIntArray
(byte[] input) Convert a byte array to an int array.
-
Method Details
-
OS2IP
public static int OS2IP(byte[] input) Convert an octet string of length 4 to an integer. No length checking is performed.- Parameters:
input
- the byte array holding the octet string- Returns:
- an integer representing the octet string input
- Throws:
ArithmeticException
- if the length of the given octet string is larger than 4.
-
OS2IP
public static int OS2IP(byte[] input, int inOff) Convert an byte array of length 4 beginning at offset into an integer.- Parameters:
input
- the byte arrayinOff
- the offset into the byte array- Returns:
- the resulting integer
-
OS2IP
public static int OS2IP(byte[] input, int inOff, int inLen) Convert a byte array of the given length beginning at offset into an integer.- Parameters:
input
- the byte arrayinOff
- the offset into the byte arrayinLen
- the length of the encoding- Returns:
- the resulting integer
-
OS2LIP
public static long OS2LIP(byte[] input, int inOff) Convert a byte array of length 8 beginning at inOff into a long integer.- Parameters:
input
- the byte arrayinOff
- the offset into the byte array- Returns:
- the resulting long integer
-
I2OSP
public static byte[] I2OSP(int x) Convert an integer to an octet string of length 4.- Parameters:
x
- the integer to convert- Returns:
- the converted integer
-
I2OSP
public static void I2OSP(int value, byte[] output, int outOff) Convert an integer into a byte array beginning at the specified offset.- Parameters:
value
- the integer to convertoutput
- the byte array to hold the resultoutOff
- the integer offset into the byte array
-
I2OSP
public static void I2OSP(int value, byte[] output, int outOff, int outLen) Convert an integer to a byte array beginning at the specified offset. No length checking is performed (i.e., if the integer cannot be encoded with length octets, it is truncated).- Parameters:
value
- the integer to convertoutput
- the byte array to hold the resultoutOff
- the integer offset into the byte arrayoutLen
- the length of the encoding
-
I2OSP
public static byte[] I2OSP(long input) Convert an integer to a byte array of length 8.- Parameters:
input
- the integer to convert- Returns:
- the converted integer
-
I2OSP
public static void I2OSP(long input, byte[] output, int outOff) Convert an integer to a byte array of length 8.- Parameters:
input
- the integer to convertoutput
- byte array holding the outputoutOff
- offset in output array where the result is stored
-
toByteArray
public static byte[] toByteArray(int[] input, int outLen) Convert an int array to a byte array of the specified length. No length checking is performed (i.e., if the last integer cannot be encoded with length % 4 octets, it is truncated).- Parameters:
input
- the int arrayoutLen
- the length of the converted array- Returns:
- the converted array
-
toIntArray
public static int[] toIntArray(byte[] input) Convert a byte array to an int array.- Parameters:
input
- the byte array- Returns:
- the converted array
-