|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.core.pbe.PBES2
This class is the main class for the passphrase based encryption scheme 2 as defined in PKCS #5 version 2.0 standard.
| Field Summary | |
static java.lang.String |
OID
The OID of PBES2. |
| Fields inherited from class de.flexiprovider.api.Cipher |
DECRYPT_MODE, ENCRYPT_MODE, opMode |
| Constructor Summary | |
PBES2()
|
|
| Method Summary | |
byte[] |
doFinal(byte[] input,
int inOff,
int inLen)
Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized). |
int |
doFinal(byte[] input,
int inOff,
int inLen,
byte[] output,
int outOff)
Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized). |
int |
getBlockSize()
Returns the block size (in bytes). |
byte[] |
getIV()
Returns the initialization vector (IV) in a new buffer. |
int |
getKeySize(Key key)
Return the key size of the given key object. |
java.lang.String |
getName()
Return the name of this cipher. |
int |
getOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes). |
AlgorithmParameterSpec |
getParameters()
Returns the parameters used with this cipher. |
void |
initDecrypt(Key key,
AlgorithmParameterSpec params)
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness. |
void |
initEncrypt(Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness. |
protected void |
setMode(java.lang.String modeName)
Set the mode for this cipher. |
protected void |
setPadding(java.lang.String paddingName)
Set the padding scheme for this cipher. |
byte[] |
update(byte[] input,
int inOff,
int inLen)
Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part. |
int |
update(byte[] input,
int inOff,
int inLen,
byte[] output,
int outOff)
Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part. |
| Methods inherited from class de.flexiprovider.api.Cipher |
doFinal, doFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, update |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final java.lang.String OID
| Constructor Detail |
public PBES2()
| Method Detail |
public java.lang.String getName()
getName in class Cipher
public int getKeySize(Key key)
throws InvalidKeyException
getKeySize in class Cipherkey - the key objectInvalidKeyException - if key is invalid.public int getBlockSize()
getBlockSize in class Cipherpublic byte[] getIV()
This is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.
getIV in class Cipherpublic int getOutputSize(int inputLen)
This call takes into account any unprocessed (buffered) data from a previous update call, and padding.
The actual output length of the next update or doFinal call may be smaller than the length returned by this method.
getOutputSize in class CipherinputLen - the input length (in bytes)public AlgorithmParameterSpec getParameters()
The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).
getParameters in class Cipher
public void initEncrypt(Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
The cipher is initialized for encryption.
If this cipher requires any algorithm parameters and params is null, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and raise an InvalidAlgorithmParameterException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).
If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.
Note that when a Cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it.
initEncrypt in class Cipherkey - the encryption keyparams - the algorithm parametersrandom - the source of randomnessInvalidKeyException - if the given key is inappropriate for initializing this
cipherInvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for
this cipher, or if this cipher is being initialized fro
decryption and requires algorithm parameters and params
is null
public void initDecrypt(Key key,
AlgorithmParameterSpec params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
The cipher is initialized for decryption.
If this cipher requires any algorithm parameters and params is null, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and raise an InvalidAlgorithmParameterException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).
If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random.
Note that when a Cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it.
initDecrypt in class Cipherkey - the encryption keyparams - the algorithm parametersInvalidKeyException - if the given key is inappropriate for initializing this
cipherInvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for
this cipher, or if this cipher is being initialized fro
decryption and requires algorithm parameters and params
is null
protected void setMode(java.lang.String modeName)
throws NoSuchModeException
setMode in class CiphermodeName - the name of the cipher modeNoSuchModeException - always.
protected void setPadding(java.lang.String paddingName)
throws NoSuchPaddingException
setPadding in class CipherpaddingName - the name of the padding schemeNoSuchPaddingException - always.
public byte[] update(byte[] input,
int inOff,
int inLen)
update in class Cipherinput - the input bufferinOff - the offset where the input startsinLen - the input length
public int update(byte[] input,
int inOff,
int inLen,
byte[] output,
int outOff)
throws ShortBufferException
update in class Cipherinput - the input bufferinOff - the offset where the input startsinLen - the input lengthoutput - the output bufferoutOff - the offset where the result is storedShortBufferException - if the output buffer is too small to hold the result.
public byte[] doFinal(byte[] input,
int inOff,
int inLen)
throws IllegalBlockSizeException,
BadPaddingException
doFinal in class Cipherinput - the input bufferinOff - the offset where the input startsinLen - the input lengthIllegalBlockSizeException - if the total input length is not a multiple of the block
size (for encryption when no padding is used or for
decryption).BadPaddingException - if unpadding fails.
public int doFinal(byte[] input,
int inOff,
int inLen,
byte[] output,
int outOff)
throws ShortBufferException,
IllegalBlockSizeException,
BadPaddingException
doFinal in class Cipherinput - the input bufferinOff - the offset where the input startsinLen - the input lengthoutput - the buffer for the resultoutOff - the offset where the result is storedShortBufferException - if the output buffer is too small to hold the result.IllegalBlockSizeException - if the total input length is not a multiple of the block
size (for encryption when no padding is used or for
decryption).BadPaddingException - if unpadding fails.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||