XML Security, 1.6

com.ibm.xml.crypto.spi
Interface EncryptionEngine


public interface EncryptionEngine

This interface defines methods for encryption and decryption of data and key. The methods are called by our XML Encryption processor as follows: On data encryption or decryption, init() is called first, and then update() is called repeatedly as long as data to be processed exist, and finally doFinal() is called. On key encryption or decryption, init() is called first, and then wrap() or unwrap() is called, respectively.

Instances of this interface are obtained through an instance of the EngineFactory interface. See its documentation for more details.

See Also:
EngineFactory.getEncryptionEngine(String), EngineFactory.releaseEncryptionEngine(EncryptionEngine)

Field Summary
static int DECRYPT_MODE
          Operation mode for data decryption.
static int ENCRYPT_MODE
          Operation mode for data encryption.
static int UNWRAP_MODE
          Operation mode for key unwrapping.
static int WRAP_MODE
          Operation mode for key wrapping.
 
Method Summary
 byte[] doFinal()
          Finishes a multiple-part operation.
 byte[] doFinal(byte[] input)
          Processes data in a single-part operation, or finishes a multiple-part operation.
 byte[] doFinal(byte[] input, int off, int len)
          Processes data in a single-part operation, or finishes a multiple-part operation.
 java.lang.String getURI()
          Returns the algorithm URI of this engine.
 void init(int opMode, java.security.Key key, java.security.spec.AlgorithmParameterSpec spec)
          Initializes this engine with a key and a set of algorithm parameters.
 java.security.Key unwrap(byte[] wrappedKey, java.lang.String uri, java.lang.String type)
          Unwraps a previously wrapped key.
 byte[] update(byte[] input)
          Continues a multiple-part operation, processing another data part.
 byte[] update(byte[] input, int off, int len)
          Continues a multiple-part operation, processing another data part.
 byte[] wrap(java.security.Key key)
          Wraps a key.
 

Field Detail

ENCRYPT_MODE

static final int ENCRYPT_MODE
Operation mode for data encryption.

See Also:
Constant Field Values

DECRYPT_MODE

static final int DECRYPT_MODE
Operation mode for data decryption.

See Also:
Constant Field Values

WRAP_MODE

static final int WRAP_MODE
Operation mode for key wrapping.

See Also:
Constant Field Values

UNWRAP_MODE

static final int UNWRAP_MODE
Operation mode for key unwrapping.

See Also:
Constant Field Values
Method Detail

getURI

java.lang.String getURI()
Returns the algorithm URI of this engine.

Returns:
algorithm URI.

init

void init(int opMode,
          java.security.Key key,
          java.security.spec.AlgorithmParameterSpec spec)
          throws java.security.InvalidAlgorithmParameterException,
                 java.security.InvalidKeyException
Initializes this engine with a key and a set of algorithm parameters.

Parameters:
opMode - operation mode, which is one of ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE, or UNWRAP_MODE.
key - key.
spec - algorithm parameters. It may be null.
Throws:
java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException

update

byte[] update(byte[] input)
Continues a multiple-part operation, processing another data part.

Parameters:
input - input buffer.
Returns:
new buffer with the result, or null if the underlying cipher is a block cipher and the input data is too short to result in a new block.

update

byte[] update(byte[] input,
              int off,
              int len)
Continues a multiple-part operation, processing another data part.

Parameters:
input - input buffer.
off - start offset in the input buffer.
len - number of bytes to input.
Returns:
new buffer with the result, or null if the underlying cipher is a block cipher and the input data is too short to result in a new block.

doFinal

byte[] doFinal()
               throws javax.crypto.BadPaddingException,
                      javax.crypto.IllegalBlockSizeException
Finishes a multiple-part operation.

Returns:
new buffer with the result.
Throws:
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException

doFinal

byte[] doFinal(byte[] input)
               throws javax.crypto.BadPaddingException,
                      javax.crypto.IllegalBlockSizeException
Processes data in a single-part operation, or finishes a multiple-part operation.

Parameters:
input - input buffer.
Returns:
new buffer with the result.
Throws:
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException

doFinal

byte[] doFinal(byte[] input,
               int off,
               int len)
               throws javax.crypto.BadPaddingException,
                      javax.crypto.IllegalBlockSizeException
Processes data in a single-part operation, or finishes a multiple-part operation.

Parameters:
input - input buffer.
off - start offset in the input buffer.
len - number of bytes to input.
Returns:
new buffer with the result.
Throws:
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException

wrap

byte[] wrap(java.security.Key key)
            throws javax.crypto.IllegalBlockSizeException,
                   java.security.InvalidKeyException
Wraps a key.

Parameters:
key - key to be wrapped.
Returns:
wrapped key.
Throws:
javax.crypto.IllegalBlockSizeException
java.security.InvalidKeyException

unwrap

java.security.Key unwrap(byte[] wrappedKey,
                         java.lang.String uri,
                         java.lang.String type)
                         throws java.security.InvalidKeyException,
                                java.security.NoSuchAlgorithmException
Unwraps a previously wrapped key.

Parameters:
wrappedKey - key to be unwrapped.
uri - algorithm URI associated with the wrapped key, which is usually the value of the Algorithm attribute of the EncryptionMethod element of the EncryptedData or EncryptedKey element to which the wrapped key was applied.
type - type of the wrapped key, which is usually the value of the Type attribute of the EncryptedKey element containing the wrapped key.
Returns:
unwrapped key.
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException

XML Security, 1.6

Portions Copyright 2003, 2012 IBM Corporation.
Portions Copyright 2003, 2012 Oracle and/or its affiliates.