de.flexiprovider.core.rsa
Class UnlimitedLengthRSA
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.AsymmetricBlockCipher
|
+--de.flexiprovider.core.rsa.RSA_PKCS1_v1_5
|
+--de.flexiprovider.core.rsa.UnlimitedLengthRSA
- public class UnlimitedLengthRSA
- extends RSA_PKCS1_v1_5
Implements the PKCS1v5 RSA as a cipher with unlimited length for plaintexts and ciphertexts.
First it truncates a big message to smaller messages that can be processed by a standard RSA encryption.
This depends also on the key size. For example for a 1024 bits key only up to 117 (128-11) bytes can be en/decrypted.
Upon an input of 304 bytes, first three submessages are created. The first one is 70 (304-2*117) bytes long and the other two 117.
Each message is encrypted with a normal PKCS1v5 RSA encryption. The ciphertext is 384 (3*128) bytes long. This is also truncated
to three messages of 128 bytes which are also decrypted by a normal RSA operation.
- Author:
- Michael Gaber
|
Field Summary |
static java.lang.String |
NAME
|
|
Method Summary |
protected void |
checkLength(int inLength)
Checks whether the plaintext or the ciphertext have correct sizes. |
java.lang.String |
getName()
Return the name of the encrpytion algorithm. |
protected byte[] |
messageDecrypt(byte[] input)
Decrypts this message of unlimited length. |
protected byte[] |
messageEncrypt(byte[] input)
Encrypts this message of unlimited length. |
| Methods inherited from class de.flexiprovider.api.AsymmetricBlockCipher |
doFinal, doFinal, getBlockSize, getIV, getOutputSize, getParameters, initDecrypt, initDecrypt, initEncrypt, initEncrypt, initEncrypt, initEncrypt, setMode, setPadding, update, update |
| 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 |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NAME
public static final java.lang.String NAME
UnlimitedLengthRSA
public UnlimitedLengthRSA()
messageDecrypt
protected byte[] messageDecrypt(byte[] input)
throws IllegalBlockSizeException,
BadPaddingException
- Decrypts this message of unlimited length. The length of the message however still needs to
be a multiple of a normal RSA to-be-decrypted message.
- Overrides:
messageDecrypt in class RSA_PKCS1_v1_5
- Returns:
- the decrypted message.
messageEncrypt
protected byte[] messageEncrypt(byte[] input)
throws BadPaddingException
- Encrypts this message of unlimited length.
- Overrides:
messageEncrypt in class RSA_PKCS1_v1_5
- Returns:
- the ciphertext message.
getName
public java.lang.String getName()
- Return the name of the encrpytion algorithm.
- Overrides:
getName in class RSA_PKCS1_v1_5
- Returns:
- the name of the encryption algorithm.
checkLength
protected void checkLength(int inLength)
throws IllegalBlockSizeException
- Checks whether the plaintext or the ciphertext have correct sizes. While for plaintexts there are no restrictions, the ciphertext
must be a multiple of a normal RSA to-be-decrypted message.
- Overrides:
checkLength in class AsymmetricBlockCipher
- Following copied from class:
de.flexiprovider.api.AsymmetricBlockCipher
- Parameters:
inLen - length of the input to check- Throws:
IllegalBlockSizeException - if the input length is invalid.