import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.AsymmetricBlockCipher;
-import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.crypto.params.RSAKeyParameters;
import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
/**
* initialise the RSA engine.
*
- * @param forEncryption treu if we are encrypting, false otherwise.
+ * @param forEncryption true if we are encrypting, false otherwise.
* @param param the necessary RSA key parameters.
*/
public void init(
if (forEncryption)
{
- if ((bitSize % 8) == 0)
- {
- return bitSize / 8 - 1;
- }
-
- return bitSize / 8;
+ return (bitSize + 7) / 8 - 1;
}
else
{
* For RSA this is always one byte less than the key size on
* decryption, and the same length as the key size on encryption.
*
- * @return maximum size for an input block.
+ * @return maximum size for an output block.
*/
public int getOutputBlockSize()
{
if (forEncryption)
{
- return ((bitSize - 1) + 7) / 8;
+ return (bitSize + 7) / 8;
}
else
{
- return (bitSize - 7) / 8;
+ return (bitSize + 7) / 8 - 1;
}
}