modLen_, opMode_, PADDING_NONE, PADDING_OAEP, PADDING_PKCS1, PADDING_PKCS1_SSL2, privateKey_, publicKey_
Constructor and Description |
---|
PKCS1v15Padding(java.lang.String paddingName,
java.lang.String transformationMode)
Creates a PKCS#1v1.5 Padding object with given padding name and
transformationMode.
|
Modifier and Type | Method and Description |
---|---|
java.security.AlgorithmParameters |
getParameters()
Returns
null since no parameters are used. |
void |
init(int paddingMode,
java.security.Key key,
int modLen,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes this Padding engine.
|
byte[] |
pad(byte[] data)
Pads the supplied data according to PKCS#1v1.5.
|
byte[] |
unpad(byte[] paddedData)
Unpads the supplied padded data according to PKCS#1v1.5.
|
public PKCS1v15Padding(java.lang.String paddingName, java.lang.String transformationMode) throws javax.crypto.NoSuchPaddingException
The transformationMode is the "mode" specification of the transformation string that has to be specified when instantiating a Cipher object. For RSA Ciphers that use PKCS#1v1.5 padding the mode name may be "ECB", "NONE" or the blockType number (0, 1, or 2), e.g.:
Cipher.getInstance("RSA/ECB/PKCS1Padding");or
Cipher.getInstance("RSA/bt/PKCS1Padding");where
bt
is 0, 1 or 2. paddingName
- the name of the padding scheme ("PKCS1Padding" or
"PKCS1PaddingSSL2")transformationMode
- the transformation mode name ("ECB", "NONE" or "0", "1" or "2")javax.crypto.NoSuchPaddingException
- if the transformationMode is not "ECB" or "NONE" but specifies
an illegal block typepublic void init(int paddingMode, java.security.Key key, int modLen, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
init
in class Padding
paddingMode
- the padding mode, either PAD_MODE (1)
or
UNPAD_MODE (2)
key
- the RSA en/decryption key; used for checking block type
conformancemodLen
- the length of the key modulusparams
- parameters; ignored since not required for PKCS#1v1.5 paddingrandom
- generator supplying random numbers if requiredjava.security.InvalidKeyException
- if the key does not match to the padding block typejava.security.InvalidAlgorithmParameterException
- if the parameters are invalid, or the padding Mode is invalid
(not PAD_MODE (1)
or
UNPAD_MODE (2)
, or SSL2 padding
variant is requested in UNPAD mode which is not supportedpublic java.security.AlgorithmParameters getParameters()
null
since no parameters are used.getParameters
in class Padding
public byte[] pad(byte[] data) throws javax.crypto.BadPaddingException
public byte[] unpad(byte[] paddedData) throws javax.crypto.BadPaddingException
paddedData
input array maybe changed
after calling this method.