tribble.crypto
Class Cipher

java.lang.Object
  extended byjavax.crypto.Cipher
      extended bytribble.crypto.Cipher

public abstract class Cipher
extends javax.crypto.Cipher

Cryptographic cipher implementation.

This class generates instances of cryptographic cipher algorithms.

Cipher objects (of type javax.crypto.Cipher) are constructed from a combination of a cipher SPI object, which is one of generic cipher algorithm types derived from this class, CipherSpi, and a primitive cipher algorithm, which is a class derived from class AbstractCipher.

Since:
JCE 1.2 / JRE 1.4, 2005-09-10
Version:
API 2, $Revision: 1.1 $ $Date: 2005/09/11 04:28:52 $
Author:
David R. Tribble (david@tribble.com).

Copyright ©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:
CipherSpi, AbstractCipher, MyProvider

Field Summary
static short DECRYPT_MODE
          Initialization mode: Decryption.
static short ENCRYPT_MODE
          Initialization mode: Encryption.
static java.lang.String MODE_BC
          Operating mode (block): BC, block chaining.
static java.lang.String MODE_CBC
          Operating mode (block): CBC, cipher block chaining.
static java.lang.String MODE_CFB
          Operating mode (stream): CFB, cipher feedback.
static java.lang.String MODE_CFB8
          Operating mode (stream): CFB-8, cipher feedback.
static java.lang.String MODE_CTR
          Operating mode (stream): CTR, counter mode.
static java.lang.String MODE_CTR8
          Operating mode (stream): CTR-8, counter mode.
static java.lang.String MODE_ECB
          Operating mode (block): ECB, electronic codebook (no chaining).
static java.lang.String MODE_OFB
          Operating mode (stream): OFB, output feedback.
static java.lang.String MODE_OFB8
          Operating mode (stream): OFB-8, output feedback.
static java.lang.String MODE_PBC
          Operating mode (block): PBC, plaintext block chaining.
static java.lang.String MODE_PCBC
          Operating mode (block): PCBC, propagating cipher block chaining.
static java.lang.String MODE_PFB
          Operating mode (stream): PFB, plaintext feedback.
static java.lang.String MODE_PFB8
          Operating mode (stream): PFB-8, plaintext feedback.
static java.lang.String PADDING_CTS
          Padding scheme: Ciphertext stealing in the final partial block.
static java.lang.String PADDING_NONE
          Padding scheme: None.
static java.lang.String PADDING_PKCS5
          Padding scheme: PKCS#5.
static java.lang.String PADDING_ZEROS
          Padding scheme: Pad with zero bytes (nulls).
static short PRIVATE_KEY
          Key type: Private.
static short PUBLIC_KEY
          Key type: Public.
static short SECRET_KEY
          Key type: Secret.
static int SERIES
          Class series version.
static short UNWRAP_MODE
          Key wrap mode: Unwrap.
static short WRAP_MODE
          Key wrap mode: Wrap.
 
Method Summary
 void clear()
          Clear (wipe) this cipher.
protected  void finalize()
          Finalization.
static Cipher getCipher(java.lang.String trans)
          Generates a Cipher object that implements the specified transformation.
 
Methods inherited from class javax.crypto.Cipher
doFinal, doFinal, doFinal, doFinal, doFinal, doFinal, getAlgorithm, getBlockSize, getExemptionMechanism, getInstance, getInstance, getInstance, getIV, getOutputSize, getParameters, getProvider, init, init, init, init, init, init, init, init, unwrap, update, update, update, update, wrap
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIES

public static final int SERIES
Class series version.

See Also:
Constant Field Values

ENCRYPT_MODE

public static final short ENCRYPT_MODE
Initialization mode: Encryption. (Same as Cipher.ENCRYPT_MODE.)


DECRYPT_MODE

public static final short DECRYPT_MODE
Initialization mode: Decryption. (Same as Cipher.DECRYPT_MODE.)


SECRET_KEY

public static final short SECRET_KEY
Key type: Secret. (Same as Cipher.SECRET_KEY.)


PUBLIC_KEY

public static final short PUBLIC_KEY
Key type: Public. (Same as Cipher.PUBLIC_KEY.)


PRIVATE_KEY

public static final short PRIVATE_KEY
Key type: Private. (Same as Cipher.PRIVATE_KEY.)


WRAP_MODE

public static final short WRAP_MODE
Key wrap mode: Wrap. (Same as Cipher.WRAP_MODE.)


UNWRAP_MODE

public static final short UNWRAP_MODE
Key wrap mode: Unwrap. (Same as Cipher.UNWRAP_MODE.)


MODE_ECB

public static final java.lang.String MODE_ECB
Operating mode (block): ECB, electronic codebook (no chaining).

See Also:
Constant Field Values

MODE_CBC

public static final java.lang.String MODE_CBC
Operating mode (block): CBC, cipher block chaining.

See Also:
Constant Field Values

MODE_PBC

public static final java.lang.String MODE_PBC
Operating mode (block): PBC, plaintext block chaining.

See Also:
Constant Field Values

MODE_PCBC

public static final java.lang.String MODE_PCBC
Operating mode (block): PCBC, propagating cipher block chaining.

See Also:
Constant Field Values

MODE_BC

public static final java.lang.String MODE_BC
Operating mode (block): BC, block chaining.

See Also:
Constant Field Values

MODE_CFB

public static final java.lang.String MODE_CFB
Operating mode (stream): CFB, cipher feedback.

See Also:
Constant Field Values

MODE_CFB8

public static final java.lang.String MODE_CFB8
Operating mode (stream): CFB-8, cipher feedback.

See Also:
Constant Field Values

MODE_OFB

public static final java.lang.String MODE_OFB
Operating mode (stream): OFB, output feedback.

See Also:
Constant Field Values

MODE_OFB8

public static final java.lang.String MODE_OFB8
Operating mode (stream): OFB-8, output feedback.

See Also:
Constant Field Values

MODE_PFB

public static final java.lang.String MODE_PFB
Operating mode (stream): PFB, plaintext feedback.

See Also:
Constant Field Values

MODE_PFB8

public static final java.lang.String MODE_PFB8
Operating mode (stream): PFB-8, plaintext feedback.

See Also:
Constant Field Values

MODE_CTR

public static final java.lang.String MODE_CTR
Operating mode (stream): CTR, counter mode.

See Also:
Constant Field Values

MODE_CTR8

public static final java.lang.String MODE_CTR8
Operating mode (stream): CTR-8, counter mode.

See Also:
Constant Field Values

PADDING_NONE

public static final java.lang.String PADDING_NONE
Padding scheme: None.

See Also:
Constant Field Values

PADDING_PKCS5

public static final java.lang.String PADDING_PKCS5
Padding scheme: PKCS#5.

See Also:
Constant Field Values

PADDING_ZEROS

public static final java.lang.String PADDING_ZEROS
Padding scheme: Pad with zero bytes (nulls).

See Also:
Constant Field Values

PADDING_CTS

public static final java.lang.String PADDING_CTS
Padding scheme: Ciphertext stealing in the final partial block.

See Also:
Constant Field Values
Method Detail

getCipher

public static final Cipher getCipher(java.lang.String trans)
                              throws java.security.NoSuchAlgorithmException,
                                     javax.crypto.NoSuchPaddingException
Generates a Cipher object that implements the specified transformation.

This method corresponds to the getInstance() method of class javax.crypto.Cipher.

Parameters:
trans - The name of the transformation, e.g., "AES/CBC/PKCS5Padding".
Returns:
A cipher that implements the requested transformation.
Throws:
java.security.NoSuchAlgorithmException - Thrown if trans does not specify a transformation provided by this implementation package.
javax.crypto.NoSuchPaddingException - Thrown if trans does not specify a padding scheme provided by this implementation package.
Since:
1.1, 2005-09-10

clear

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

This method is not part of the standard set defined in class javax.crypto.Cipher, but is provided as a convenient enhancement.

Note that this cipher object is no longer usable after calling this method.

Since:
1.1, 2005-09-10

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalization. Erases all sensitive information contained within this object prior to it being garbage-collected.

Throws:
java.lang.Throwable
Since:
1.1, 2005-09-10