iaik.me.utils
Class CryptoUtils

java.lang.Object
  |
  +--iaik.me.utils.CryptoUtils

public class CryptoUtils
extends Object


Method Summary
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 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 void spreadIntsToBytes(int[] inInts, int inOff, byte[] outBytes, int outOff, int intLen)
           
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)
           
static void spreadShortsToBytesLE(int[] inShorts, int inOff, byte[] outBytes, int outOff, int shortLen)
          Spreads shorts ints into bytes in little endian bytes ordering.
static void squashBytesToInts(byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen)
           
static void squashBytesToIntsLE(byte[] inBytes, int inOff, int[] outInts, int outOff, int intLen)
           
static void squashBytesToShortsBE(byte[] inBytes, int inOff, int[] outShorts, int outOff, int shortLen)
           
static void squashBytesToShortsLE(byte[] inBytes, int inOff, int[] outShorts, int outOff, int shortLen)
           
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

zeroBlock

public static void zeroBlock(byte[] block,
                             int off,
                             int len)
Fills the specified sub-array of the given byte array with zeros.

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);
 
Parameters:
block - the byte array of which some bytes have to be set to zero
off - the offset indicating the start position within the byte array; the following len bytes are set to zero
len - the number of bytes to be set to zero, starting at off

zeroBlock

public static void zeroBlock(int[] block,
                             int off,
                             int len)
Fill part of an integer array with zeros.
Parameters:
int - array
offset - within the block
length - how far to fill with zeros

zeroBlock

public static void zeroBlock(byte[] block)
Fills the given byte array with zeros.
Parameters:
block - the byte array to be filled with zeros

zeroBlock

public static void zeroBlock(int[] block)
Fill an integer array with zeros.
Parameters:
block - the int array to be filled with zeros

copyBlock

public 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.

Beginning at the specified srcOff position, len bytes of the source array are copied to the given destination array, starting at dstOff.

Parameters:
src - the source byte array
srcOff - the offset indicating the start position within the first byte array; the following len bytes will be copied to the destination array
dst - the destination array to which to copy the bytes
dstOff - the offset indicating the start position within the destination byte array, to which the bytes shall be copied
len - the number of bytes to be copied

copyBlock

public static void copyBlock(byte[] src,
                             byte[] dst)
Copies one byte block to another.
Parameters:
src - the source byte array
dst - the destination array to which to copy the bytes

copyBlock

public 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.

Beginning at the specified srcOff position, len ints of the source array are copied to the given destination array, starting at dstOff.

Parameters:
src - the source int array
srcOff - the offset indicating the start position within the first int array; the following len ints will be copied to the destination array
dst - the destination array to which to copy the ints
dstOff - the offset indicating the start position within the destination int array, to which the ints shall be copied
len - the number of ints to be copied

copyBlock

public static void copyBlock(int[] src,
                             int[] dst)
Copies one int block to another.
Parameters:
src - the source int array
dst - the destination array to which to copy the ints

equalsBlock

public 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.
Parameters:
a - the first byte array
aOff - 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 array
b - the second byte array
bOff - 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 array
len - the number of bytes to be compared
Returns:
true if the two sub-arrays have the same contents, false if not

equalsBlock

public static boolean equalsBlock(byte[] a,
                                  byte[] b)
Checks two byte blocks for equality.
Parameters:
a - the first byte array to be compared with the second byte array
b - the second byte array to be compared with the first byte array
Returns:
true if the two blocks have the same contents, false if not

squashBytesToInts

public static void squashBytesToInts(byte[] inBytes,
                                     int inOff,
                                     int[] outInts,
                                     int outOff,
                                     int intLen)
Parameters:
inBytes -  
inOff -  
outInts -  
outOff -  
intLen -  

spreadIntsToBytes

public static void spreadIntsToBytes(int[] inInts,
                                     int inOff,
                                     byte[] outBytes,
                                     int outOff,
                                     int intLen)

squashBytesToIntsLE

public static void squashBytesToIntsLE(byte[] inBytes,
                                       int inOff,
                                       int[] outInts,
                                       int outOff,
                                       int intLen)

spreadIntsToBytesLE

public static void spreadIntsToBytesLE(int[] inInts,
                                       int inOff,
                                       byte[] outBytes,
                                       int outOff,
                                       int intLen)
Spreads ints into bytes in little endian bytes ordering. That means least significant byte first, most significant byte last.
See Also:
spreadIntsToBytes(int[], int, byte[], int, int)

squashBytesToShortsBE

public static void squashBytesToShortsBE(byte[] inBytes,
                                         int inOff,
                                         int[] outShorts,
                                         int outOff,
                                         int shortLen)

spreadShortsToBytesBE

public static void spreadShortsToBytesBE(int[] inShorts,
                                         int inOff,
                                         byte[] outBytes,
                                         int outOff,
                                         int shortLen)

squashBytesToShortsLE

public static void squashBytesToShortsLE(byte[] inBytes,
                                         int inOff,
                                         int[] outShorts,
                                         int outOff,
                                         int shortLen)

spreadShortsToBytesLE

public static void spreadShortsToBytesLE(int[] inShorts,
                                         int inOff,
                                         byte[] outBytes,
                                         int outOff,
                                         int shortLen)
Spreads shorts ints into bytes in little endian bytes ordering. That means least significant byte first, most significant byte last.
See Also:
spreadIntsToBytes(int[], int, byte[], int, int)

This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note).

IAIK-JCE ME 3.04, (c) 2002 IAIK, (c) 2003 to 2006 Stiftung SIC