wustrive2008 / aes-rsa-java Goto Github PK
View Code? Open in Web Editor NEWAES+RSA结合应用java示例
License: Apache License 2.0
AES+RSA结合应用java示例
License: Apache License 2.0
看了下这个方案的 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 模式!
HMAC 用 javax.crypto.Mac 就行了
不需要自己实现。
楼主的实现冗余代码太多。
建议废掉 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!
"SHA1WithRSA" 已经被废弃,建议更新成 SHA256WithRSA
建议楼主好好看看Facebook的这个项目:
String aeskey = RSA.decrypt(Req.encryptkey, serverPrivateKey);
解密服务器的响应时为什么不用客户端的私钥clientPrivateKey,这时客户端相对服务器端是接收方,不是应该用接收方的私钥解密吗?
Hi there, we found that the following places using insecure hash functions:
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/Digest.java:19: error: [algorithm.not.allowed] Algorithm: MD5 is not allowed by the current rules
MessageDigest md = MessageDigest.getInstance("MD5");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/Digest.java:33: error: [algorithm.not.allowed] Algorithm: MD5 is not allowed by the current rules
MessageDigest md = MessageDigest.getInstance("MD5");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/Digest.java:66: error: [algorithm.not.allowed] Algorithm: MD5 is not allowed by the current rules
md = MessageDigest.getInstance("MD5");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/Digest.java:102: error: [algorithm.not.allowed] Algorithm: SHA is not allowed by the current rules
md = MessageDigest.getInstance("SHA");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/Digest.java:132: error: [algorithm.not.allowed] Algorithm: SHA is not allowed by the current rules
md = MessageDigest.getInstance("SHA");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/Digest.java:162: error: [algorithm.not.allowed] Algorithm: SHA1 is not allowed by the current rules
MessageDigest md = MessageDigest.getInstance("SHA1");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/EncryptionUtil.java:23: error: [algorithm.not.allowed] Algorithm: MD5 is not allowed by the current rules
MessageDigest md = MessageDigest.getInstance("MD5");
^
/home/xwt/IdeaProjects/aes-rsa-java/src/main/java/com/wustrive/aesrsa/util/EncryptionUtil.java:57: error: [algorithm.not.allowed] Algorithm: SHA-1 is not allowed by the current rules
MessageDigest md = MessageDigest.getInstance("SHA-1");
^
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.