public interface EncryptionAlgorithm
The application does not normally need to use this interface because the Toolkit already contains classes that implement it.
The following symmetric algorithms are supported:
The following asymmetric algorithms are supported:
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] toBeDecrypted)
Decrypts a byte array.
|
byte[] |
encrypt(byte[] toBeEncrypted)
Encrypts a byte array.
|
byte[] |
getEncoded()
Retrieves the encoded symmetric key associated with this
EncryptionAlgorithm. |
java.lang.String |
getIVparameters()
Retrieves a Base 64 encoding of the initialization vector that was
used at the most recent invocation of
initEncrypt() or
initDecrypt(). |
URI |
getURI()
Retrieves the algorithm identifier, which is a URI.
|
void |
initDecrypt(byte[] keyBytes,
byte[] iv)
Initializes the
EncryptionAlgorithm for decrypting. |
void |
initEncrypt()
Initializes the
EncryptionAlgorithm for encrypting a DOM element or
a set of DOM elements. |
void |
setPrivateKey(java.security.PrivateKey decryptionKey)
Sets a private key for decrypting an <EncryptedKey> element.
|
void |
setPublicKey(java.security.PublicKey encryptionKey)
Sets a public key for encrypting an <EncryptedKey> element.
|
void |
setURI(URI uri)
Sets the algorithm identifier, which is a URI.
|
URI getURI()
XMLEConstants.ALGORITHM_RSA,
XMLEConstants.ALGORITHM_RSA_OAEP,
XMLEConstants.ALGORITHM_3DES,
XMLEConstants.ALGORITHM_AES_256,
XMLEConstants.ALGORITHM_AES_192,
XMLEConstants.ALGORITHM_AES_128void setURI(URI uri) throws EncryptionAlgorithmException
uri - a URI reference that identifies the algorithm.EncryptionAlgorithmExceptionXMLEConstants.ALGORITHM_RSA,
XMLEConstants.ALGORITHM_RSA_OAEP,
XMLEConstants.ALGORITHM_3DES,
XMLEConstants.ALGORITHM_AES_256,
XMLEConstants.ALGORITHM_AES_192,
XMLEConstants.ALGORITHM_AES_128byte[] getEncoded()
EncryptionAlgorithm.
If the implementation is a public key algorithm, returns null. Used internally by XMLE to encrypt the symmetric key with a public key.
SecretKey associated with this EncryptionAlgorithm.void initEncrypt()
throws EncryptionAlgorithmException
EncryptionAlgorithm for encrypting a DOM element or
a set of DOM elements.
Generates fresh secret key material for each set of elements, and generates a fresh random initialization vector for each element in the set.
Applies only to symmetric algorithms; for asymmetric algorithms, does nothing.
EncryptionAlgorithmExceptionvoid initDecrypt(byte[] keyBytes,
byte[] iv)
throws EncryptionAlgorithmException
EncryptionAlgorithm for decrypting.
Applies only to symmetric algorithms.
keyBytes - the key material for a secret keyiv - initialization vector to be used in the decryption operationEncryptionAlgorithmExceptionvoid setPrivateKey(java.security.PrivateKey decryptionKey)
throws EncryptionAlgorithmException
decryptionKey - the private decryption keyEncryptionAlgorithmExceptionPrivateKeyvoid setPublicKey(java.security.PublicKey encryptionKey)
throws EncryptionAlgorithmException
EncryptionAlgorithmExceptionPublicKeybyte[] encrypt(byte[] toBeEncrypted)
throws EncryptionAlgorithmException
toBeEncrypted - a byte[] containing plaintext to be encryptedEncryptionAlgorithmExceptionbyte[] decrypt(byte[] toBeDecrypted)
throws EncryptionAlgorithmException
toBeDecrypted - a byte[] containing data to be decryptedEncryptionAlgorithmExceptionjava.lang.String getIVparameters()
throws EncryptionAlgorithmException
initEncrypt() or
initDecrypt().String containing the initialization vectorEncryptionAlgorithmException