IAIK ECC
version 2.18

iaik.security.ecc.util
Class Utils

java.lang.Object
  extended byiaik.security.ecc.util.Utils

public class Utils
extends java.lang.Object

A collection of some useful functions.


Constructor Summary
Utils()
           
 
Method Summary
static boolean equalsBlock(int[] a, int[] b)
          Checks two int blocks for equality.
static boolean equalsBlock(int[] a, int aOff, int[] b, int bOff, int len)
          Check the specified sub-sequences of the given int arrays for equality.
static ECPrivateKey getECPrivateKey(java.security.Key key)
          Converts a key to an IAIK ECPublicKey.
static ECPublicKey getECPublicKey(java.security.Key key)
          Converts a key to an IAIK ECPublicKey.
static PointCompressor getPointCompression()
          Method to look, if the class CompressorImpl is in the classpath.
static boolean isOnCurve(ECPoint p)
          Checks if a point is on the elliptic curve.
static boolean isSpeedUpEnabled()
          Method to look, if the class FastPrimeCurve is in the classpath.
static boolean orderCheck(ECPoint p, java.math.BigInteger order)
          Calculates p.multiply(order), where p is a point on the curve and order is the order of this point.
static void setSpeedUpsEnabled(boolean enable)
          This method can manually set whether or not the iaik_ecc_addon.jar should be used.
static java.util.Set toSet(java.lang.Object[] o)
          A convenience method to convert the given array into a Set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

equalsBlock

public static boolean equalsBlock(int[] a,
                                  int aOff,
                                  int[] b,
                                  int bOff,
                                  int len)
Check the specified sub-sequences of the given int arrays for equality.

Parameters:
a - the first int array
aOff - the offset indicating the start position within the first int array; the following len ints are compared with the corresponding number of ints of the second int array
b - the second int array
bOff - the offset indicating the start position within the second int array; the following len ints are compared with the corresponding number of ints of the first int array
len - the number of ints to be compared
Returns:
true if the two sub-arrays have the same contents, false if not

equalsBlock

public static boolean equalsBlock(int[] a,
                                  int[] b)
Checks two int blocks for equality.

Parameters:
a - the first int array to be compared with the second int array
b - the second int array to be compared with the first int array
Returns:
true if the two blocks have the same contents, false if not

toSet

public static java.util.Set toSet(java.lang.Object[] o)
A convenience method to convert the given array into a Set. Each element of the array is added to the new set starting with the element at array index 0.

Parameters:
o - the array of objects to add to the set.
Returns:
The new set.

isOnCurve

public static boolean isOnCurve(ECPoint p)
Checks if a point is on the elliptic curve.

Returns:
true if the point is indeed on the curve, false otherwise.

orderCheck

public static boolean orderCheck(ECPoint p,
                                 java.math.BigInteger order)
Calculates p.multiply(order), where p is a point on the curve and order is the order of this point. The result must be infinity.

Parameters:
p - the point on the elliptic curve
order - the order of the point p
Returns:
true if p.multiply(order) is equal to p.

isSpeedUpEnabled

public static boolean isSpeedUpEnabled()
Method to look, if the class FastPrimeCurve is in the classpath. (It is then assumed that iaik_ecc_addon.jar is included in the classpath.)

Returns:
true, if iaik_ecc_addon.jar is included in the classpath.

getPointCompression

public static PointCompressor getPointCompression()
Method to look, if the class CompressorImpl is in the classpath. (It is then assumed that iaik_ecc_addon.jar is included in the classpath.)

Returns:
An instance of a PointCompressorimplementation, if iaik_ecc_addon.jar is included in the classpath.

setSpeedUpsEnabled

public static void setSpeedUpsEnabled(boolean enable)
This method can manually set whether or not the iaik_ecc_addon.jar should be used. It is thus the responsibility of the user to ensure that the iaik_ecc_addon.jar file is present in the classpath if enable is set to true. No classloader will be used to look for the respective implementations.

Parameters:
enable - Boolean to set manually, if the jar file containing the speed-ups is present. Disables the classloader.

getECPublicKey

public static ECPublicKey getECPublicKey(java.security.Key key)
                                  throws java.security.InvalidKeyException
Converts a key to an IAIK ECPublicKey. Key must be an instance of java.security.PublicKey.

Parameters:
key - the key to be converted
Returns:
the IAIK ECPublicKey
Throws:
java.security.InvalidKeyException - if the key cannot be converted

getECPrivateKey

public static ECPrivateKey getECPrivateKey(java.security.Key key)
                                    throws java.security.InvalidKeyException
Converts a key to an IAIK ECPublicKey. Key must be an instance of java.security.PrivateKey.

Parameters:
key - the key to be converted
Returns:
the IAIK ECPrivateKey
Throws:
java.security.InvalidKeyException - if the key cannot be converted

IAIK ECC
version 2.18

IAIK-ECC 2.18, (c) 2002 IAIK, (c) 2003 SIC