ice-doc-java.html
5ea3023019af3153db607d32bdd5b425d0d2e77207388d19f41db93f4d1b0378
<HTML>
<HEAD><TITLE>Class IceKey</TITLE></HEAD>
<BODY BGCOLOR="#d8d8d8" TEXT="#000080" LINK="#0000FF">
<H1> Class IceKey</H1>
<PRE>
class <STRONG>IceKey</STRONG>
{
// Constructors
public <A HREF="#1">IceKey</A>(int level);
// Methods
public void <A HREF="#2">set</A>(byte key[]);
public byte[] <A HREF="#3">encrypt</A>(byte plaintext[], byte ciphertext[]);
public byte[] <A HREF="#4">decrypt</A>(byte ciphertext[], byte plaintext[]);
public void <A HREF="#5">clear</A>();
public int <A HREF="#6">keySize</A>();
public int <A HREF="#7">blockSize</A>();
}
</PRE>
<P>
An <B>IceKey</B> object is used to encrypt and decrypt 8-byte blocks
of data using the ICE encryption algorithm. ICE, an acronym for
<EM>Information Concealment Engine</EM>, is a 64-bit block cipher in
the tradition of DES. However, it aims to be faster and significantly
more secure than DES. </P>
<P>
Unlike DES, ICE has various levels of encryption, where higher levels
provide more security, but at the expense of speed. It also makes use of
a technique called <EM>keyed permutation</EM> internally, which gives
it increased resistance to differential and linear cryptanalysis. </P>
<P>
Once an <B>IceKey</B> object has been created, it will usually have
its key set from a password of some sort. The object can then be used
to encrypt and decrypt data using that key. </P>
<HR>
<H2> Constructors </H2>
<A NAME="1"><H3> IceKey </H3></A>
<CODE> public IceKey(int level) </CODE>
<DL>
<DD> Creates an <B>IceKey</B> object. The <EM>level</EM> parameter specifies
the level of ICE encryption to use, where higher levels require
longer keys and are slower, but are more secure.
<DD> Level 0 uses the <EM>Thin-ICE</EM> variant of ICE, which is an 8-round
cipher taking an 8-byte key. This is the fastest option, and is
generally considered to be at least as secure as DES. For levels
<EM>n</EM> greater than zero, a 16<EM>n</EM>-round cipher is used,
taking 8<EM>n</EM>-byte keys. Although not as fast as level 0, these
are very secure.
<BR><BR>
<DL>
<DT> <B>Parameters:</B>
<DD> <CODE>level - </CODE>the ICE level of encryption
</DL>
</DL>
<HR>
<H2> Methods </H2>
<A NAME="2"><H3> set </H3></A>
<CODE> public void set(byte key[]) </CODE>
<DL>
<DD> This method sets the key schedule for the <B>IceKey</B>. This should
be called before any encryption or decryption is done, or the results
will not be secure. The number of key bytes used depends on the level
of encryption set in the constructor. For levels 0 and 1, 8 bytes are
used. For levels <EM>n</EM> > 1, 8<EM>n</EM> bytes are used.
<DD> If the key array is not large enough to contain the required number
of bytes, an array bounds error will occur.
<BR><BR>
<DL>
<DT> <B>Parameters:</B>
<DD> <CODE>key - </CODE>the key used to encrypt and decrypt data
</DL>
</DL>
<A NAME="3"><H3> encrypt </H3></A>
<CODE> public byte[] encrypt(byte plaintext[], byte ciphertext[]) </CODE>
<DL>
<DD> This method is called to encrypt 8 bytes of the plaintext with the
key specified in the <A HREF="#2">set</A> method. The result is stored
in the ciphertext array, which is also the return value.
<BR><BR>
<DL>
<DT> <B>Parameters:</B>
<DD> <CODE>plaintext - </CODE>the data to be encrypted
<DD> <CODE>ciphertext - </CODE>the resulting encrypted data
</DL>
</DL>
<A NAME="4"><H3> decrypt </H3></A>
<CODE> public byte[] decrypt(byte ciphertext[], byte plaintext[]) </CODE>
<DL>
<DD> This method is called to decrypt 8 bytes of the plaintext with the
key specified in the <A HREF="#2">set</A> method. The result is stored
in the plaintext array, which is also the return value.
<BR><BR>
<DL>
<DT> <B>Parameters:</B>
<DD> <CODE>ciphertext - </CODE>the data to be decrypted
<DD> <CODE>plaintext - </CODE>the resulting decrypted data
</DL>
</DL>
<A NAME="5"><H3> clear </H3></A>
<CODE> public void clear() </CODE>
<DL>
<DD> This method zeroes out the key schedule, which prevents memory
snoopers from finding key information. It should only be called when
the key is no longer needed for encryption or decryption.
</DL>
<A NAME="6"><H3> keySize </H3></A>
<CODE> public int keySize() </CODE>
<DL>
<DD> This method returns the key size, in bytes.
</DL>
<A NAME="7"><H3> blockSize </H3></A>
<CODE> public int blockSize() </CODE>
<DL>
<DD> This method returns the block size, in bytes. The value is always 8.
</DL>
<HR>
<DIV ALIGN=RIGHT>
<FONT SIZE=-1>
Document written by Matthew Kwan, 25 March 1997 <BR>
Please send any comments or corrections to
<A HREF="mailto:mkwan@darkside.com.au">mkwan@darkside.com.au</A>
</FONT>
</DIV>
</BODY>
</HTML>