resolve darcs stupidity
[org.ibex.core.git] / src / org / bouncycastle / crypto / engines / RSAEngine.java
index 2cbac54..0aaee2d 100644 (file)
@@ -5,7 +5,6 @@ import java.math.BigInteger;
 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;
 
@@ -21,7 +20,7 @@ public class RSAEngine
     /**
      * 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(
@@ -45,12 +44,7 @@ public class RSAEngine
 
         if (forEncryption)
         {
-            if ((bitSize % 8) == 0)
-            {
-                return bitSize / 8 - 1;
-            }
-
-            return bitSize / 8;
+            return (bitSize + 7) / 8 - 1;
         }
         else
         {
@@ -63,7 +57,7 @@ public class RSAEngine
      * 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()
     {
@@ -71,11 +65,11 @@ public class RSAEngine
 
         if (forEncryption)
         {
-            return ((bitSize - 1) + 7) / 8;
+            return (bitSize + 7) / 8;
         }
         else
         {
-            return (bitSize - 7) / 8;
+            return (bitSize + 7) / 8 - 1;
         }
     }