|
Bouncy Castle Cryptography Library 1.86 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.bouncycastle.util.Pack
Utility methods for converting byte arrays into ints and longs, and back again.
| Constructor Summary | |
Pack()
|
|
| Method Summary | |
static int |
bigEndianToInt_High(byte[] bs,
int off,
int len)
|
static int |
bigEndianToInt_Low(byte[] bs,
int off,
int len)
|
static int |
bigEndianToInt(byte[] bs,
int off)
|
static void |
bigEndianToInt(byte[] bs,
int off,
int[] ns)
|
static void |
bigEndianToInt(byte[] bs,
int off,
int[] ns,
int nsOff,
int nsLen)
|
static long |
bigEndianToLong_High(byte[] bs,
int off,
int len)
|
static long |
bigEndianToLong_Low(byte[] bs,
int off,
int len)
Reads the len bytes at bs[off] as a big-endian value and returns it in the low len bytes of the result: a len of 3 returns what bigEndianToLong(byte[], int) would return for those three bytes preceded by five
zero ones.
|
static long |
bigEndianToLong(byte[] bs,
int off)
|
static void |
bigEndianToLong(byte[] bs,
int off,
long[] ns)
|
static void |
bigEndianToLong(byte[] bs,
int bsOff,
long[] ns,
int nsOff,
int nsLen)
|
static short |
bigEndianToShort(byte[] bs,
int off)
|
static void |
intToBigEndian_High(int n,
byte[] bs,
int off,
int len)
|
static void |
intToBigEndian_Low(int n,
byte[] bs,
int off,
int len)
|
static byte[] |
intToBigEndian(int n)
|
static byte[] |
intToBigEndian(int[] ns)
|
static void |
intToBigEndian(int[] ns,
byte[] bs,
int off)
|
static void |
intToBigEndian(int[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
|
static void |
intToBigEndian(int n,
byte[] bs)
|
static void |
intToBigEndian(int n,
byte[] bs,
int off)
|
static void |
intToLittleEndian_High(int n,
byte[] bs,
int off,
int len)
|
static void |
intToLittleEndian_Low(int n,
byte[] bs,
int off,
int len)
|
static byte[] |
intToLittleEndian(int n)
|
static byte[] |
intToLittleEndian(int[] ns)
|
static void |
intToLittleEndian(int[] ns,
byte[] bs,
int off)
|
static void |
intToLittleEndian(int[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
|
static void |
intToLittleEndian(int n,
byte[] bs,
int off)
|
static int |
littleEndianToInt_High(byte[] bs,
int off,
int len)
|
static int |
littleEndianToInt_Low(byte[] bs,
int off,
int len)
|
static int |
littleEndianToInt(byte[] bs,
int off)
|
static int[] |
littleEndianToInt(byte[] bs,
int off,
int count)
|
static void |
littleEndianToInt(byte[] bs,
int off,
int[] ns)
|
static void |
littleEndianToInt(byte[] bs,
int bOff,
int[] ns,
int nOff,
int count)
|
static int |
littleEndianToInt24(byte[] bs,
int off)
|
static long |
littleEndianToLong_High(byte[] bs,
int off,
int len)
|
static long |
littleEndianToLong_Low(byte[] bs,
int off,
int len)
|
static long |
littleEndianToLong(byte[] bs,
int off)
|
static long[] |
littleEndianToLong(byte[] bs,
int off,
int count)
|
static void |
littleEndianToLong(byte[] bs,
int off,
long[] ns)
|
static void |
littleEndianToLong(byte[] bs,
int bsOff,
long[] ns,
int nsOff,
int nsLen)
|
static short |
littleEndianToShort(byte[] bs,
int off)
|
static short[] |
littleEndianToShort(byte[] bs,
int off,
int count)
|
static void |
littleEndianToShort(byte[] bs,
int bOff,
short[] ns)
|
static void |
littleEndianToShort(byte[] bs,
int bOff,
short[] ns,
int nOff,
int count)
|
static void |
longToBigEndian_High(long n,
byte[] bs,
int off,
int len)
Writes the most significant len bytes of n to bs at off, in big-endian order: a len of 3 writes the three bytes longToBigEndian(long, byte[], int) would put at bs[off] to
bs[off + 2], and drops the other five.
|
static void |
longToBigEndian_Low(long n,
byte[] bs,
int off,
int len)
Writes the least significant len bytes of n to bs at off, in big-endian order: a len of 3 writes the three bytes longToBigEndian(long, byte[], int) would put at bs[off + 5] to
bs[off + 7], and drops the other five.
|
static byte[] |
longToBigEndian(long n)
|
static byte[] |
longToBigEndian(long[] ns)
|
static void |
longToBigEndian(long[] ns,
byte[] bs,
int off)
|
static void |
longToBigEndian(long[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
|
static void |
longToBigEndian(long n,
byte[] bs,
int off)
|
static void |
longToLittleEndian_High(long n,
byte[] bs,
int off,
int len)
|
static void |
longToLittleEndian_Low(long n,
byte[] bs,
int off,
int len)
|
static byte[] |
longToLittleEndian(long n)
|
static byte[] |
longToLittleEndian(long[] ns)
|
static void |
longToLittleEndian(long[] ns,
byte[] bs,
int off)
|
static void |
longToLittleEndian(long[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
|
static void |
longToLittleEndian(long n,
byte[] bs,
int off)
|
static byte[] |
shortToBigEndian(short n)
|
static void |
shortToBigEndian(short n,
byte[] bs,
int off)
|
static byte[] |
shortToLittleEndian(short n)
|
static byte[] |
shortToLittleEndian(short[] ns)
|
static void |
shortToLittleEndian(short[] ns,
byte[] bs,
int bsOff)
|
static void |
shortToLittleEndian(short[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
|
static void |
shortToLittleEndian(short n,
byte[] bs,
int off)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Pack()
| Method Detail |
public static short bigEndianToShort(byte[] bs,
int off)
public static int bigEndianToInt(byte[] bs,
int off)
public static void bigEndianToInt(byte[] bs,
int off,
int[] ns)
public static void bigEndianToInt(byte[] bs,
int off,
int[] ns,
int nsOff,
int nsLen)
public static int bigEndianToInt_High(byte[] bs,
int off,
int len)
public static int bigEndianToInt_Low(byte[] bs,
int off,
int len)
public static byte[] intToBigEndian(int n)
public static void intToBigEndian(int n,
byte[] bs)
public static void intToBigEndian(int n,
byte[] bs,
int off)
public static byte[] intToBigEndian(int[] ns)
public static void intToBigEndian(int[] ns,
byte[] bs,
int off)
public static void intToBigEndian(int[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
public static void intToBigEndian_High(int n,
byte[] bs,
int off,
int len)
public static void intToBigEndian_Low(int n,
byte[] bs,
int off,
int len)
public static long bigEndianToLong(byte[] bs,
int off)
public static void bigEndianToLong(byte[] bs,
int off,
long[] ns)
public static void bigEndianToLong(byte[] bs,
int bsOff,
long[] ns,
int nsOff,
int nsLen)
public static long bigEndianToLong_High(byte[] bs,
int off,
int len)
public static long bigEndianToLong_Low(byte[] bs,
int off,
int len)
bigEndianToLong(byte[], int) would return for those three bytes preceded by five
zero ones.
It is the read side of longToBigEndian_Low(long, byte[], int, int) and carries the
same unenforced 1..8 bound, for a related reason: the first byte is read ahead of the loop,
so a len of 0 reads one byte anyway and returns it rather than returning zero,
and a len above 8 goes on shifting and so yields the last eight bytes read
rather than the first. The callers here are the XMSS ones reading back RFC 8391's
toByte(x, y): the index field of a stored private key, in , which
is the one codec both families' keys are decoded through, and the index field of an XMSS^MT
signature in . Each passes the constant 4 or ceil(h/8) for a height
its parameter class holds to 2..62, so both are inside the bound already, as are the reads
the package's own tests make with the same two lengths.
public static byte[] longToBigEndian(long n)
public static void longToBigEndian(long n,
byte[] bs,
int off)
public static byte[] longToBigEndian(long[] ns)
public static void longToBigEndian(long[] ns,
byte[] bs,
int off)
public static void longToBigEndian(long[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
public static void longToBigEndian_High(long n,
byte[] bs,
int off,
int len)
longToBigEndian(long, byte[], int) would put at bs[off] to
bs[off + 2], and drops the other five.
It is the write side of bigEndianToLong_High(byte[], int, int). The pair is shaped
for the short final block of a big-endian sponge, where the bytes the block has occupy the
top of the rate word and the remainder of that word is padding - so both conversions work
against the high end of the word rather than the low one. The callers are the Ascon v1.2
classes (AsconEngine,
AsconDigest,
AsconXof), all three now deprecated: final Ascon is
little-endian and goes through longToLittleEndian_Low(long, byte[], int, int).
len must be 1..8, and nothing enforces it. The first store sits ahead of the loop, so a len of 0 writes one byte anyway - n's top one - and throws ArrayIndexOutOfBoundsException where the array has no room for it; and because Java takes a shift distance mod 64, a len above 8 wraps round and repeats n's bytes rather than running to zero. Callers whose length can reach 0 guard the call themselves.
public static void longToBigEndian_Low(long n,
byte[] bs,
int off,
int len)
longToBigEndian(long, byte[], int) would put at bs[off + 5] to
bs[off + 7], and drops the other five.
It is longToBigEndian_High(long, byte[], int, int) applied to n
shifted up past the bytes being dropped, the write side of
bigEndianToLong_Low(byte[], int, int), and it carries the same unenforced 1..8
bound for the same reason. It is the low-end counterpart of the _High pair the Ascon v1.2
classes use; its callers here are the XMSS ones building RFC 8391's toByte(x, y), which pads
left of the eight bytes rather than absorbing into the top of a word, so it wants the low
end. Two of the five pass a length that is not a constant, and both are inside the bound
because they say so: , whose size is its caller's argument,
and 's H_msg key, whose length is the security parameter, each taking a
min() with 8. The other three are inside it by construction - the index field of a stored
private key in and of an XMSS^MT signature in
, both 4 or ceil(h/8), and 's PRF index at the
constant 8.
public static short littleEndianToShort(byte[] bs,
int off)
public static void littleEndianToShort(byte[] bs,
int bOff,
short[] ns)
public static void littleEndianToShort(byte[] bs,
int bOff,
short[] ns,
int nOff,
int count)
public static short[] littleEndianToShort(byte[] bs,
int off,
int count)
public static int littleEndianToInt24(byte[] bs,
int off)
public static int littleEndianToInt(byte[] bs,
int off)
public static int littleEndianToInt_High(byte[] bs,
int off,
int len)
public static int littleEndianToInt_Low(byte[] bs,
int off,
int len)
public static void littleEndianToInt(byte[] bs,
int off,
int[] ns)
public static void littleEndianToInt(byte[] bs,
int bOff,
int[] ns,
int nOff,
int count)
public static int[] littleEndianToInt(byte[] bs,
int off,
int count)
public static byte[] shortToLittleEndian(short n)
public static void shortToLittleEndian(short n,
byte[] bs,
int off)
public static void shortToLittleEndian(short[] ns,
byte[] bs,
int bsOff)
public static void shortToLittleEndian(short[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
public static byte[] shortToLittleEndian(short[] ns)
public static byte[] shortToBigEndian(short n)
public static void shortToBigEndian(short n,
byte[] bs,
int off)
public static byte[] intToLittleEndian(int n)
public static void intToLittleEndian(int n,
byte[] bs,
int off)
public static byte[] intToLittleEndian(int[] ns)
public static void intToLittleEndian(int[] ns,
byte[] bs,
int off)
public static void intToLittleEndian(int[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
public static void intToLittleEndian_High(int n,
byte[] bs,
int off,
int len)
public static void intToLittleEndian_Low(int n,
byte[] bs,
int off,
int len)
public static long littleEndianToLong(byte[] bs,
int off)
public static void littleEndianToLong(byte[] bs,
int off,
long[] ns)
public static void littleEndianToLong(byte[] bs,
int bsOff,
long[] ns,
int nsOff,
int nsLen)
public static long[] littleEndianToLong(byte[] bs,
int off,
int count)
public static long littleEndianToLong_High(byte[] bs,
int off,
int len)
public static long littleEndianToLong_Low(byte[] bs,
int off,
int len)
public static byte[] longToLittleEndian(long n)
public static void longToLittleEndian(long n,
byte[] bs,
int off)
public static byte[] longToLittleEndian(long[] ns)
public static void longToLittleEndian(long[] ns,
byte[] bs,
int off)
public static void longToLittleEndian(long[] ns,
int nsOff,
int nsLen,
byte[] bs,
int bsOff)
public static void longToLittleEndian_High(long n,
byte[] bs,
int off,
int len)
public static void longToLittleEndian_Low(long n,
byte[] bs,
int off,
int len)
|
Bouncy Castle Cryptography Library 1.86 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||