Skip to content

几个问题 #2

@byronhe

Description

@byronhe

看了下这个方案的 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions