You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.




org.mozilla.jss.crypto
Class Cipher

java.lang.Object
  extended by org.mozilla.jss.crypto.Cipher

Deprecated. Use the JCA interface instead (Cipher)

public abstract class Cipher
extends java.lang.Object

A context for performing symmetric encryption and decryption. First, the context must be initialized. Then, it can be updated with input through zero or more calls to update. Finally, doFinal is called to finalize the operation. Note that it is not necessary to call update if all of the data is available at once. In this case, all of the input can be processed with one call to doFinal.


Constructor Summary
Cipher()
          Deprecated.  
 
Method Summary
abstract  byte[] doFinal()
          Deprecated. Completes an cipher operation.
abstract  byte[] doFinal(byte[] bytes)
          Deprecated. Completes an cipher operation.
abstract  byte[] doFinal(byte[] bytes, int offset, int length)
          Deprecated. Completes an cipher operation.
abstract  void initDecrypt(SymmetricKey key)
          Deprecated. Initializes a decryption context with a symmetric key.
abstract  void initDecrypt(SymmetricKey key, java.security.spec.AlgorithmParameterSpec parameters)
          Deprecated. Initializes a decryption context with a symmetric key and algorithm parameters.
abstract  void initEncrypt(SymmetricKey key)
          Deprecated. Initializes a encryption context with a symmetric key.
abstract  void initEncrypt(SymmetricKey key, java.security.spec.AlgorithmParameterSpec parameters)
          Deprecated. Initializes an encryption context with a symmetric key and algorithm parameters.
static byte[] pad(byte[] toBePadded, int blockSize)
          Deprecated. Pads a byte array so that its length is a multiple of the given blocksize.
static byte[] unPad(byte[] padded)
          Deprecated. Un-pads a byte array that is padded with PKCS padding.
static byte[] unPad(byte[] padded, int blockSize)
          Deprecated. Un-pads a byte array that is padded with PKCS padding.
abstract  byte[] update(byte[] bytes)
          Deprecated. Updates the encryption context with additional input.
abstract  byte[] update(byte[] bytes, int offset, int length)
          Deprecated. Updates the encryption context with additional plaintext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cipher

public Cipher()
Deprecated. 
Method Detail

initEncrypt

public abstract void initEncrypt(SymmetricKey key)
                          throws java.security.InvalidKeyException,
                                 java.security.InvalidAlgorithmParameterException,
                                 TokenException
Deprecated. 
Initializes a encryption context with a symmetric key.

Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
TokenException

initDecrypt

public abstract void initDecrypt(SymmetricKey key)
                          throws java.security.InvalidKeyException,
                                 java.security.InvalidAlgorithmParameterException,
                                 TokenException
Deprecated. 
Initializes a decryption context with a symmetric key.

Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
TokenException

initEncrypt

public abstract void initEncrypt(SymmetricKey key,
                                 java.security.spec.AlgorithmParameterSpec parameters)
                          throws java.security.InvalidKeyException,
                                 java.security.InvalidAlgorithmParameterException,
                                 TokenException
Deprecated. 
Initializes an encryption context with a symmetric key and algorithm parameters.

Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
TokenException

initDecrypt

public abstract void initDecrypt(SymmetricKey key,
                                 java.security.spec.AlgorithmParameterSpec parameters)
                          throws java.security.InvalidKeyException,
                                 java.security.InvalidAlgorithmParameterException,
                                 TokenException
Deprecated. 
Initializes a decryption context with a symmetric key and algorithm parameters.

Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
TokenException

update

public abstract byte[] update(byte[] bytes)
                       throws java.lang.IllegalStateException,
                              TokenException
Deprecated. 
Updates the encryption context with additional input.

Parameters:
bytes - Bytes of plaintext (if encrypting) or ciphertext (if decrypting).
Returns:
Bytes of ciphertext (if encrypting) or plaintext (if decrypting).
Throws:
java.lang.IllegalStateException
TokenException

update

public abstract byte[] update(byte[] bytes,
                              int offset,
                              int length)
                       throws java.lang.IllegalStateException,
                              TokenException
Deprecated. 
Updates the encryption context with additional plaintext.

Parameters:
bytes - Bytes of plaintext (if encrypting) or ciphertext (if decrypting).
offset - The index in bytes at which to begin reading.
length - The number of bytes from bytes to read.
Returns:
Bytes of ciphertext (if encrypting) or plaintext (if decrypting).
Throws:
java.lang.IllegalStateException
TokenException

doFinal

public abstract byte[] doFinal(byte[] bytes)
                        throws java.lang.IllegalStateException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               TokenException
Deprecated. 
Completes an cipher operation. This can be called directly after the context is initialized, or update may be called any number of times before calling final.

Parameters:
bytes - Bytes of plaintext (if encrypting) or ciphertext (if decrypting).
Returns:
The last of the output.
Throws:
java.lang.IllegalStateException
IllegalBlockSizeException
BadPaddingException
TokenException

doFinal

public abstract byte[] doFinal(byte[] bytes,
                               int offset,
                               int length)
                        throws java.lang.IllegalStateException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               TokenException
Deprecated. 
Completes an cipher operation.

Parameters:
bytes - Bytes of plaintext (if encrypting) or ciphertext (if decrypting).
offset - The index in bytes at which to begin reading.
length - The number of bytes from bytes to read.
Returns:
The last of the output.
Throws:
java.lang.IllegalStateException
IllegalBlockSizeException
BadPaddingException
TokenException

doFinal

public abstract byte[] doFinal()
                        throws java.lang.IllegalStateException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               TokenException
Deprecated. 
Completes an cipher operation.

Returns:
The last of the output.
Throws:
java.lang.IllegalStateException
IllegalBlockSizeException
BadPaddingException
TokenException

pad

public static byte[] pad(byte[] toBePadded,
                         int blockSize)
Deprecated. 
Pads a byte array so that its length is a multiple of the given blocksize. The method of padding is the one defined in the RSA PKCS standards. If M is the length of the data and B is the block size, the padding string consists of B - (M mod B) octets, each having the value B - (M mod B).

Parameters:
The - block size of the encryption algorithm. Must be greater than zero.
See Also:
unPad(byte[], int)

unPad

public static byte[] unPad(byte[] padded,
                           int blockSize)
                    throws BadPaddingException
Deprecated. 
Un-pads a byte array that is padded with PKCS padding.

Parameters:
blockSize - The block size of the encryption algorithm. This is only used for error checking: if the pad size is not between 1 and blockSize, a BadPaddingException is thrown.
Throws:
BadPaddingException
See Also:
pad(byte[], int)

unPad

public static byte[] unPad(byte[] padded)
                    throws BadPaddingException
Deprecated. 
Un-pads a byte array that is padded with PKCS padding. Since this version does not take block size as a parameter, it cannot error check.

Throws:
BadPaddingException
See Also:
pad(byte[], int)