|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.utils.CryptoUtils
Some useful cryptography utilities.
Method Summary | |
static int |
compareBlock(byte[] a,
byte[] b)
Checks two byte blocks for equality. |
static int |
compareBlock(byte[] a,
int aOff,
byte[] b,
int bOff,
int len)
Check the specified sub-sequences of the given byte arrays for equality. |
static byte[] |
concatenate(byte[] a1,
byte[] a2)
Concatenate the given byte arrays. |
static void |
copyBlock(byte[] src,
byte[] dst)
Copies one byte block to another. |
static void |
copyBlock(byte[] src,
int srcOff,
byte[] dst,
int dstOff,
int len)
Copies the specified byte sequence of the given source array to the specified destination array. |
static void |
copyBlock(int[] src,
int[] dst)
Copies one int block to another. |
static void |
copyBlock(int[] src,
int srcOff,
int[] dst,
int dstOff,
int len)
Copies the specified int sequence of the given source array to the specified destination array. |
static void |
copyBlock(long[] src,
int srcOff,
long[] dst,
int dstOff,
int len)
Copies the specified long sequence of the given source array to the specified destination array. |
static void |
copyBlock(long[] src,
long[] dst)
Copies one long block to another. |
static boolean |
equalsBlock(byte[] a,
byte[] b)
Checks two byte blocks for equality. |
static boolean |
equalsBlock(byte[] a,
int aOff,
byte[] b,
int bOff,
int len)
Check the specified sub-sequences of the given byte arrays for equality. |
static int[] |
extGcd(int a,
int b)
Deprecated. use NumberTheory.extGcd() instead |
static void |
fillBlock(byte[] block,
byte b)
Fills a block with a given byte. |
static void |
fillBlock(byte[] block,
int blockOff,
byte b,
int len)
Fills the specified subsequence of the given byte array with the given byte. |
static int |
gcd(int a,
int b)
Deprecated. use NumberTheory.gcd() instead |
static BigInteger |
getStrongPrime(int x,
Random random)
Deprecated. use NumberTheory.getStrongPrime() instead |
static byte[] |
increment(byte[] b)
Increment the byte array by one. |
static byte[] |
incrementExtended(byte[] number)
This method increments the given byte array and return the result. |
static void |
randomBlock(byte[] block)
Fills the given byte array with random bytes. |
static void |
randomBlock(byte[] block,
int off,
int len)
Fills the specified sub-array of the given byte array with random bytes. |
static byte[] |
resizeArray(byte[] array,
int len)
Resizes a byte array to the specified length. |
static void |
reverseArray(byte[] array,
int off,
int len)
Reverses the order of the bytes in the given array. |
static void |
spreadIntsToBytes(int[] inInts,
int inOff,
byte[] outBytes,
int outOff,
int intLen)
Spreads ints into bytes. |
static void |
spreadIntsToBytesLE(int[] inInts,
int inOff,
byte[] outBytes,
int outOff,
int intLen)
Spreads ints into bytes in little endian bytes ordering. |
static void |
spreadShortsToBytesBE(int[] inShorts,
int inOff,
byte[] outBytes,
int outOff,
int shortLen)
Spreads shorts into bytes in big-endian. |
static void |
spreadShortsToBytesLE(int[] inShorts,
int inOff,
byte[] outBytes,
int outOff,
int shortLen)
Spreads shorts into bytes in little-endian. |
static void |
squashBytesToInts(byte[] inBytes,
int inOff,
int[] outInts,
int outOff,
int intLen)
Squashes bytes down to ints. |
static void |
squashBytesToIntsLE(byte[] inBytes,
int inOff,
int[] outInts,
int outOff,
int intLen)
Squashes bytes down to ints assuming little endian byte ordering. |
static int |
squashBytesToIntsLEPadZero(byte[] inBytes,
int inOff,
int[] outInts,
int outOff,
int byteLen)
|
static void |
squashBytesToIntsPadZero(byte[] inBytes,
int inOff,
int[] outInts,
int outOff,
int byteLen)
|
static void |
squashBytesToShortsBE(byte[] inBytes,
int inOff,
int[] outShorts,
int outOff,
int shortLen)
Squashes bytes down to shorts in big-endian. |
static void |
squashBytesToShortsLE(byte[] inBytes,
int inOff,
int[] outShorts,
int outOff,
int shortLen)
Squashes bytes down to shorts in little-endian. |
static void |
xorBlock(byte[] a,
byte[] b,
byte[] dst)
XORs two byte blocks. |
static void |
xorBlock(byte[] a,
int aOff,
byte[] b,
int bOff,
byte[] dst,
int dstOff,
int len)
XORs the specified sub-arrays of the given byte blocks. |
static void |
zeroBlock(byte[] block)
Fills the given byte array with zeros. |
static void |
zeroBlock(byte[] block,
int off,
int len)
Fills the specified sub-array of the given byte array with zeros. |
static void |
zeroBlock(int[] block)
Fill an integer array with zeros. |
static void |
zeroBlock(int[] block,
int off,
int len)
Fill part of an integer array with zeros. |
static void |
zeroBlock(long[] block)
Fill a long array with zeros. |
static void |
zeroBlock(long[] block,
int off,
int len)
Fill part of a long array with zeros. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void zeroBlock(byte[] block, int off, int len)
Starting at the given off
position, len
bytes
of the given array are set to zero. To, for instance, set three bytes
to zero, starting at position 2, use:
byte[] block = ...; CryptoUtils.zeroBlock(block, 2, 3);
block
- the byte array of which some bytes have to be set to zerooff
- the offset indicating the start position within the byte array; the
following len
bytes are set to zerolen
- the number of bytes to be set to zero, starting at off
public static void zeroBlock(int[] block, int off, int len)
public static void zeroBlock(long[] block, int off, int len)
public static void zeroBlock(byte[] block)
block
- the byte array to be filled with zerospublic static void zeroBlock(int[] block)
public static void zeroBlock(long[] block)
public static void randomBlock(byte[] block, int off, int len)
This method uses Math.random()
for generating random numbers.
Starting at the given off
position, len
bytes
of the given array are randomly generated. To, for instance, set ten bytes
at random, starting at position 2, use:
byte[] block = new byte[20]; CryptoUtils.randomBlock(block, 2, 10);
block
- the byte array of which some bytes shall be randomly generatedoff
- the offset indicating the start position within the byte array; the
following len
bytes will be randomly generatedlen
- the number of bytes to be randomly generated, starting at off
public static void randomBlock(byte[] block)
This method uses Math.random()
for generating random numbers.
block
- the byte array to be filled with random bytespublic static void xorBlock(byte[] a, int aOff, byte[] b, int bOff, byte[] dst, int dstOff, int len)
Beginning at aOff
, len
bytes of the given a
array are XORed with the corresponding bytes of the b
array,
beginning at position bOff
. The result is written to the destination
byte array (dst
), starting at position dstOff
, e.g.:
byte[] a = ...; byte[] b = ...; byte[] dst = new byte[8]; CryptoUtils.xorBlock(a, 0, b, 0, dst, 0, 8);
a
- the first byte array supplying bytes to be XORedaOff
- the offset indicating the start position within the first byte array; the
following len
bytes will be XORed with the corresponding number
of bytes of the second byte arrayb
- the second byte array supplying bytes to be XORedbOff
- the offset indicating the start position within the second byte array; the
following len
bytes will be XORed with the corresponding number
of bytes of the first byte arraydst
- the destination byte array to which the result of the XOR operation is writtendstOff
- the offset indicating the start position within the destination byte
array, to which the result of the XOR operation is writtenlen
- the number of bytes to be XORedpublic static void xorBlock(byte[] a, byte[] b, byte[] dst)
Every byte of the given a
array is XORed with the corresponding byte
of the b
array. The result is written to the specified destination
array, e.g.:
byte[] a = ...; byte[] b = ...; byte[] dst = new byte[8]; CryptoUtils.xorBlock(a, b, dst);
a
- the first byte array to be XORedb
- the second byte array to be XOReddst
- the destination byte array to which the result is writtenpublic static void copyBlock(byte[] src, int srcOff, byte[] dst, int dstOff, int len)
Beginning at the specified srcOff
position, len
bytes
of the source array are copied to the given destination array, starting at
dstOff
.
src
- the source byte arraysrcOff
- the offset indicating the start position within the first byte array; the
following len
bytes will be copied to the destination arraydst
- the destination array to which to copy the bytesdstOff
- the offset indicating the start position within the destination byte
array, to which the bytes shall be copiedlen
- the number of bytes to be copiedpublic static void copyBlock(byte[] src, byte[] dst)
src
- the source byte arraydst
- the destination array to which to copy the bytespublic static void copyBlock(int[] src, int srcOff, int[] dst, int dstOff, int len)
Beginning at the specified srcOff
position, len
ints
of the source array are copied to the given destination array, starting at
dstOff
.
src
- the source int arraysrcOff
- the offset indicating the start position within the first int array; the
following len
ints will be copied to the destination arraydst
- the destination array to which to copy the intsdstOff
- the offset indicating the start position within the destination int
array, to which the ints shall be copiedlen
- the number of ints to be copiedpublic static void copyBlock(int[] src, int[] dst)
src
- the source int arraydst
- the destination array to which to copy the intspublic static void copyBlock(long[] src, int srcOff, long[] dst, int dstOff, int len)
Beginning at the specified srcOff
position, len
longs
of the source array are copied to the given destination array, starting at
dstOff
.
src
- the source int arraysrcOff
- the offset indicating the start position within the first long array; the
following len
ints will be copied to the destination arraydst
- the destination array to which to copy the longsdstOff
- the offset indicating the start position within the destination long
array, to which the longs shall be copiedlen
- the number of longs to be copiedpublic static void copyBlock(long[] src, long[] dst)
src
- the source int arraydst
- the destination array to which to copy the intspublic static boolean equalsBlock(byte[] a, int aOff, byte[] b, int bOff, int len)
a
- the first byte arrayaOff
- the offset indicating the start position within the first byte array; the
following len
bytes are compared with the corresponding number
of bytes of the second byte arrayb
- the second byte arraybOff
- the offset indicating the start position within the second byte array; the
following len
bytes are compared with the corresponding number
of bytes of the first byte arraylen
- the number of bytes to be comparedtrue
if the two sub-arrays have the same contents,
false
if notpublic static boolean equalsBlock(byte[] a, byte[] b)
a
- the first byte array to be compared with the second byte arrayb
- the second byte array to be compared with the first byte arraytrue
if the two blocks have the same contents,
false
if notpublic static int compareBlock(byte[] a, int aOff, byte[] b, int bOff, int len)
a
- the first byte arrayaOff
- the offset indicating the start position within the first byte array; the
following len
bytes are compared with the corresponding number
of bytes of the second byte arrayb
- the second byte arraybOff
- the offset indicating the start position within the second byte array; the
following len
bytes are compared with the corresponding number
of bytes of the first byte arraylen
- the number of bytes to be compared-1
if the two sub-arrays have the same contents,
the position of the first difference otherwiespublic static int compareBlock(byte[] a, byte[] b)
a
- the first byte array to be compared with the second byte arrayb
- the second byte array to be compared with the first byte array-1
if the two blocks have the same contents,
the position of the first difference otherwise (if the two
arrays differ in their length only the output of this method
will be the length of the smaller array)public static void fillBlock(byte[] block, int blockOff, byte b, int len)
After calling this method all bytes of the given subarray will have the same value, e.g.
will set block[1] ... block[3] tobyte[] block = ...; CryptoUtils.fillBlock(block, 2, (byte)0xBA, 3);
0xBA
.block
- the byte array to which the specified byte shall be written repeatedlyblockOff
- the offset indicating the start position within the given byte
array; the following len
bytes will be set to b
b
- the byte value to be written repeatedly to the specified sub arraylen
- the number of bytes that have to be set to b
, beginning at
len
public static void fillBlock(byte[] block, byte b)
After calling this method all the bytes of the given byte array will have the same value.
block
- the byte array that shall be filled with the given byteb
- the byte value for filling the arraypublic static void squashBytesToInts(byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen)
In Java, the primitive data type byte internally is represented as 8 bit
signed number, and int denotes a signed 32 bit number.
This method transforms the bytes of the given inBytes
array into
proper int values for the specified outInts
int array. The bytes
are grouped in sequences each of it consisting of 4 bytes (32 bits) to compute
the corresponding int values. So, if the given inBytes
array will
consist of n
bytes (n = 4 * m;
m >= 1
), the following "transformation" will take place
(when both inOff
and outOff
, indicating the start
position from where to read the bytes from the inBytes
array
and the destination position where to write the resulting int values to the
outInts
array, are set to 0
):
The last parameter valueinBytes[0...3] goes to outInts[0] inBytes[4...7] goes to outInts[1] ... inBytes[n-4...n-1] goes to outInts[n/4-1]
intLen
denotes the number of the resulting
int values. To squash, for instance, a sequence of 8 bytes, set intLen
to 2
indicating that two int values will result from the transforming
computations:
byte[] in = new byte[8]; int[] out = new int[2]; ... CryptoUtils.squashBytesToInts(in, 0, out, 0, 2);
inBytes
- the byte array supplying the bytes to be squashed to intsinOff
- the offset indicating the start position within the input byte array; the
following 4 * intLen
bytes will be squashed to intsoutInts
- the int array to which the resulting int values are written, starting
at position outOff
outOff
- the offset indicating the start position within the destination int
array, to which the resulting int values are writtenintLen
- the number of int values that will result from the "bytes-to-ints"
transformationpublic static void squashBytesToIntsPadZero(byte[] inBytes, int inOff, int[] outInts, int outOff, int byteLen)
public static int squashBytesToIntsLEPadZero(byte[] inBytes, int inOff, int[] outInts, int outOff, int byteLen)
public static void spreadIntsToBytes(int[] inInts, int inOff, byte[] outBytes, int outOff, int intLen)
In Java, the primitive data type byte internally is represented as 8 bit
signed number, and int denotes a signed 32 bit number.
This method transforms the int values of the given inInts
array into
proper byte values for the specified outBytes
array. The transforming
computation will yield four bytes for each int value of the specified sequence of
the input int array. So, if the given inInts
array will
consist of n
ints, the following "transformation" will take place
(when both inOff
and outOff
, indicating the start
position from where to read the int values from the inInts
array
and the destination position where to write the resulting byte values to the
outBytes
array, are set to 0
):
The last parameter valueinInts[0] goes to outBytes[0...3] inInts[1] goes to outBytes[4...7] ... inInts[n-1] goes to outInts[n*4-4...n*4-1]
intLen
denotes the size of the input int
array. To spread, for instance, a sequence of 2 ints, set intLen
to 2
:
int[] in = new int[2]; byte[] out = new byte[8]; ... CryptoUtils.squashBytesToInts(in, 0, out, 0, 2);
inInts
- the int array supplying the integers to be spread to bytesinOff
- the offset indicating the start position within the input int array; the
following intLen
integers will be spread to bytesoutBytes
- the byte array to which the resulting byte values are written, starting
at position outOff
outOff
- the offset indicating the start position within the destination byte
array, to which the resulting byte values are writtenintLen
- the number of int values that have to spread to bytespublic static void squashBytesToIntsLE(byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen)
squashBytesToInts(byte[], int, int[], int, int)
public static void spreadIntsToBytesLE(int[] inInts, int inOff, byte[] outBytes, int outOff, int intLen)
spreadIntsToBytes(int[], int, byte[], int, int)
public static void squashBytesToShortsBE(byte[] inBytes, int inOff, int[] outShorts, int outOff, int shortLen)
In Java, the primitive data type byte internally is represented as 8 bit
signed number, and short denotes a signed 16 bit number.
This method transforms the bytes of the given inBytes
array into
proper short values for the specified outShorts
int array. The bytes
are grouped in sequences each of it consisting of 2 bytes (16 bits) to compute
the corresponding short values. So, if the given inBytes
array will
consist of n
bytes (n = 2 * m;
m >= 1
), the following "transformation" will take place
(when both inOff
and outOff
, indicating the start
position from where to read the bytes from the inBytes
array
and the destination position where to write the resulting short values to the
outShorts
array, are set to 0
):
The last parameter valueinBytes[0...1] goes to outShorts[0] inBytes[2...3] goes to outShorts[1] ... inBytes[n-2...n-1] goes to outShorts[n/2-1]
shortLen
denotes the number of the resulting
short values. To squash, for instance, a sequence of 8 bytes, set shortLen
to 4
indicating that four short values will result from the transforming
computations (note that outShorts
is decleared as an int[] array; only
the 16 low bits are significant):
Each single "two-byte-to-one-short" transformation is performed according to the big-endian scheme where the leftmost byte (with a lower address) is most significant, mapping inBytes[i] to the lower byte of the corresponding short value and inBytes[i+1] to the higher byte, e.g.:byte[] in = new byte[8]; int[] out = new int[4]; ... CryptoUtils.squashBytesToShortsBE(in, 0, out, 0, 4);
two bytes: 00000000 00000001 {00, 01} result in one short: 00000000 00000001 {1}
inBytes
- the byte array supplying the bytes to be squashed to shortsinOff
- the offset indicating the start position within the input byte array; the
following 2 * shortLen
bytes will be squashed to shortsoutShorts
- the int array to which the resulting short values are written, starting
at position outOff
outOff
- the offset indicating the start position within the destination int (short)
array, to which the resulting short values are writtenshortLen
- the number of short values that will result from the "bytes-to-shorts"
transformationpublic static void squashBytesToShortsLE(byte[] inBytes, int inOff, int[] outShorts, int outOff, int shortLen)
In Java, the primitive data type byte internally is represented as 8 bit
signed number, and short denotes a signed 16 bit number.
This method transforms the bytes of the given inBytes
array into
proper short values for the specified outShorts
int array. The bytes
are grouped in sequences each of it consisting of 2 bytes (16 bits) to compute
the corresponding short values. So, if the given inBytes
array will
consist of n
bytes (n = 2 * m;
m >= 1
), the following "transformation" will take place
(when both inOff
and outOff
, indicating the start
position from where to read the bytes from the inBytes
array
and the destination position where to write the resulting short values to the
outShorts
array, are set to 0
):
The last parameter valueinBytes[0...1] goes to outShorts[0] inBytes[2...3] goes to outShorts[1] ... inBytes[n-2...n-1] goes to outShorts[n/2-1]
shortLen
denotes the number of the resulting
short values. To squash, for instance, a sequence of 8 bytes, set shortLen
to 4
indicating that four short values will result from the transforming
computations (note that outShorts
is decleared as an int[] array; only
the 16 low bits are significant):
Each single "two-byte-to-one-short" transformation is performed according to the little-endian scheme where the rightmost byte (with a higher address) is most significant, mapping inBytes[i] to the higher byte of the corresponding short value and inBytes[i+1] to the lower byte, e.g.:byte[] in = new byte[8]; int[] out = new int[4]; ... CryptoUtils.squashBytesToShortsBE(in, 0, out, 0, 4);
two bytes: 00000000 00000001 {00, 01} result in one short: 00000001 00000000 {256}
inBytes
- the byte array supplying the bytes to be squashed to shortsinOff
- the offset indicating the start position within the input byte array; the
following 2 * shortLen
bytes will be squashed to shortsoutShorts
- the int array to which the resulting short values are written, starting
at position outOff
outOff
- the offset indicating the start position within the destination int (short)
array, to which the resulting short values are writtenshortLen
- the number of short values that will result from the "bytes-to-shorts"
transformationpublic static void spreadShortsToBytesBE(int[] inShorts, int inOff, byte[] outBytes, int outOff, int shortLen)
In Java, the primitive data type byte internally is represented as 8 bit
signed number, and short denotes a signed 16 bit number.
This method transforms the short values of the given inShorts
array into
proper byte values for the specified outBytes
array. The transforming
computation will yield two bytes for each short value of the specified sequence of
the input short array. So, if the given inShorts
array will
consist of n
shorts, the following "transformation" will take place
(when both inOff
and outOff
, indicating the start
position from where to read the short values from the inShorts
array
and the destination position where to write the resulting byte values to the
outBytes
array, are set to 0
):
The last parameter valueinShorts[0] goes to outBytes[0...1] inShorts[1] goes to outBytes[2...3] ... inShorts[n-1] goes to outInts[n*2-2...n*2-1]
shortLen
denotes the size of the input int (short)
array. To spread, for instance, a sequence of 4 shorts, set shortLen
to 4
(note that inShorts
is decleared as an int[] array; only
the 16 low bits are significant):
Each single "one-short-to-two-bytes" transformation is performed according to the big-endian scheme where the leftmost byte (with a lower address) is most significant, mapping the lower byte of an input short value to the correspondingint[] in = new int[4]; byte[] out = new byte[8]; ... CryptoUtils.squashBytesToInts(in, 0, out, 0, 4);
outBytes[i]
byte and the higher byte to outBytes[i+1]
, e.g.:
one short: 00000000 00000001 {1} results in two bytes: 00000000 00000001 {00, 01}
inShorts
- the int array supplying the shorts to be spread to bytesinOff
- the offset indicating the start position within the input int (short)
array; the following shortLen
shorts will be spread to bytesoutBytes
- the byte array to which the resulting byte values are written, starting
at position outOff
outOff
- the offset indicating the start position within the destination byte
array, to which the resulting byte values are writtenshortLen
- the number of short values that have to spread to bytespublic static void spreadShortsToBytesLE(int[] inShorts, int inOff, byte[] outBytes, int outOff, int shortLen)
In Java, the primitive data type byte internally is represented as 8 bit
signed number, and short denotes a signed 16 bit number.
This method transforms the short values of the given inShorts
array into
proper byte values for the specified outBytes
array. The transforming
computation will yield two bytes for each short value of the specified sequence of
the input short array. So, if the given inShorts
array will
consist of n
shorts, the following "transformation" will take place
(when both inOff
and outOff
, indicating the start
position from where to read the short values from the inShorts
array
and the destination position where to write the resulting byte values to the
outBytes
array, are set to 0
):
The last parameter valueinShorts[0] goes to outBytes[0...1] inShorts[1] goes to outBytes[2...3] ... inShorts[n-1] goes to outInts[n*2-2...n*2-1]
shortLen
denotes the size of the input int (short)
array. To spread, for instance, a sequence of 4 shorts, set shortLen
to 4
(note that inShorts
is decleared as an int[] array; only
the 16 low bits are significant):
Each single "one-short-to-two-bytes" transformation is performed according to the little-endian scheme where the rightmost byte (with a higher address) is most significant, mapping the lower byte of an input short value to the correspondingint[] in = new int[4]; byte[] out = new byte[8]; ... CryptoUtils.squashBytesToInts(in, 0, out, 0, 4);
outBytes[i]
byte and the higher byte to outBytes[i-1]
, e.g.:
one short: 00000001 00000000 {256} results in two bytes: 00000000 00000001 {00, 01}
inShorts
- the int array supplying the shorts to be spread to bytesinOff
- the offset indicating the start position within the input int (short)
array; the following shortLen
shorts will be spread to bytesoutBytes
- the byte array to which the resulting byte values are written, starting
at position outOff
outOff
- the offset indicating the start position within the destination byte
array, to which the resulting byte values are writtenshortLen
- the number of short values that have to spread to bytespublic static byte[] resizeArray(byte[] array, int len)
array
- the array to resizelen
- the new length of the arraypublic static void reverseArray(byte[] array, int off, int len)
array
- the array to be "reversed"off
- the start offset into the arraylen
- the number of bytes to be involved in the reversing operation,
starting at offpublic static byte[] increment(byte[] b)
public static byte[] incrementExtended(byte[] number)
number
- The given number to increment.public static byte[] concatenate(byte[] a1, byte[] a2)
a1
- The first part.a2
- The second part.public static BigInteger getStrongPrime(int x, Random random)
public static int gcd(int a, int b)
public static int[] extGcd(int a, int b)
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |