Discussion:
OpenJDK: javax.crypto.IllegalBlockSizeException
David McReynolds
2014-08-15 13:15:31 UTC
Permalink
I am posting this on behalf of a friend. He is using RedHat and the
OpenJDK. The encryption seems to work, but he is getting an error during
the decryption.

Caused by: javax.crypto.IllegalBlockSizeException: last block incomplete in
decryption
at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(Unknown
Source)
at javax.crypto.Cipher.doFinal(Cipher.java:1813)

I think it is worth mentioning that they error does not occur when running
the same code under an Oracle JVM.

I was just wondering if there was a known issue.

============================
Here's how he is trying to decrypt.

var decryptedString : String = null

try {
if (encryptedText != null) {
var encryptedBytes : byte[] = new
sun.misc.BASE64Decoder().decodeBuffer(encryptedText)
_cipher.get().init(Cipher.DECRYPT_MODE, _keySpec, _ivSpec)
var decrypted : byte[] = _cipher.get().doFinal(encryptedBytes)
decryptedString = new String(decrypted, "UTF8")
}
} catch (ikExc : InvalidKeyException) {
throw ikExc
} catch (iapExc : InvalidAlgorithmParameterException) {
throw iapExc
} catch (ibsExc : IllegalBlockSizeException) {
throw ibsExc
} catch (bpExc : BadPaddingException) {
throw bpExc
}
return decryptedString
--
--------------
*Mi aerodeslizador está lleno de anguilas.*
David Hook
2014-08-16 02:46:10 UTC
Permalink
No, there is no known issue here. BC also does get used on a wide
variety of JVMs so if it was that simple I would have expected one of us
would have hear about it by now. Have they checked that encrypted text
is really correct and what it is expected to be?

Regards,

David
Post by David McReynolds
I am posting this on behalf of a friend. He is using RedHat and the
OpenJDK. The encryption seems to work, but he is getting an error
during the decryption.
Caused by: javax.crypto.IllegalBlockSizeException: last block
incomplete in decryption
at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(Unknown
Source)
at javax.crypto.Cipher.doFinal(Cipher.java:1813)
I think it is worth mentioning that they error does not occur when
running the same code under an Oracle JVM.
I was just wondering if there was a known issue.
============================
Here's how he is trying to decrypt.
var decryptedString : String = null
try {
if (encryptedText != null) {
var encryptedBytes : byte[] = new
sun.misc.BASE64Decoder().decodeBuffer(encryptedText)
_cipher.get().init(Cipher.DECRYPT_MODE, _keySpec, _ivSpec)
var decrypted : byte[] = _cipher.get().doFinal(encryptedBytes)
decryptedString = new String(decrypted, "UTF8")
}
} catch (ikExc : InvalidKeyException) {
throw ikExc
} catch (iapExc : InvalidAlgorithmParameterException) {
throw iapExc
} catch (ibsExc : IllegalBlockSizeException) {
throw ibsExc
} catch (bpExc : BadPaddingException) {
throw bpExc
}
return decryptedString
--
--------------
/Mi aerodeslizador está lleno de anguilas./
David McReynolds
2014-08-17 15:11:46 UTC
Permalink
Thank's. Yeah, something is off. It's difficult because they are in OK and
I'm in GA but they gave me their code and I ran created a junit test on
Debian under OpenJDK 7 and it ran with no issues (they are RH and openjdk
6). Anyway, they changed something. I am going to ask for another snapshot
of their code and see what they changed.
No, there is no known issue here. BC also does get used on a wide variety
of JVMs so if it was that simple I would have expected one of us would have
hear about it by now. Have they checked that encrypted text is really
correct and what it is expected to be?
Regards,
David
I am posting this on behalf of a friend. He is using RedHat and the
OpenJDK. The encryption seems to work, but he is getting an error during
the decryption.
Caused by: javax.crypto.IllegalBlockSizeException: last block incomplete
in decryption
at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(Unknown
Source)
at javax.crypto.Cipher.doFinal(Cipher.java:1813)
I think it is worth mentioning that they error does not occur when
running the same code under an Oracle JVM.
I was just wondering if there was a known issue.
============================
Here's how he is trying to decrypt.
var decryptedString : String = null
try {
if (encryptedText != null) {
var encryptedBytes : byte[] = new
sun.misc.BASE64Decoder().decodeBuffer(encryptedText)
_cipher.get().init(Cipher.DECRYPT_MODE, _keySpec, _ivSpec)
var decrypted : byte[] = _cipher.get().doFinal(encryptedBytes)
decryptedString = new String(decrypted, "UTF8")
}
} catch (ikExc : InvalidKeyException) {
throw ikExc
} catch (iapExc : InvalidAlgorithmParameterException) {
throw iapExc
} catch (ibsExc : IllegalBlockSizeException) {
throw ibsExc
} catch (bpExc : BadPaddingException) {
throw bpExc
}
return decryptedString
--
--------------
*Mi aerodeslizador está lleno de anguilas.*
--
--------------
*Mi aerodeslizador está lleno de anguilas.*
Loading...