iaik.utils
Class CriticalObject

java.lang.Object
  |
  +--iaik.utils.CriticalObject
All Implemented Interfaces:
Serializable

public class CriticalObject
extends Object
implements Serializable

This class can be used to secure critical objects in memory. The object to be secured must implement the Serializable interface.

Version:
File Revision 21
See Also:
Serialized Form

Field Summary
static String cipher
          The cipher for encrypting the serialized object.
static SecureRandom random
          The random number generator for generating a new key.
 
Constructor Summary
CriticalObject(Object o)
          Creates a new CriticalObject with a new random key.
CriticalObject(Object o, boolean destroyCriticalData)
          Creates a new CriticalObject with a new random key.
CriticalObject(Object o, byte[] key)
          Creates a new CriticalObject from a given key.
CriticalObject(Object o, byte[] key, boolean destroyCriticalData)
          Creates a new CriticalObject from a given key.
 
Method Summary
protected static Object deserialize(byte[] object)
          Deserializes a given object from a byte array.
static void destroy(boolean[] a)
           
static void destroy(byte[] a)
           
static void destroy(double[] a)
           
static void destroy(Enumeration a)
           
static void destroy(float[] a)
           
static void destroy(Hashtable a)
           
static void destroy(int[] a)
           
static void destroy(long[] a)
           
static void destroy(Object a)
           
static void destroy(Object[] a)
           
static void destroy(Vector a)
           
 Object getObject()
          Returns the proteced CriticalObject.
 Object getObject(byte[] key)
          Returns the proteced CriticalObject encrypted with a given key.
protected static byte[] serialize(Object obj)
          Serializes a given object to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cipher

public static String cipher
The cipher for encrypting the serialized object. Default value is: "IDEA/CBC/PKCS5Padding"

random

public static SecureRandom random
The random number generator for generating a new key.
Constructor Detail

CriticalObject

public CriticalObject(Object o)
               throws IOException
Creates a new CriticalObject with a new random key. The length of the key is 20 bytes and the key is stored in an byte array within this class.

This method first serializes the object and then encrypts it. If the object has an accessable method "destroyCriticalData" this method is invoked after the encryption.

Parameters:
o - the critical object to protect
Throws:
IOException - if an error during the serializiation occurs

CriticalObject

public CriticalObject(Object o,
                      boolean destroyCriticalData)
               throws IOException
Creates a new CriticalObject with a new random key. The length of the key is 20 bytes and the key is stored in an byte array within this class.

This method first serializes the object and then encrypts it. If the object has an accessable method "destroyCriticalData" this method is invoked after the encryption.

Parameters:
o - the critical object to protect
destroyCriticalData - true if the method destroyCriticalData shall be invoked
Throws:
IOException - if an error during the serializiation occurs

CriticalObject

public CriticalObject(Object o,
                      byte[] key)
               throws IOException
Creates a new CriticalObject from a given key. The same key must be used for retrieving the object.

This method first serializes the object and then encrypts it. If the object has an accessable method "destroyCriticalData" this method is invoked after the encryption.

Parameters:
o - the critical object to protect
key - the key for generating an iv and a secret key
Throws:
IOException - if an error during the serializiation occurs

CriticalObject

public CriticalObject(Object o,
                      byte[] key,
                      boolean destroyCriticalData)
               throws IOException
Creates a new CriticalObject from a given key. The same key must be used for retrieving the object.

This method first serializes the object and then encrypts it. If the object has an accessable method "destroyCriticalData" this method is invoked after the encryption.

Parameters:
o - the critical object to protect
key - the key for generating an iv and a secret key
destroyCriticalData - true if the method destroyCriticalData shall be invoked
Throws:
IOException - if an error during the serializiation occurs
Method Detail

getObject

public Object getObject(byte[] key)
                 throws IOException
Returns the proteced CriticalObject encrypted with a given key.
Parameters:
key - the key used when generating the CriticalObject
Returns:
the protected object

getObject

public Object getObject()
                 throws IOException
Returns the proteced CriticalObject. This method uses the stored random key to decrypt the object.
Returns:
the protected object

deserialize

protected static Object deserialize(byte[] object)
                             throws IOException
Deserializes a given object from a byte array.
Parameters:
object - the object as a byte array
Returns:
the deserialized object

serialize

protected static byte[] serialize(Object obj)
                           throws IOException
Serializes a given object to a byte array.
Parameters:
obj - the object to serialize
Returns:
the serialized object as byte array

destroy

public static void destroy(byte[] a)

destroy

public static void destroy(int[] a)

destroy

public static void destroy(long[] a)

destroy

public static void destroy(float[] a)

destroy

public static void destroy(double[] a)

destroy

public static void destroy(boolean[] a)

destroy

public static void destroy(Object[] a)

destroy

public static void destroy(Object a)

destroy

public static void destroy(Vector a)

destroy

public static void destroy(Hashtable a)

destroy

public static void destroy(Enumeration a)

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

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK