tribble.crypto
Class ZoidfarbCipher

java.lang.Object
  extended bytribble.crypto.AbstractCipher
      extended bytribble.crypto.SymmetricCipher
          extended bytribble.crypto.ZoidfarbCipher

public class ZoidfarbCipher
extends SymmetricCipher

Zoidfarb cryptographic symmetric block cipher. Encrypts or decrypts a 160-bit (20-byte) data block using a 128-bit symmetric encryption key.

Note that none of these methods are synchronized.

Acknowledgments

This code is based on an original algorithm invented by David R. Tribble in April 2003. This is version "C" of the algorithm.

License is granted to use this algorithm without fees or restrictions for all private and commercial uses.

Since:
2003-04-07
Version:
API 2, $Revision: 1.6 $ $Date: 2005/09/11 15:17:34 $
Author:
David R Tribble (david@tribble.com).

Copyright ©2003-2005 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.

See Also:
tribble.security.ZoidfarbHash

Field Summary
 
Fields inherited from class tribble.crypto.SymmetricCipher
m_blockLen
 
Fields inherited from class tribble.crypto.AbstractCipher
m_alg, m_decrypt, m_init, m_keyLen
 
Constructor Summary
ZoidfarbCipher()
          Default constructor.
 
Method Summary
protected  void blockDecrypt(byte[] in, int inOff, byte[] out, int outOff)
          Decrypt a block of ciphertext.
protected  void blockEncrypt(byte[] in, int inOff, byte[] out, int outOff)
          Encrypt a block of plaintext.
protected  void clear()
          Clear (wipe) this cipher.
protected  void initialize(byte[] key, boolean decrypt)
          Initialize this cipher.
static void main(java.lang.String[] args)
          Test driver.
 
Methods inherited from class tribble.crypto.SymmetricCipher
getBlockSize, test, test
 
Methods inherited from class tribble.crypto.AbstractCipher
finalize, getAlgorithm, getKeySize, getKeySizes
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZoidfarbCipher

public ZoidfarbCipher()
Default constructor.

Since:
1.1, 2002-05-23
Method Detail

main

public static final void main(java.lang.String[] args)
                       throws java.lang.Exception
Test driver.

Parameters:
args - Command line arguments.
Throws:
java.lang.Exception - Thrown if an error occurs in the encryption engine.
Since:
1.1, 2003-04-06

initialize

protected void initialize(byte[] key,
                          boolean decrypt)
                   throws java.security.InvalidKeyException
Initialize this cipher.

Specified by:
initialize in class AbstractCipher
Parameters:
key - The symmetric (secret) key for this cipher.
decrypt - If true, this indicates that this cipher is to be initialized for decrypting, otherwise it is to be initialized for encrypting.
Throws:
java.security.InvalidKeyException
Since:
1.1, 2002-04-26
See Also:
clear()

clear

protected void clear()
Clear (wipe) this cipher. Erases all sensitive information contained within this object.

Note that this cipher object can no longer be used after this method has been called.

Specified by:
clear in class AbstractCipher
Since:
1.5, 2004-12-20
See Also:
initialize()

blockEncrypt

protected void blockEncrypt(byte[] in,
                            int inOff,
                            byte[] out,
                            int outOff)
Encrypt a block of plaintext.

Specified by:
blockEncrypt in class SymmetricCipher
Parameters:
in - Array containing a single block of plaintext bytes to encrypt. The length of the block is exactly equal to the cipher block size (160 bits, 20 bytes).
inOff - Index of the first byte of the plaintext block within array in to encrypt.
out - Array that will be filled with the encrypted ciphertext block. The length of the block is exactly equal to the cipher block size (160 bits, 20 bytes).
outOff - Index of the first byte of array out to fill with the encrypted ciphertext block.
Since:
1.1, 2002-04-26
See Also:
blockDecrypt(), initialize()

blockDecrypt

protected void blockDecrypt(byte[] in,
                            int inOff,
                            byte[] out,
                            int outOff)
Decrypt a block of ciphertext.

Specified by:
blockDecrypt in class SymmetricCipher
Parameters:
in - Array containing a single block of ciphertext bytes to decrypt. The length of the block is exactly equal to the cipher block size (160 bits, 20 bytes).
inOff - Index of the first byte of the ciphertext block within array in to decrypt.
out - Array that will be filled with the decrypted plaintext block. The length of the block is exactly equal to the cipher block size (160 bits, 20 bytes).
outOff - Index of the first byte of array out to fill with the decrypted plaintext block.
Since:
1.1, 2002-04-26
See Also:
blockEncrypt(), initialize()