-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Promote insufficient key size query from experimental #10785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: Promote insufficient key size query from experimental #10785
Conversation
…ratorInitConfiguration
… handle complex VarAccess
… name when KeyGen obj is param to other method
QHelp previews: java/ql/src/Security/CWE/CWE-326/InsufficientKeySize.qhelpUse of a cryptographic algorithm with insufficient key sizeModern encryption relies on the computational infeasibility of breaking a cipher and decoding its message without the key. As computational power increases, the ability to break ciphers grows, and key sizes need to become larger as a result. Cryptographic algorithms that use too small of a key size are vulnerable to brute force attacks, which can reveal sensitive data. RecommendationUse a key of the recommended size or larger. The key size should be at least 128 bits for AES encryption, 256 bits for elliptic-curve cryptography (ECC), and 2048 bits for RSA, DSA, or DH encryption. ExampleThe following code uses cryptographic algorithms with insufficient key sizes. KeyPairGenerator keyPairGen1 = KeyPairGenerator.getInstance("RSA");
keyPairGen1.initialize(1024); // BAD: Key size is less than 2048
KeyPairGenerator keyPairGen2 = KeyPairGenerator.getInstance("DSA");
keyPairGen2.initialize(1024); // BAD: Key size is less than 2048
KeyPairGenerator keyPairGen3 = KeyPairGenerator.getInstance("DH");
keyPairGen3.initialize(1024); // BAD: Key size is less than 2048
KeyPairGenerator keyPairGen4 = KeyPairGenerator.getInstance("EC");
ECGenParameterSpec ecSpec = new ECGenParameterSpec("secp112r1"); // BAD: Key size is less than 256
keyPairGen4.initialize(ecSpec);
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(64); // BAD: Key size is less than 128 To fix the code, change the key sizes to be the recommended size or larger for each algorithm. References
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great use of flow states @jcogs33! 😄
I added some comments, but I'll probably give it another review if you decide to apply the suggested refactor (should be easier to review the details then).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more minor comments, but otherwise this LGTM. If DCA and MRVA are happy, let's ask for a docs review and then merge.
👋 Docs first responder here! I've put this on our review board for a writer to pick up and review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcogs33 👋🏻 - this looks good from a Docs point of view ✨
Added a couple of very minor comments (feel free to ignore them if you don't agree 🙂 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
This PR promotes #4926 from experimental.