All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class IS.hi.logir.cryptonite.TeaKey

java.lang.Object
   |
   +----IS.hi.logir.cryptonite.Key
           |
           +----IS.hi.logir.cryptonite.TeaKey

public class TeaKey
extends Key
implements Serializable, Fingerprintable
The Tiny Encryption Algorithm (TEA) by David Wheeler and Roger Needham of the Cambridge Computer Laboratory.

TEA is a Feistel cipher with XOR and and addition as the non-linear mixing functions.

The number of iterations is variable. 32 is ample, 16 is sufficient, as few as eight may be OK. The algorithm achieves good dispersion after six iterations.

Author:
Logi Ragnarsson (logir@hi.is)

Variable Index

 o byteBits
 o byteMask
 o charBits
 o charMask
 o delta
 o intMask
 o iter
 o key
 o logIter
 o sumEnd

Constructor Index

 o TeaKey(int, long, long, long, long, String, String)
Create an object for the specified Tea key.
 o TeaKey(int, String, String)
Create a new random Tea key with keySize iterations.

Method Index

 o algorithmName()
Return the name of the algorithm used by this key.
 o blockSize()
Returns a number n, such that least space will be wasted if a mutiple of n bytes is encrypted at once.
 o byteToInt(byte[], int, int[], int)
Put the bits from b[bOffset..bOffset+3] into i[iOffset]
 o calcFingerprint()
Return the key's MD5 fingerprint.
 o createKeys(int, String, String)
Create a TEA random key-pair.
 o decrypt(Data, Data)
Decrypt the data from source with this key and put the plain data in dest.
 o decryptArray(int[])
Decrypt the array v in place.
 o decryptElement(int[], int)
Decrypt v[offset] and v[offset+1] in place
 o encrypt(Data, Data)
Encrypt source with this key and put the result in dest.
 o encryptArray(int[])
Encrypt the array v in place
 o encryptElement(int[], int)
Encrypt v[offset] and v[offset+1] in place
 o equals(Object)
Return true iff o is equal to this Key.
 o getSize()
Returns the number of iterations performed when encrypting with this key.
 o intToByte(int, byte[], int)
Put the bits from i in b[bOffset..bOffset+3].
 o log2(int)
 o matches(Key)
Returns true if this and key are a matched pair of public/private keys.
 o setIter(int)
 o toString()
Return a string representation of this key.

Variables

 o delta
 private static final long delta
 o intMask
 private static final long intMask
 o charBits
 private static final int charBits
 o byteBits
 private static final int byteBits
 o charMask
 private static final int charMask
 o byteMask
 private static final int byteMask
 o key
 private long key[]
 o iter
 private int iter
 o logIter
 private int logIter
 o sumEnd
 private long sumEnd

Constructors

 o TeaKey
 public TeaKey(int keySize,
               String ownerName,
               String ownerMail)
Create a new random Tea key with keySize iterations. It will be marked as belonging to ownerName with e-mail address ownerMail.

 o TeaKey
 public TeaKey(int keySize,
               long k1,
               long k2,
               long k3,
               long k4,
               String ownerName,
               String ownerMail)
Create an object for the specified Tea key. It will be marked as belonging to ownerName with e-mail address ownerMail.

Methods

 o setIter
 private void setIter(int n)
 o createKeys
 public static KeyPair createKeys(int keySize,
                                  String ownerName,
                                  String ownerMail)
Create a TEA random key-pair. Both keys will be identical, since TEA is a symmetric cipher. The key will perform keySize iterations during encryption. It will be marked as belonging to ownerName with e-mail address ownerMail.

 o log2
 private int log2(int n)
 o getSize
 public int getSize()
Returns the number of iterations performed when encrypting with this key.

Overrides:
getSize in class Key
 o calcFingerprint
 protected final Fingerprint calcFingerprint()
Return the key's MD5 fingerprint. It is called by the final getFingerprint method in the Key superclass.

Overrides:
calcFingerprint in class Key
See Also:
MD5State, Fingerprintable
 o algorithmName
 public String algorithmName()
Return the name of the algorithm used by this key.

Overrides:
algorithmName in class Key
 o toString
 public String toString()
Return a string representation of this key.

Overrides:
toString in class Key
 o equals
 public final boolean equals(Object o)
Return true iff o is equal to this Key.

Overrides:
equals in class Object
 o matches
 public final boolean matches(Key k)
Returns true if this and key are a matched pair of public/private keys. For symetric ciphers such as TEA, this is true iff k is equal to this key.

Overrides:
matches in class Key
 o encryptElement
 public void encryptElement(int v[],
                            int offset)
Encrypt v[offset] and v[offset+1] in place

 o encryptArray
 public void encryptArray(int v[])
Encrypt the array v in place

 o decryptElement
 public void decryptElement(int v[],
                            int offset)
Decrypt v[offset] and v[offset+1] in place

 o decryptArray
 public void decryptArray(int v[])
Decrypt the array v in place.

 o intToByte
 private void intToByte(int i,
                        byte b[],
                        int bOffset)
Put the bits from i in b[bOffset..bOffset+3].

 o byteToInt
 private void byteToInt(byte b[],
                        int bOffset,
                        int i[],
                        int iOffset)
Put the bits from b[bOffset..bOffset+3] into i[iOffset]

 o blockSize
 public int blockSize()
Returns a number n, such that least space will be wasted if a mutiple of n bytes is encrypted at once.

Overrides:
blockSize in class Key
 o encrypt
 public final void encrypt(Data source,
                           Data dest)
Encrypt source with this key and put the result in dest. The source.buf and dest.buf arrays must be different.

Overrides:
encrypt in class Key
 o decrypt
 public void decrypt(Data source,
                     Data dest)
Decrypt the data from source with this key and put the plain data in dest.

Overrides:
decrypt in class Key

All Packages  Class Hierarchy  This Package  Previous  Next  Index