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)
-
byteBits
-
-
byteMask
-
-
charBits
-
-
charMask
-
-
delta
-
-
intMask
-
-
iter
-
-
key
-
-
logIter
-
-
sumEnd
-
-
TeaKey(int, long, long, long, long, String, String)
- Create an object for the specified Tea key.
-
TeaKey(int, String, String)
- Create a new random Tea key with keySize iterations.
-
algorithmName()
- Return the name of the algorithm used by this key.
-
blockSize()
- Returns a number n, such that least space will be wasted if
a mutiple of n bytes is encrypted at once.
-
byteToInt(byte[], int, int[], int)
- Put the bits from b[bOffset..bOffset+3] into i[iOffset]
-
calcFingerprint()
- Return the key's MD5 fingerprint.
-
createKeys(int, String, String)
- Create a TEA random key-pair.
-
decrypt(Data, Data)
- Decrypt the data from source with this key and put the plain data
in dest.
-
decryptArray(int[])
- Decrypt the array v in place.
-
decryptElement(int[], int)
- Decrypt v[offset] and v[offset+1] in place
-
encrypt(Data, Data)
- Encrypt source with this key and put the result in dest.
-
encryptArray(int[])
- Encrypt the array v in place
-
encryptElement(int[], int)
- Encrypt v[offset] and v[offset+1] in place
-
equals(Object)
- Return true iff o is equal to this Key.
-
getSize()
- Returns the number of iterations performed when encrypting
with this key.
-
intToByte(int, byte[], int)
- Put the bits from i in b[bOffset..bOffset+3].
-
log2(int)
-
-
matches(Key)
- Returns true if this and key are a matched pair
of public/private keys.
-
setIter(int)
-
-
toString()
- Return a string representation of this key.
delta
private static final long delta
intMask
private static final long intMask
charBits
private static final int charBits
byteBits
private static final int byteBits
charMask
private static final int charMask
byteMask
private static final int byteMask
key
private long key[]
iter
private int iter
logIter
private int logIter
sumEnd
private long sumEnd
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.
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.
setIter
private void setIter(int n)
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.
log2
private int log2(int n)
getSize
public int getSize()
- Returns the number of iterations performed when encrypting
with this key.
- Overrides:
- getSize in class Key
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
algorithmName
public String algorithmName()
- Return the name of the algorithm used by this key.
- Overrides:
- algorithmName in class Key
toString
public String toString()
- Return a string representation of this key.
- Overrides:
- toString in class Key
equals
public final boolean equals(Object o)
- Return true iff o is equal to this Key.
- Overrides:
- equals in class Object
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
encryptElement
public void encryptElement(int v[],
int offset)
- Encrypt v[offset] and v[offset+1] in place
encryptArray
public void encryptArray(int v[])
- Encrypt the array v in place
decryptElement
public void decryptElement(int v[],
int offset)
- Decrypt v[offset] and v[offset+1] in place
decryptArray
public void decryptArray(int v[])
- Decrypt the array v in place.
intToByte
private void intToByte(int i,
byte b[],
int bOffset)
- Put the bits from i in b[bOffset..bOffset+3].
byteToInt
private void byteToInt(byte b[],
int bOffset,
int i[],
int iOffset)
- Put the bits from b[bOffset..bOffset+3] into i[iOffset]
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
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
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