T - the concrete type of this object.public abstract class AbstractAlgorithmParameters<T extends AbstractAlgorithmParameters<T>> extends Object implements AlgorithmParameters<T>
| Modifier and Type | Field and Description |
|---|---|
static int |
KEY_SIZE_128
128-bit key size.
|
static int |
KEY_SIZE_192
192-bit key size (not available in all jurisdictions).
|
static int |
KEY_SIZE_256
256-bit key size (not available in all jurisdictions).
|
static String |
MAC_ALGORITHM_HMAC_MD5
The HMAC-MD5 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for Message
Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA1
The HMAC-SHA1 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA224
The HMAC-SHA224 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA256
The HMAC-SHA256 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA3_224
The HMAC-SHA3-224 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA3_256
The HMAC-SHA3-256 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA3_384
The HMAC-SHA3-384 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA3_512
The HMAC-SHA3-512 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA384
The HMAC-SHA384 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA512
The HMAC-SHA512 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA512_224
The HMAC-SHA512/224 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static String |
MAC_ALGORITHM_HMAC_SHA512_256
The HMAC-SHA512/256 keyed-hashing algorithm as defined in RFC 2104: "HMAC: Keyed-Hashing for
Message Authentication" (February 1997).
|
static int |
MAC_KEY_SIZE_128
128-bit MAC key size (Suggested minimum key size for HmacMD5).
|
static int |
MAC_KEY_SIZE_160
160-bit MAC key size (Suggested minimum key size for HmacSHA1).
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractAlgorithmParameters()
Initializes the AbstractAlgorithmParameters.
|
protected |
AbstractAlgorithmParameters(TextEncoder textEncoder)
Initializes the AbstractAlgorithmParameters with a
TextEncoder. |
| Modifier and Type | Method and Description |
|---|---|
AlgorithmParameterSpec |
createParameterSpec(byte[] parameterData)
Generates an algorithm-specific
AlgorithmParameterSpec object used to hold algorithm
parameters such as an initialization vector or salt. |
byte[] |
generateParameterSpecData()
Generates a byte array which holds algorithm parameters such as an initialization vector or
salt.
|
String |
getAlgorithm()
Returns the algorithm value.
|
Key |
getDecryptionKey()
Returns the key used for decryption.
|
protected abstract String |
getDefaultAlgorithm()
Returns the defaultAlgorithm.
|
protected int |
getDefaultKeySize()
Returns the defaultKeySize.
|
Key |
getEncryptionKey()
Returns the key used for encryption.
|
int |
getKeySize()
Returns the size of the key to be generated in bits.
|
String |
getMacAlgorithm()
Returns the macAlgorithm value.
|
Key |
getMacKey()
Returns the macKey.
|
int |
getMacKeySize()
Returns the size of the MAC key to be generated in bits.
|
Provider |
getProvider()
Returns the Java Security Provider.
|
String |
getProviderName()
Returns the Java Security Provider name.
|
protected boolean |
hasDecryptionKey()
Returns true if this instance has a loaded decryptionKey.
|
protected boolean |
hasEncryptionKey()
Returns true if this instance has a loaded encryptionKey.
|
protected abstract Key |
loadKey(byte[] rawKey,
KeyLoader keyLoader,
String algorithm)
Loads a key from the given possible key sources.
|
protected byte[] |
parseAndVerifySalt(byte[] messageData)
Separates and returns the algorithm spec data or salt from the enciphered message.
|
protected T |
setAlgorithm(String algorithm)
Sets the algorithm value.
|
protected T |
setDecryptionKey(byte[] decryptionKey)
Sets the raw byte array of the decryption key.
|
protected T |
setDecryptionKey(Key decryptionKey)
Sets the decryption key.
|
protected T |
setDecryptionKey(String decryptionKey)
Sets the decryption key.
|
protected T |
setDecryptionKeyLoader(Object decryptionKeyLoader)
Sets the
KeyLoader, which is used to load the decryption key. |
protected T |
setEncryptionKey(byte[] encryptionKey)
Sets the raw byte array of the encryption key.
|
protected T |
setEncryptionKey(Key encryptionKey)
Sets the encryption key.
|
protected T |
setEncryptionKey(String encryptionKey)
Sets the encryption key.
|
protected T |
setEncryptionKeyLoader(Object encryptionKeyLoader)
Sets the
KeyLoader, which is used to load the encryption key. |
T |
setKeySize(int keySize)
Sets the size of the key in bits to be generated during initialization.
|
T |
setMacAlgorithm(String macAlgorithm)
Sets the macAlgorithm value.
|
T |
setMacKey(byte[] macKey)
Sets the raw byte array of the MAC key.
|
T |
setMacKey(Key macKey)
Sets the macKey.
|
T |
setMacKey(String macKey)
Sets the macKey.
|
T |
setMacKeyLoader(Object macKeyLoader)
Sets the
KeyLoader, which is used to load the cipher key for the MAC. |
T |
setMacKeySize(int macKeySize)
Sets the size of the MAC key in bits to be generated during initialization.
|
T |
setProvider(Provider provider)
Sets the Java Security Provider.
|
T |
setProviderName(String providerName)
Sets the Java Security Provider name.
|
T |
setSaltGenerator(SaltGenerator saltGenerator)
Sets the
SaltGenerator, which allows for custom salt data generation. |
T |
setSaltMatcher(SaltMatcher saltMatcher)
Sets the
SaltMatcher, which may be used to verify the salt within the cipher text matches some
expected value. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetParameterSpec, getParameterSpecSize, getTransformationpublic static final int KEY_SIZE_128
public static final int KEY_SIZE_192
public static final int KEY_SIZE_256
public static final int MAC_KEY_SIZE_128
public static final int MAC_KEY_SIZE_160
public static final String MAC_ALGORITHM_HMAC_MD5
public static final String MAC_ALGORITHM_HMAC_SHA1
public static final String MAC_ALGORITHM_HMAC_SHA224
public static final String MAC_ALGORITHM_HMAC_SHA256
public static final String MAC_ALGORITHM_HMAC_SHA384
public static final String MAC_ALGORITHM_HMAC_SHA512
public static final String MAC_ALGORITHM_HMAC_SHA512_224
public static final String MAC_ALGORITHM_HMAC_SHA512_256
public static final String MAC_ALGORITHM_HMAC_SHA3_224
public static final String MAC_ALGORITHM_HMAC_SHA3_256
public static final String MAC_ALGORITHM_HMAC_SHA3_384
public static final String MAC_ALGORITHM_HMAC_SHA3_512
protected AbstractAlgorithmParameters()
protected AbstractAlgorithmParameters(TextEncoder textEncoder)
TextEncoder.textEncoder - the TextEncoderprotected abstract String getDefaultAlgorithm()
protected int getDefaultKeySize()
public int getKeySize()
getKeySize in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>public T setKeySize(int keySize)
setKeySize in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>keySize - The keySize to set.protected abstract Key loadKey(byte[] rawKey, KeyLoader keyLoader, String algorithm) throws GeneralSecurityException
rawKey - the raw key bytes (may be null)keyLoader - the keyLoader (may be null)algorithm - the algorithm for the keyGeneralSecurityException - GeneralSecurityExceptionpublic Key getEncryptionKey() throws GeneralSecurityException
getEncryptionKey in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>GeneralSecurityException - GeneralSecurityExceptionprotected boolean hasDecryptionKey()
protected T setEncryptionKey(byte[] encryptionKey)
encryptionKey - The encryptionKey to set.protected T setEncryptionKey(String encryptionKey)
encryptionKey - The encryptionKey to set.protected T setEncryptionKey(Key encryptionKey)
encryptionKey - The encryptionKey to set.protected T setEncryptionKeyLoader(Object encryptionKeyLoader)
KeyLoader, which is used to load the encryption key. The value may either be the
full class name of a KeyLoader implementation or an actual KeyLoader
instance.encryptionKeyLoader - The encryptionKeyLoader to set.public Key getDecryptionKey() throws GeneralSecurityException
getDecryptionKey in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>GeneralSecurityException - GeneralSecurityExceptionprotected boolean hasEncryptionKey()
protected T setDecryptionKey(byte[] decryptionKey)
decryptionKey - The decryptionKey to set.protected T setDecryptionKey(String decryptionKey)
decryptionKey - The decryptionKey to set.protected T setDecryptionKey(Key decryptionKey)
decryptionKey - The decryptionKey to set.protected T setDecryptionKeyLoader(Object decryptionKeyLoader)
KeyLoader, which is used to load the decryption key. The value may either be the
full class name of a KeyLoader implementation or an actual KeyLoader
instance.decryptionKeyLoader - The decryptionKeyLoader to set.public String getAlgorithm()
getAlgorithm in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>protected T setAlgorithm(String algorithm)
algorithm - The algorithm to set.public byte[] generateParameterSpecData()
generateParameterSpecData in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>public AlgorithmParameterSpec createParameterSpec(byte[] parameterData)
AlgorithmParameterSpec object used to hold algorithm
parameters such as an initialization vector or salt.createParameterSpec in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>parameterData - the data for the AlgorithmParameterSpecAlgorithmParameterSpec objectpublic int getMacKeySize()
getMacKeySize in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>public T setMacKeySize(int macKeySize)
setMacKeySize in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>macKeySize - The macKeySize to set.public Key getMacKey() throws GeneralSecurityException
getMacKey in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>GeneralSecurityException - GeneralSecurityExceptionpublic T setMacKey(byte[] macKey)
setMacKey in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>macKey - The macKey to set.public T setMacKey(String macKey)
setMacKey in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>macKey - The macKey to set.public T setMacKey(Key macKey)
setMacKey in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>macKey - The macKey to set.public String getMacAlgorithm()
getMacAlgorithm in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>public T setMacAlgorithm(String macAlgorithm)
setMacAlgorithm in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>macAlgorithm - The macAlgorithm to set.public String getProviderName()
getProviderName in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>public T setProviderName(String providerName)
setProviderName in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>providerName - The providerName to set.public Provider getProvider()
getProvider in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>public T setProvider(Provider provider)
setProvider in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>provider - The provider to set.public T setMacKeyLoader(Object macKeyLoader)
KeyLoader, which is used to load the cipher key for the MAC. The value may
either be the full class name of a KeyLoader implementation or an actual
KeyLoader instance.setMacKeyLoader in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>macKeyLoader - The macKeyLoader to set.public T setSaltGenerator(SaltGenerator saltGenerator)
SaltGenerator, which allows for custom salt data generation.setSaltGenerator in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>saltGenerator - the saltGenerator to setpublic T setSaltMatcher(SaltMatcher saltMatcher)
SaltMatcher, which may be used to verify the salt within the cipher text matches some
expected value.setSaltMatcher in interface AlgorithmParameters<T extends AbstractAlgorithmParameters<T>>saltMatcher - the saltMatcher to setprotected byte[] parseAndVerifySalt(byte[] messageData)
throws GeneralSecurityException
SaltMatcher if one exists.messageData - the enciphered messageGeneralSecurityException - if an error occurs when verifying a salt match (if one exists)