Is it RC4 or ARCFOUR? InvalidKeyException when using SecretKeySpec?

我是研究僧i 提交于 2019-12-03 21:54:41

As alluded to by @DaveHowes it is likely you are using a third-party JCE provider in the case of the first stacktrace, and that your keysize is invalid in the case of the second stacktrace.

Sun includes several providers whose parameters are documented here. Note that according to the documentation for the SunJCE provider, the name of the algorithm is "ARCFOUR", not "RC4". My guess is that when you specified "RC4" you got the 'fabsam' provider implementation, whatever that is. When you specified 'ARCFOUR' you got the Sun implementation. Note also the keysize restrictions which specify that 'ARCFOUR' must have a keysize between 40 bits and 1024 bits inclusive (that's 5 bytes and 128 bytes inclusive). The String object key in your program may be either too small or too large, please check this.

Rihards

After lot of struggling and searching and everything, I got the right answer. Check my question here: Java Security: Illegal key size or default parameters? if you are experiencing this problem!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!