question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

javax.crypto.BadPaddingException: Decryption error on Android

See original GitHub issue

This happens if i connect from Android to an 1.12.2 Server (Vanilla and Spigot). I am logged in and i get disconnected because “Connection closed.”, the Server gives this Stacktrace:

[11:15:23 WARN]: javax.crypto.BadPaddingException: Decryption error [11:15:23 WARN]: at sun.security.rsa.RSAPadding.unpadV15(Unknown Source) [11:15:23 WARN]: at sun.security.rsa.RSAPadding.unpad(Unknown Source) [11:15:23 WARN]: at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:363) [11:15:23 WARN]: at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:389) [11:15:23 WARN]: at javax.crypto.Cipher.doFinal(Cipher.java:2164) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.MinecraftEncryption.a(SourceFile:117) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.MinecraftEncryption.b(SourceFile:112) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.PacketLoginInEncryptionBegin.b(SourceFile:50) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.LoginListener.a(LoginListener.java:203) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.PacketLoginInEncryptionBegin.a(SourceFile:39) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.PacketLoginInEncryptionBegin.a(SourceFile:12) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:126) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.NetworkManager.channelRead0(NetworkManager.java:330) [11:15:23 WARN]: at net.minecraft.server.v1_12_R1.NetworkManager.channelRead0(NetworkManager.java:1) [11:15:23 WARN]: at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [11:15:23 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [11:15:23 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [11:15:23 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [11:15:23 WARN]: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [11:15:23 WARN]: at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [11:15:23 WARN]: at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [11:15:23 WARN]: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [11:15:23 WARN]: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [11:15:23 WARN]: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [11:15:23 WARN]: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) [11:15:23 WARN]: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) [11:15:23 WARN]: at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) [11:15:23 WARN]: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [11:15:23 WARN]: at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [11:15:23 WARN]: at java.lang.Thread.run(Unknown Source) [11:15:23 ERROR]: Cipher data failed! [11:15:23 INFO]: com.mojang.authlib.GameProfile@56fa3948[id=<null>,name=ThisIsNotMyRealName,properties={},legacy=false] (/192.168.0.109:36941) lost connection: Internal Exception: java.lang.IllegalStateException: Invalid nonce!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Steveice10commented, Sep 6, 2018

Very sorry, apparently I’ve been trying to test it in offline mode this whole time… It should work now. At the very least, it definitely works with OpenJDK now; I don’t have an Android app set up to test with.

1reaction
0-x-2-2commented, Sep 5, 2018

Can you send the code you are using and what version of java you are running under.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BadPaddingException decrypting the encrypted data in Android
Encryption seems to be doesn't have any problem, but when I try to decrypt it, it throws: javax.crypto.BadPaddingException: error:0407106B:rsa ...
Read more >
BadPaddingException - Android Developers
javax.crypto.interfaces ... BadPaddingException; BadPaddingException ... Prints this throwable and its backtrace to the standard error stream.
Read more >
javax.crypto.BadPaddingException: Decryption error on Android
This happens if i connect from Android to an 1.12.2 Server (Vanilla and Spigot). I am logged in and i get disconnected because...
Read more >
javax.crypto.BadPaddingException — Analyzing related root ...
Exception in thread “main” javax.crypto.BadPaddingException: Decryption error at sun.security.rsa.RSAPadding.unpadOAEP(RSAPadding.java:499)
Read more >
AES Encryption Error: BadPaddingException : r/java - Reddit
NoSuchAlgorithmException; import javax.crypto. ... send = send.substring(16); Cipher decCipher; byte[] decrypted = null; decCipher = Cipher.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found