aes-rsa-java icon indicating copy to clipboard operation
aes-rsa-java copied to clipboard

几个问题

Open byronhe opened this issue 10 years ago • 4 comments

看了下这个方案的 Java 代码,有几个问题: 1. https://github.com/wustrive2008/aes-rsa-java/blob/master/src/main/java/com/wustrive/aesrsa/util/RandomUtil.java

这个竟然用的是java.util.Random。 java.util.Random 不是密码学安全的!

"AES/ECB/PKCS5Padding";

AES绝对不要使用 ECB 模式!

https://zh.wikipedia.org/wiki/%E5%9D%97%E5%AF%86%E7%A0%81%E7%9A%84%E5%B7%A5%E4%BD%9C%E6%A8%A1%E5%BC%8F

HMAC 用 javax.crypto.Mac 就行了

http://stackoverflow.com/questions/3208160/how-to-generate-an-hmac-in-java-equivalent-to-a-python-example

不需要自己实现。 楼主的实现冗余代码太多。

建议废掉 HMAC-MD5 和 HMAC-SHA1,这俩已经不安全了。 1. https://github.com/wustrive2008/aes-rsa-java/blob/master/src/main/java/com/wustrive/aesrsa/util/EncryptionUtil.java

这个提取一个 byte to hex 的公共函数出来就行了。

可以省掉复制粘贴。

byte to hex 也不需要写这么长。几行搞定:

http://stackoverflow.com/questions/15429257/how-to-convert-byte-array-to-hexstring-in-java

RSA 1024已经不安全了,起码要2048!

https://github.com/wustrive2008/aes-rsa-java/blob/master/src/main/java/com/wustrive/aesrsa/util/RSA.java

"SHA1WithRSA" 已经被废弃,建议更新成 SHA256WithRSA

建议楼主好好看看Facebook的这个项目:

https://github.com/facebook/conceal

byronhe avatar Sep 02 '15 10:09 byronhe

提的几点改进建议非常好,感谢!

wustrive2008 avatar Sep 20 '18 06:09 wustrive2008

ios 端 可以用吗

wangfengcool avatar Dec 27 '18 16:12 wangfengcool

Android 和 后端Java 可以用

wangfengcool avatar Dec 27 '18 16:12 wangfengcool

不错,虽然感觉很复杂的样子,会用工具就行

wubang0930 avatar Jan 10 '19 10:01 wubang0930