public abstract class DOFCipher
extends java.lang.Object
DOFCipher.Factory
implementation to provide a custom implementation of
encryption. All encryption and decryption is handled as a single block at a time (of the cipher's block size).Modifier and Type | Class and Description |
---|---|
static class |
DOFCipher.Algorithm
Block Cipher Algorithms.
|
static interface |
DOFCipher.Factory
The factory definition for creating a DOFCipher.
|
static class |
DOFCipher.Strength
The strength of the encryption.
|
Constructor and Description |
---|
DOFCipher() |
Modifier and Type | Method and Description |
---|---|
static void |
addFactory(DOFCipher.Algorithm algorithm,
DOFCipher.Strength strength,
DOFCipher.Factory factory)
Add a block cipher factory to the library.
|
static DOFCipher |
create(DOFCipher.Algorithm algorithm,
DOFCipher.Strength strength,
byte[] key)
Create a block cipher for the given algorithm, strength, and key.
|
abstract byte[] |
decrypt(byte[] ciphertext)
Decrypt a block of data.
|
abstract byte[] |
encrypt(byte[] plaintext)
Encrypt a block of data.
|
abstract int |
getBlockSize()
The required block size for this cipher algorithm.
|
public abstract int getBlockSize()
public abstract byte[] encrypt(byte[] plaintext) throws DOFSecurityException
getBlockSize()
).plaintext
- The buffer containing the plaintext block to be encrypted. Must not be null.DOFSecurityException
- If the plaintext can not be encrypted.public abstract byte[] decrypt(byte[] ciphertext) throws DOFSecurityException
getBlockSize()
).ciphertext
- The buffer containing the ciphertext block to be decrypted. Must not be null.DOFSecurityException
- If the ciphertext can not be decrypted.public static void addFactory(DOFCipher.Algorithm algorithm, DOFCipher.Strength strength, DOFCipher.Factory factory) throws DOFSecurityException
algorithm
- The recognized algorithm to be registered; refer to DOFCipher.Algorithm
.strength
- The strength of the encryption.factory
- The block cipher factory implementation; refer to DOFCipher.Factory
.DOFSecurityException
- if the cipher could not be added. This may occur for a number of reasons, including:
public static DOFCipher create(DOFCipher.Algorithm algorithm, DOFCipher.Strength strength, byte[] key) throws DOFSecurityException
algorithm
- The recognized algorithm.strength
- The security strength as defined by the DOF Technical Committee.key
- The 32-byte key for this cipher.DOFSecurityException
- If the cipher can not be created.