Save This Page
Home » openjdk-7 » com.sun.crypto » provider » [javadoc | source]
com.sun.crypto.provider
final class: CipherCore [javadoc | source]
java.lang.Object
   com.sun.crypto.provider.CipherCore
This class represents the symmetric algorithms in its various modes (ECB, CFB, OFB, CBC, PCBC, CTR, and CTS) and padding schemes (PKCS5Padding, NoPadding, ISO10126Padding).
Constructor:
 CipherCore(SymmetricCipher impl,
    int blkSize) 
    Creates an instance of CipherCore with default ECB mode and PKCS5Padding.
Method from com.sun.crypto.provider.CipherCore Summary:
doFinal,   doFinal,   getIV,   getKeyBytes,   getOutputSize,   getParameters,   init,   init,   init,   setMode,   setPadding,   unwrap,   update,   update,   wrap
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.crypto.provider.CipherCore Detail:
 byte[] doFinal(byte[] input,
    int inputOffset,
    int inputLen) throws IllegalBlockSizeException, BadPaddingException 
    Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this cipher was initialized.

    The first inputLen bytes in the input buffer, starting at inputOffset, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in a new buffer.

    The cipher is reset to its initial state (uninitialized) after this call.

 int doFinal(byte[] input,
    int inputOffset,
    int inputLen,
    byte[] output,
    int outputOffset) throws IllegalBlockSizeException, ShortBufferException, BadPaddingException 
    Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. The data is encrypted or decrypted, depending on how this cipher was initialized.

    The first inputLen bytes in the input buffer, starting at inputOffset, and any input bytes that may have been buffered during a previous update operation, are processed, with padding (if requested) being applied. The result is stored in the output buffer, starting at outputOffset.

    The cipher is reset to its initial state (uninitialized) after this call.

 byte[] getIV() 
    Returns the initialization vector (IV) in a new buffer.

    This is useful in the case where a random IV has been created (see init), or in the context of password-based encryption or decryption, where the IV is derived from a user-provided password.

 static byte[] getKeyBytes(Key key) throws InvalidKeyException 
    Return the key bytes of the specified key. Throw an InvalidKeyException if the key is not usable.
 int getOutputSize(int inputLen) 
    Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes).

    This call takes into account any unprocessed (buffered) data from a previous update call, and padding.

    The actual output length of the next update or doFinal call may be smaller than the length returned by this method.

 AlgorithmParameters getParameters(String algName) 
    Returns the parameters used with this cipher.

    The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).

  void init(int opmode,
    Key key,
    SecureRandom random) throws InvalidKeyException 
    Initializes this cipher with a key and a source of randomness.

    The cipher is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opmode.

    If this cipher requires an initialization vector (IV), it will get it from random. This behaviour should only be used in encryption or key wrapping mode, however. When initializing a cipher that requires an IV for decryption or key unwrapping, the IV (same IV that was used for encryption or key wrapping) must be provided explicitly as a parameter, in order to get the correct result.

    This method also cleans existing buffer and other related state information.

  void init(int opmode,
    Key key,
    AlgorithmParameterSpec params,
    SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException 
    Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness.

    The cipher is initialized for one of the following four operations: encryption, decryption, key wrapping or key unwrapping, depending on the value of opmode.

    If this cipher (including its underlying feedback or padding scheme) requires any random bytes, it will get them from random.

  void init(int opmode,
    Key key,
    AlgorithmParameters params,
    SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException 
  void setMode(String mode) throws NoSuchAlgorithmException 
    Sets the mode of this cipher.
  void setPadding(String paddingScheme) throws NoSuchPaddingException 
    Sets the padding mechanism of this cipher.
 Key unwrap(byte[] wrappedKey,
    String wrappedKeyAlgorithm,
    int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException 
    Unwrap a previously wrapped key.
 byte[] update(byte[] input,
    int inputOffset,
    int inputLen) 
    Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

    The first inputLen bytes in the input buffer, starting at inputOffset, are processed, and the result is stored in a new buffer.

 int update(byte[] input,
    int inputOffset,
    int inputLen,
    byte[] output,
    int outputOffset) throws ShortBufferException 
    Continues a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.

    The first inputLen bytes in the input buffer, starting at inputOffset, are processed, and the result is stored in the output buffer, starting at outputOffset.

 byte[] wrap(Key key) throws IllegalBlockSizeException, InvalidKeyException 
    Wrap a key.