`
lg70124752
  • 浏览: 59753 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Input length must be multiple of 8 when decrypting with padded cipher

    博客分类:
  • java
阅读更多
java.lang.RuntimeException: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.checkGeo(BlobExtHandler.java:399)
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.processEvent(BlobExtHandler.java:232)
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.getEvents(BlobExtHandler.java:140)
        at us.pinguo.flume.hdfs.ext.source.HTTPSource$FlumeHTTPServlet.doPost(HTTPSource.java:252)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:767)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:750)
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
        at com.sun.crypto.provider.DESCipher.engineDoFinal(DESCipher.java:314)
        at javax.crypto.Cipher.doFinal(Cipher.java:2087)
        at us.pinguo.flume.hdfs.ext.utils.DES.decryptDES(DES.java:49)
        at us.pinguo.flume.hdfs.ext.utils.DESHelperV2.decryptDESBase64(DESHelperV2.java:96)
        at us.pinguo.flume.hdfs.ext.source.BlobExtHandler.checkGeo(BlobExtHandler.java:386)
        ... 19 more



解决方案
you are calling doFinal multiple times. or at least trying to.

when you read data, not all data arrives or is read into the buffer at once. so you decrypt some and then read again. that is all ok.

but when you do that, you are calling doFinal each time, instead of update. this is wrong and is the cause of the error. instead, replace doFinal with update and then add an extra doFinal once you have finished reading all data (there is a doFinal() that takes no arguments for exactly this reason).

see http://docs.oracle.com/javase/7/docs/api/javax/crypto/Cipher.html

also see http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_.28ECB.29 for why ecb mode is often not a good idea (look at the penguin pictures).
分享到:
评论

相关推荐

    Kotlin Base64编解码类

    Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher at java.base/...

    JCEPolicyJDK8.zip

    当环境为jdk1.8.0_191之前的版本时,使用jdk自带的AES256...Input length must be multiple of 16 when decrypting with padded cipher,可通过将此附件解压后复制jar包到jre\lib\security 目录进行覆盖,即可解决。

    Hacking.Secret.Ciphers.with.Python.B00WOY87ZU

    Chapter 8 - Encrypting with the Transposition Cipher Chapter 9 - Decrypting with the Transposition Cipher Chapter 10 - Programming a Program to Test Our Program Chapter 11 - Encrypting and Decrypting ...

    aaes.zip_Adopted

    AES is based on the Rijndael cipher developed by two Belgian cryptographers, Joan Daemen and Vincent Rijmen, who submitted a proposal to NIST during the AES selection process. Rijndael is a family of ...

    NIST SP800-21.pdf

    Today’s information technology security environment consists of highly interactive and powerful computing devices and interconnected systems of systems across global networks where Federal agencies ...

    DumpXor_decrypting_XOR_friendexe_Known_

    Program for decrypting a dump using a known xor

    LockBox2.5

    This version of LockBox has been updated so that it can be used with Tiburon. Creating a version of LockBox that is compatible with Tiburon is not very difficult. All that needed to be done was ...

    Wireshark.for.Security.pdf

    In addition to following along with the labs you will be challenged with end-of-chapter exercises to expand on covered material. Lastly, this book explores Wireshark with Lua, the light-weight ...

    Encrypting and decrypting sensitive data using CryptoAPI. (6

    Encrypting and decrypting sensitive data using CryptoAPI. (6KB)

    2018年8月arrow病毒解码工具

    download this file, and add it to white list in your antivirus 6) run this application WITH ADMINISTRATOR RIGHTS 7) scan local machine (don't move your files - this may compromise the integrity of the...

    python-xtea.tar.gz_The Chain_block_block chain_encryption_xtea

    Python implementation of the XTEA Block Encryption Algorithm. Also includes a CBC decrypt function for decrypting Cipher Block Chain mode encrypted ciphertext.

    Hack Proofing Your Network, Second Edition

    · The Politics, Laws of Security, Classes of Attack, Methodology, Diffing, Decrypting, Brute Force, Unexpected Input, Buffer Overrun, Sniffing, Session Hijacking, Spoofing, Server Holes, Client ...

    信息安全_数据安全_DPAPI_and_DPAPI-NG:Decrypting_Al.pdf

    信息安全_数据安全_DPAPI_and_DPAPI-NG:Decrypting_Al 安全建设 漏洞分析 可信编译 威胁情报 大数据

    ScienceDecrypting

    SD

    Android代码-whorlwind

    Whorlwind A reactive wrapper around Android's fingerprint API that handles encrypting/decrypting sensitive ...keyAlias is used when generating a key pair in the KeyStore and should not be shared with an

    Visual C++ 编程资源大全(英文源码 其它)

    in converts the text format (DOS or UNIX) of a file when it is saved in Visual Studio.(39KB)<END><br>78,devtruecolour.zip Use any colour in the Developer Studio IDE(49KB)<END><br>79,openvc_demo.zip...

    opensc-0.12.0.tar.gz

    NEWS for OpenSC -- History of user visible changes Complete change history is available online: http://www.opensc-project.org/opensc/timeline New in 0.12.0; 2010-12-22 * OpenSC uses a single reader ...

    hls.min.js

    (e.size)){var r=t._utf8ArrayToStr(e.data),i=new Uint8Array(e.data.subarray(r.length+1));return{key:e.type,info:r,data:i.buffer}}},t._decodeTextFrame=function(e){if(!(e.size)){if("TXXX"===e.type){var r...

    开源项目-evantbyrne-crypt.zip

    开源项目-evantbyrne-crypt.zip,Made a small utility for encrypting and decrypting files with AES-256 GCM and Scrypt – feedback appreciated!

    Рисунки для 2ТЭ25КМ_dataутечка_dataхакер_ТПС_

    Decrypting data files

Global site tag (gtag.js) - Google Analytics