XML Security, 1.6

com.ibm.xml.enc.dom
Class DOMAESCBC

java.lang.Object
  extended by com.ibm.xml.enc.dom.DOMStructure
      extended by com.ibm.xml.enc.dom.DOMEncryptionMethod
          extended by com.ibm.xml.enc.dom.DOMAESCBC
All Implemented Interfaces:
AlgorithmMethod, EncryptionMethod, XMLStructure

public final class DOMAESCBC
extends DOMEncryptionMethod

DOM-based implementation of EncryptionMethod for AES algorithm.


Field Summary
 
Fields inherited from interface javax.xml.crypto.enc.EncryptionMethod
AES128_CBC, AES192_CBC, AES256_CBC, KW_AES128, KW_AES192, KW_AES256, KW_TRIPLEDES, RSA_1_5, RSA_OAEP_MGF1P, TRIPLEDES_CBC
 
Constructor Summary
DOMAESCBC(org.w3c.dom.Element smElem, java.lang.String algo)
          Creates a DOMAESCBC from an element.
DOMAESCBC(java.lang.String algo, java.lang.Integer keysize, java.security.spec.AlgorithmParameterSpec params)
          Creates a DOMAESCBC for the specified input parameters.
 
Method Summary
protected  void checkParams(java.lang.Integer keySize, EncryptionMethodParameterSpec params)
          Checks if the specified parameters are valid for this algorithm.
 byte[] decrypt(java.security.Key key, byte[] data)
          decrypt the specified bytes with the specified key, using the underlying encryption algorithm.
 java.security.Key decryptKey(java.security.Key key, byte[] encryptedKey, AlgorithmMethod algo)
           
 byte[] encrypt(java.security.Key key, byte[] data, EncryptedType type)
          encrypt the passed-in data with the specified key, using the underlying encryption algorithm and parameters.
 javax.crypto.Cipher getCipher(java.lang.String callingMethodName)
           
protected  void marshalParams(org.w3c.dom.Element parent, java.lang.String dsPrefix)
          Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element.
protected  boolean paramsEqual(java.security.spec.AlgorithmParameterSpec spec)
          Returns true if parameters are equal; false otherwise.
protected  EncryptionMethodParameterSpec unmarshalParams(org.w3c.dom.Element paramsElem)
          Unmarshals EncryptionMethodParameterSpec from the specified Element.
 byte[] unwrap(java.security.Key key, byte[] encrypted)
          unwraps a previously wrapped key using the underlying encryption algorithm.
 java.security.Key unwrap(java.security.Key key, byte[] encrypted, AlgorithmMethod algo)
          unwraps a previously wrapped key using the underlying encryption algorithm.
 byte[] wrap(java.security.Key key, java.security.Key toBeWrapped)
          encrypt the passed-in key with the specified key, using the underlying encryption algorithm and parameters.
 
Methods inherited from class com.ibm.xml.enc.dom.DOMEncryptionMethod
equals, genKey, getAlgorithm, getKeySize, getParameterSpec, init, marshal, parseAlg, unmarshal
 
Methods inherited from class com.ibm.xml.enc.dom.DOMStructure
isFeatureSupported
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.crypto.XMLStructure
isFeatureSupported
 

Constructor Detail

DOMAESCBC

public DOMAESCBC(java.lang.String algo,
                 java.lang.Integer keysize,
                 java.security.spec.AlgorithmParameterSpec params)
          throws java.security.InvalidAlgorithmParameterException
Creates a DOMAESCBC for the specified input parameters.

Parameters:
algo - the AES algorithm (128, 192 or 256)
params - algorithm-specific parameters (may be null)
Throws:
java.security.InvalidAlgorithmParameterException - if the parameters are not appropriate for this cipher method

DOMAESCBC

public DOMAESCBC(org.w3c.dom.Element smElem,
                 java.lang.String algo)
          throws MarshalException
Creates a DOMAESCBC from an element.

Parameters:
smElem - a EncryptionMethod element
Throws:
MarshalException
Method Detail

checkParams

protected void checkParams(java.lang.Integer keySize,
                           EncryptionMethodParameterSpec params)
                    throws java.security.InvalidAlgorithmParameterException
Description copied from class: DOMEncryptionMethod
Checks if the specified parameters are valid for this algorithm.

Specified by:
checkParams in class DOMEncryptionMethod
params - the algorithm-specific params (may be null)
Throws:
java.security.InvalidAlgorithmParameterException - if the parameters are not appropriate for this encryption method

unmarshalParams

protected EncryptionMethodParameterSpec unmarshalParams(org.w3c.dom.Element paramsElem)
                                                 throws MarshalException
Description copied from class: DOMEncryptionMethod
Unmarshals EncryptionMethodParameterSpec from the specified Element. Subclasses should implement this to unmarshal the algorithm-specific parameters.

Specified by:
unmarshalParams in class DOMEncryptionMethod
Parameters:
paramsElem - the Element holding the input params
Returns:
the algorithm-specific EncryptionMethodParameterSpec
Throws:
MarshalException - if the parameters cannot be unmarshalled

marshalParams

protected void marshalParams(org.w3c.dom.Element parent,
                             java.lang.String dsPrefix)
                      throws MarshalException
Description copied from class: DOMEncryptionMethod
Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element.

Specified by:
marshalParams in class DOMEncryptionMethod
Parameters:
parent - the parent element to append the parameters to
dsPrefix - the algorithm parameters prefix to use
Throws:
MarshalException - if the parameters cannot be marshalled

paramsEqual

protected boolean paramsEqual(java.security.spec.AlgorithmParameterSpec spec)
Description copied from class: DOMEncryptionMethod
Returns true if parameters are equal; false otherwise. Subclasses should override this method to compare algorithm-specific parameters.

Specified by:
paramsEqual in class DOMEncryptionMethod

decrypt

public byte[] decrypt(java.security.Key key,
                      byte[] data)
               throws java.security.InvalidKeyException,
                      javax.crypto.BadPaddingException,
                      javax.crypto.IllegalBlockSizeException
Description copied from class: DOMEncryptionMethod
decrypt the specified bytes with the specified key, using the underlying encryption algorithm.

Specified by:
decrypt in class DOMEncryptionMethod
Parameters:
key - the decryption key
data - the bytes to be decrypted
Returns:
the decrypted data
Throws:
java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc
javax.crypto.BadPaddingException - if unpadding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
javax.crypto.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size

decryptKey

public java.security.Key decryptKey(java.security.Key key,
                                    byte[] encryptedKey,
                                    AlgorithmMethod algo)
                             throws java.security.InvalidKeyException,
                                    javax.crypto.BadPaddingException,
                                    javax.crypto.IllegalBlockSizeException,
                                    java.security.NoSuchAlgorithmException
Specified by:
decryptKey in class DOMEncryptionMethod
Throws:
java.security.InvalidKeyException
javax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
java.security.NoSuchAlgorithmException

encrypt

public byte[] encrypt(java.security.Key key,
                      byte[] data,
                      EncryptedType type)
               throws java.security.InvalidKeyException
Description copied from class: DOMEncryptionMethod
encrypt the passed-in data with the specified key, using the underlying encryption algorithm and parameters.

Specified by:
encrypt in class DOMEncryptionMethod
Parameters:
key - the encryption key
data - the data bytes to be encrytped
Returns:
encrypted data
Throws:
java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc

wrap

public byte[] wrap(java.security.Key key,
                   java.security.Key toBeWrapped)
            throws java.security.InvalidKeyException,
                   javax.crypto.IllegalBlockSizeException
Description copied from class: DOMEncryptionMethod
encrypt the passed-in key with the specified key, using the underlying encryption algorithm and parameters.

Specified by:
wrap in class DOMEncryptionMethod
Parameters:
key - the encryption key
toBeWrapped - the key to be encrypted
Returns:
encrypted key
Throws:
java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc
javax.crypto.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size

unwrap

public byte[] unwrap(java.security.Key key,
                     byte[] encrypted)
              throws java.security.InvalidKeyException,
                     javax.crypto.BadPaddingException,
                     javax.crypto.IllegalBlockSizeException
Description copied from class: DOMEncryptionMethod
unwraps a previously wrapped key using the underlying encryption algorithm.

Specified by:
unwrap in class DOMEncryptionMethod
Parameters:
key - the decryption key
encrypted - the wrapped key to be unwrapped
Returns:
the unwrapped key as a byte[]
Throws:
java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc
javax.crypto.BadPaddingException - if unpadding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
javax.crypto.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size

unwrap

public java.security.Key unwrap(java.security.Key key,
                                byte[] encrypted,
                                AlgorithmMethod algo)
                         throws java.security.InvalidKeyException,
                                javax.crypto.BadPaddingException,
                                javax.crypto.IllegalBlockSizeException
Description copied from class: DOMEncryptionMethod
unwraps a previously wrapped key using the underlying encryption algorithm.

Specified by:
unwrap in class DOMEncryptionMethod
Parameters:
key - the decryption key
encrypted - the wrapped key to be unwrapped
algo - the algorithm of the decrypted key
Returns:
the unwrapped key
Throws:
java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc
javax.crypto.BadPaddingException - if unpadding has been requested, but the decrypted data is not bounded by the appropriate padding bytes
javax.crypto.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the total input length of the data processed by this cipher is not a multiple of block size

getCipher

public javax.crypto.Cipher getCipher(java.lang.String callingMethodName)
                              throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

XML Security, 1.6

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