IAIK PKCS#11 Wrapper
version 1.2.16

iaik.pkcs.pkcs11.wrapper
Class Functions

java.lang.Object
  extended byiaik.pkcs.pkcs11.wrapper.Functions

public class Functions
extends Object

This class contains onyl static methods. It is the place for all functions that are used by several classes in this package.


Field Summary
protected static Hashtable digestMechanisms_
          This table contains the mechanisms that are digest mechanisms.
protected static Hashtable fullEncryptDecryptMechanisms_
          This table contains the mechanisms that are full encrypt/decrypt mechanisms; i.e. mechanisms that support the update functoins.
protected static Hashtable fullSignVerifyMechanisms_
          This table contains the mechanisms that are full sign/verify mechanisms; i.e. mechanisms that support the update functoins.
protected static char[] HEX_DIGITS
          For converting numbers to their hex presentation.
protected static Hashtable keyDerivationMechanisms_
          This table contains the mechanisms that are key derivation mechanisms.
protected static Hashtable keyGenerationMechanisms_
          This table contains the mechanisms that key generation mechanisms; i.e.
protected static Hashtable keyPairGenerationMechanisms_
          This table contains the mechanisms that key-pair generation mechanisms; i.e. mechanisms for generating key-pairs.
protected static Hashtable mechansimNames_
          Maps mechanism codes as Long to their names as Strings.
protected static Hashtable signVerifyRecoverMechanisms_
          This table contains the mechanisms that are sign/verify mechanisms with message recovery.
protected static Hashtable singleOperationEncryptDecryptMechanisms_
          This table contains the mechanisms that are single-operation encrypt/decrypt mechanisms; i.e. mechanisms that do not support the update functoins.
protected static Hashtable singleOperationSignVerifyMechanisms_
          This table contains the mechanisms that are single-operation sign/verify mechanisms; i.e. mechanisms that do not support the update functoins.
protected static Hashtable wrapUnwrapMechanisms_
          This table contains the mechanisms that are wrap/unwrap mechanisms.
 
Constructor Summary
Functions()
           
 
Method Summary
static String classTypeToString(long classType)
          Converts the long value classType to a string representation of it.
static boolean equals(byte[] array1, byte[] array2)
          Check the given arrays for equalitiy.
static boolean equals(char[] array1, char[] array2)
          Check the given arrays for equalitiy.
static boolean equals(CK_DATE date1, CK_DATE date2)
          Check the given dates for equalitiy.
static int hashCode(byte[] array)
          Calculate a hash code for the given byte array.
static int hashCode(char[] array)
          Calculate a hash code for the given char array.
static int hashCode(CK_DATE date)
          Calculate a hash code for the given date object.
static boolean isDigestMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a digest mechanism.
static boolean isFullEncryptDecryptMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a full encrypt/decrypt mechanism; i.e. it supports the encryptUpdate() and decryptUpdate() functions.
static boolean isFullSignVerifyMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a full sign/verify mechanism; i.e. it supports the signUpdate() and verifyUpdate() functions.
static boolean isKeyDerivationMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a key derivation mechanism.
static boolean isKeyGenerationMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a key generation mechanism for generating symmetric keys.
static boolean isKeyPairGenerationMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a key-pair generation mechanism for generating key-pairs.
static boolean isSignVerifyRecoverMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a sign/verify mechanism with message recovery.
static boolean isSingleOperationEncryptDecryptMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a single-operation encrypt/decrypt mechanism; i.e. it does not support the encryptUpdate() and decryptUpdate() functions.
static boolean isSingleOperationSignVerifyMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a single-operation sign/verify mechanism; i.e. it does not support the signUpdate() and encryptUpdate() functions.
static boolean isWrapUnwrapMechanism(long mechanismCode)
          This method checks, if the mechanism with the given code is a wrap/unwrap mechanism; i.e. it supports the wrapKey() and unwrapKey() functions.
static String mechanismCodeToString(long mechansimCode)
          Converts the long value code of a mechanism to a name.
static String mechanismInfoFlagsToString(long flags)
          Converts the long value flags to a MechanismInfoFlag string.
static String sessionInfoFlagsToString(long flags)
          Converts the long value flags to a SessionInfoFlag string.
static String sessionStateToString(long state)
          Converts the long value state to a SessionState string.
static String slotInfoFlagsToString(long flags)
          Converts the long value flags to a SlotInfoFlag string.
static String toBinaryString(byte[] value)
          Converts a byte array to a binary String.
static String toBinaryString(long value)
          Converts a long value to a binary String.
static String toFullHexString(int value)
          Converts a int value to a hexadecimal String of length 8.
static String toFullHexString(long value)
          Converts a long value to a hexadecimal String of length 16.
static String toHexString(byte[] value)
          Converts a byte array to a hexadecimal String.
static String toHexString(long value)
          Converts a long value to a hexadecimal String.
static String tokenInfoFlagsToString(long flags)
          Converts long value flags to a TokenInfoFlag string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mechansimNames_

protected static Hashtable mechansimNames_
Maps mechanism codes as Long to their names as Strings.


fullEncryptDecryptMechanisms_

protected static Hashtable fullEncryptDecryptMechanisms_
This table contains the mechanisms that are full encrypt/decrypt mechanisms; i.e. mechanisms that support the update functoins. The Long values of the mechanisms are the keys, and the mechanism names are the values.


singleOperationEncryptDecryptMechanisms_

protected static Hashtable singleOperationEncryptDecryptMechanisms_
This table contains the mechanisms that are single-operation encrypt/decrypt mechanisms; i.e. mechanisms that do not support the update functoins. The Long values of the mechanisms are the keys, and the mechanism names are the values.


fullSignVerifyMechanisms_

protected static Hashtable fullSignVerifyMechanisms_
This table contains the mechanisms that are full sign/verify mechanisms; i.e. mechanisms that support the update functoins. The Long values of the mechanisms are the keys, and the mechanism names are the values.


singleOperationSignVerifyMechanisms_

protected static Hashtable singleOperationSignVerifyMechanisms_
This table contains the mechanisms that are single-operation sign/verify mechanisms; i.e. mechanisms that do not support the update functoins. The Long values of the mechanisms are the keys, and the mechanism names are the values.


signVerifyRecoverMechanisms_

protected static Hashtable signVerifyRecoverMechanisms_
This table contains the mechanisms that are sign/verify mechanisms with message recovery. The Long values of the mechanisms are the keys, and the mechanism names are the values.


digestMechanisms_

protected static Hashtable digestMechanisms_
This table contains the mechanisms that are digest mechanisms. The Long values of the mechanisms are the keys, and the mechanism names are the values.


keyGenerationMechanisms_

protected static Hashtable keyGenerationMechanisms_
This table contains the mechanisms that key generation mechanisms; i.e. mechanisms for generating symmetric keys. The Long values of the mechanisms are the keys, and the mechanism names are the values.


keyPairGenerationMechanisms_

protected static Hashtable keyPairGenerationMechanisms_
This table contains the mechanisms that key-pair generation mechanisms; i.e. mechanisms for generating key-pairs. The Long values of the mechanisms are the keys, and the mechanism names are the values.


wrapUnwrapMechanisms_

protected static Hashtable wrapUnwrapMechanisms_
This table contains the mechanisms that are wrap/unwrap mechanisms. The Long values of the mechanisms are the keys, and the mechanism names are the values.


keyDerivationMechanisms_

protected static Hashtable keyDerivationMechanisms_
This table contains the mechanisms that are key derivation mechanisms. The Long values of the mechanisms are the keys, and the mechanism names are the values.


HEX_DIGITS

protected static final char[] HEX_DIGITS
For converting numbers to their hex presentation.

Constructor Detail

Functions

public Functions()
Method Detail

toFullHexString

public static String toFullHexString(long value)
Converts a long value to a hexadecimal String of length 16. Includes leading zeros if necessary.

Parameters:
value - The long value to be converted.
Returns:
The hexadecimal string representation of the long value.

toFullHexString

public static String toFullHexString(int value)
Converts a int value to a hexadecimal String of length 8. Includes leading zeros if necessary.

Parameters:
value - The int value to be converted.
Returns:
The hexadecimal string representation of the int value.

toHexString

public static String toHexString(long value)
Converts a long value to a hexadecimal String.

Parameters:
value - The long value to be converted.
Returns:
The hexadecimal string representation of the long value.

toHexString

public static String toHexString(byte[] value)
Converts a byte array to a hexadecimal String. Each byte is presented by its two digit hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is included in the result.

Parameters:
value - the byte array to be converted
Returns:
the hexadecimal string representation of the byte array

toBinaryString

public static String toBinaryString(long value)
Converts a long value to a binary String.

Parameters:
value - the long value to be converted.
Returns:
the binary string representation of the long value.

toBinaryString

public static String toBinaryString(byte[] value)
Converts a byte array to a binary String.

Parameters:
value - The byte array to be converted.
Returns:
The binary string representation of the byte array.

slotInfoFlagsToString

public static String slotInfoFlagsToString(long flags)
Converts the long value flags to a SlotInfoFlag string.

Parameters:
flags - The flags to be converted.
Returns:
The SlotInfoFlag string representation of the flags.

tokenInfoFlagsToString

public static String tokenInfoFlagsToString(long flags)
Converts long value flags to a TokenInfoFlag string.

Parameters:
flags - The flags to be converted.
Returns:
The TokenInfoFlag string representation of the flags.

sessionInfoFlagsToString

public static String sessionInfoFlagsToString(long flags)
Converts the long value flags to a SessionInfoFlag string.

Parameters:
flags - The flags to be converted.
Returns:
The SessionInfoFlag string representation of the flags.

sessionStateToString

public static String sessionStateToString(long state)
Converts the long value state to a SessionState string.

Parameters:
state - The state to be converted.
Returns:
The SessionState string representation of the state.

mechanismInfoFlagsToString

public static String mechanismInfoFlagsToString(long flags)
Converts the long value flags to a MechanismInfoFlag string.

Parameters:
flags - The flags to be converted to a string representation.
Returns:
The MechanismInfoFlag string representation of the flags.

mechanismCodeToString

public static String mechanismCodeToString(long mechansimCode)
Converts the long value code of a mechanism to a name.

Parameters:
mechansimCode - The code of the mechanism to be converted to a string.
Returns:
The string representation of the mechanism.

classTypeToString

public static String classTypeToString(long classType)
Converts the long value classType to a string representation of it.

Parameters:
classType - The classType to be converted.
Returns:
The string representation of the classType.

equals

public static boolean equals(byte[] array1,
                             byte[] array2)
Check the given arrays for equalitiy. This method considers both arrays as equal, if both are null or both have the same length and contain exactly the same byte values.

Parameters:
array1 - The first array.
array2 - The second array.
Returns:
True, if both arrays are null or both have the same length and contain exactly the same byte values. False, otherwise.
Preconditions
Postconditions

equals

public static boolean equals(char[] array1,
                             char[] array2)
Check the given arrays for equalitiy. This method considers both arrays as equal, if both are null or both have the same length and contain exactly the same char values.

Parameters:
array1 - The first array.
array2 - The second array.
Returns:
True, if both arrays are null or both have the same length and contain exactly the same char values. False, otherwise.
Preconditions
Postconditions

equals

public static boolean equals(CK_DATE date1,
                             CK_DATE date2)
Check the given dates for equalitiy. This method considers both dates as equal, if both are null or both contain exactly the same char values.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
True, if both dates are null or both contain the same char values. False, otherwise.
Preconditions
Postconditions

hashCode

public static int hashCode(byte[] array)
Calculate a hash code for the given byte array.

Parameters:
array - The byte array.
Returns:
A hash code for the given array.
Preconditions
Postconditions

hashCode

public static int hashCode(char[] array)
Calculate a hash code for the given char array.

Parameters:
array - The char array.
Returns:
A hash code for the given array.
Preconditions
Postconditions

hashCode

public static int hashCode(CK_DATE date)
Calculate a hash code for the given date object.

Parameters:
date - The date object.
Returns:
A hash code for the given date.
Preconditions
Postconditions

isFullEncryptDecryptMechanism

public static boolean isFullEncryptDecryptMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a full encrypt/decrypt mechanism; i.e. it supports the encryptUpdate() and decryptUpdate() functions. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the encrypt and decrypt functions including encryptUpdate and decryptUpdate.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a full encrypt/decrypt mechanism. False, otherwise.
Preconditions
Postconditions

isSingleOperationEncryptDecryptMechanism

public static boolean isSingleOperationEncryptDecryptMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a single-operation encrypt/decrypt mechanism; i.e. it does not support the encryptUpdate() and decryptUpdate() functions. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the encrypt and decrypt functions excluding encryptUpdate and decryptUpdate.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a single-operation encrypt/decrypt mechanism. False, otherwise.
Preconditions
Postconditions

isFullSignVerifyMechanism

public static boolean isFullSignVerifyMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a full sign/verify mechanism; i.e. it supports the signUpdate() and verifyUpdate() functions. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the sign and verify functions including signUpdate and verifyUpdate.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a full sign/verify mechanism. False, otherwise.
Preconditions
Postconditions

isSingleOperationSignVerifyMechanism

public static boolean isSingleOperationSignVerifyMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a single-operation sign/verify mechanism; i.e. it does not support the signUpdate() and encryptUpdate() functions. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the sign and verify functions excluding signUpdate and encryptUpdate.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a single-operation sign/verify mechanism. False, otherwise.
Preconditions
Postconditions

isSignVerifyRecoverMechanism

public static boolean isSignVerifyRecoverMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a sign/verify mechanism with message recovery. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the signRecover and verifyRecover functions.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a sign/verify mechanism with message recovery. False, otherwise.
Preconditions
Postconditions

isDigestMechanism

public static boolean isDigestMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a digest mechanism. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the digest functions.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a digest mechanism. False, otherwise.
Preconditions
Postconditions

isKeyGenerationMechanism

public static boolean isKeyGenerationMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a key generation mechanism for generating symmetric keys. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the generateKey function.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a key generation mechanism. False, otherwise.
Preconditions
Postconditions

isKeyPairGenerationMechanism

public static boolean isKeyPairGenerationMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a key-pair generation mechanism for generating key-pairs. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the generateKeyPair function.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a key-pair generation mechanism. False, otherwise.
Preconditions
Postconditions

isWrapUnwrapMechanism

public static boolean isWrapUnwrapMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a wrap/unwrap mechanism; i.e. it supports the wrapKey() and unwrapKey() functions. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the wrapKey and unwrapKey functions.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a wrap/unwrap mechanism. False, otherwise.
Preconditions
Postconditions

isKeyDerivationMechanism

public static boolean isKeyDerivationMechanism(long mechanismCode)
This method checks, if the mechanism with the given code is a key derivation mechanism. This is the information as provided by the table on page 229 of the PKCS#11 v2.11 standard. If this method returns true, the mechanism can be used with the deriveKey function.

Parameters:
mechanismCode - The code of the mechanism to check.
Returns:
True, if the provided mechanism is a key derivation mechanism. False, otherwise.
Preconditions
Postconditions

IAIK PKCS#11 Wrapper
version 1.2.16

IAIK JavaSecurity Website http://jce.iaik.tugraz.at/

IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2002, IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved.