Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

cryptix.jce.provider.pbe
Class PBEBase  view PBEBase download PBEBase.java

java.lang.Object
  extended byjavax.crypto.CipherSpi
      extended bycryptix.jce.provider.pbe.PBEBase
Direct Known Subclasses:
PBEWithMD2AndDES

public abstract class PBEBase
extends javax.crypto.CipherSpi

This is the base class for any PBE cipher. It is derived from CipherSpi as other ciphers are.


Field Summary
protected  javax.crypto.Cipher cipher
          Used cipher.
protected static java.lang.String mode
          PBE ciphers are run in CBC mode.
protected static java.lang.String padding
          PBE ciphers do PKCS#5 padding.
protected static java.lang.String provider
          Provider we use.
 
Constructor Summary
protected PBEBase()
           
 
Method Summary
 java.lang.Object clone()
          Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons).
protected abstract  void coreInit(int opmode, byte[] password, byte[] salt, int iteration)
          This method is only implemented by subclasses of PBEBase.
protected  byte[] coreKeyGen(java.lang.String mdStr, byte[] password, byte[] salt, int iteration, int keysize)
          This method produces the key using specified message digest function, password, salt and iteration count.
protected  byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
          Do the last step of the encryption or decryption.
protected  int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
          Do the last step of encryption or decryption.
protected  int engineGetBlockSize()
          Returns the blocksize of the underlying cipher.
protected  byte[] engineGetIV()
          Returns the IV of the underlying cipher.
protected  int engineGetOutputSize(int inputLen)
          Returns the output size of the underlying cipher if input has given length.
protected  java.security.AlgorithmParameters engineGetParameters()
          Returns the algorithm parameters of the underlying cipher.
protected  void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
          Initializes the cipher.
protected  void engineInit(int opmode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random)
          Initialize the cipher using mainly AlgorithmParameters for further information needed by PBE.
protected  void engineInit(int opmode, java.security.Key key, java.security.SecureRandom random)
          Initializes the cipher.
protected  void engineSetMode(java.lang.String mode)
          Sets the mode of a cipher.
protected  void engineSetPadding(java.lang.String padding)
          Sets the padding of the cipher.
protected  byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
          Feed the cipher with given length of data of the input buffer starting at offset.
protected  int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
          Feed the cipher with given length of data of the input buffer starting at offset.
 
Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineGetKeySize, engineUnwrap, engineUpdate, engineWrap
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mode

protected static final java.lang.String mode
PBE ciphers are run in CBC mode.

See Also:
Constant Field Values

padding

protected static final java.lang.String padding
PBE ciphers do PKCS#5 padding.

See Also:
Constant Field Values

provider

protected static final java.lang.String provider
Provider we use.

See Also:
Constant Field Values

cipher

protected javax.crypto.Cipher cipher
Used cipher.

Constructor Detail

PBEBase

protected PBEBase()
Method Detail

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons).


engineSetMode

protected void engineSetMode(java.lang.String mode)
                      throws java.security.NoSuchAlgorithmException
Sets the mode of a cipher. PBE only uses CBC for its cipher so we only allow CBC as parameter.


engineSetPadding

protected void engineSetPadding(java.lang.String padding)
                         throws javax.crypto.NoSuchPaddingException
Sets the padding of the cipher. PBE uses PKCS#5 padding scheme so we only allow PKCS#5 padding strings as arguments.


engineGetBlockSize

protected int engineGetBlockSize()
Returns the blocksize of the underlying cipher.


engineGetOutputSize

protected int engineGetOutputSize(int inputLen)
Returns the output size of the underlying cipher if input has given length.


engineGetIV

protected byte[] engineGetIV()
Returns the IV of the underlying cipher.


engineGetParameters

protected java.security.AlgorithmParameters engineGetParameters()
Returns the algorithm parameters of the underlying cipher.


engineInit

protected void engineInit(int opmode,
                          java.security.Key key,
                          java.security.SecureRandom random)
                   throws java.security.InvalidKeyException
Initializes the cipher. As this method does not provide all input data needed for PBE it always throws an exception.


engineInit

protected void engineInit(int opmode,
                          java.security.Key key,
                          java.security.spec.AlgorithmParameterSpec params,
                          java.security.SecureRandom random)
                   throws java.security.InvalidKeyException,
                          java.security.InvalidAlgorithmParameterException
Initializes the cipher. This init method gives us all the needed information (through AlgorithmParameterSpec) for PBE.


engineInit

protected void engineInit(int opmode,
                          java.security.Key key,
                          java.security.AlgorithmParameters params,
                          java.security.SecureRandom random)
                   throws java.security.InvalidKeyException,
                          java.security.InvalidAlgorithmParameterException
Initialize the cipher using mainly AlgorithmParameters for further information needed by PBE. Get the AlgorithmParameterSpec of AlgorithmParameters call the other init method.


engineUpdate

protected byte[] engineUpdate(byte[] input,
                              int inputOffset,
                              int inputLen)
Feed the cipher with given length of data of the input buffer starting at offset.


engineUpdate

protected int engineUpdate(byte[] input,
                           int inputOffset,
                           int inputLen,
                           byte[] output,
                           int outputOffset)
                    throws javax.crypto.ShortBufferException
Feed the cipher with given length of data of the input buffer starting at offset. The result is written into the provided buffer starting at provided offset.


engineDoFinal

protected byte[] engineDoFinal(byte[] input,
                               int inputOffset,
                               int inputLen)
                        throws javax.crypto.IllegalBlockSizeException,
                               javax.crypto.BadPaddingException
Do the last step of the encryption or decryption.


engineDoFinal

protected int engineDoFinal(byte[] input,
                            int inputOffset,
                            int inputLen,
                            byte[] output,
                            int outputOffset)
                     throws javax.crypto.ShortBufferException,
                            javax.crypto.IllegalBlockSizeException,
                            javax.crypto.BadPaddingException
Do the last step of encryption or decryption.


coreInit

protected abstract void coreInit(int opmode,
                                 byte[] password,
                                 byte[] salt,
                                 int iteration)
                          throws java.security.InvalidKeyException
This method is only implemented by subclasses of PBEBase. All params which are needed for PBE are passed to it


coreKeyGen

protected byte[] coreKeyGen(java.lang.String mdStr,
                            byte[] password,
                            byte[] salt,
                            int iteration,
                            int keysize)
                     throws java.security.InvalidKeyException
This method produces the key using specified message digest function, password, salt and iteration count.