Skip to content

Python: cryptography module upgrades #11678

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

Closed

Conversation

bdrodes
Copy link
Contributor

@bdrodes bdrodes commented Dec 13, 2022

Updates to python crypto API support. Additional algorithms added, support for 'unknown' algorithms and block modes added, and support added for the cryptography module pbkdf2_hmac.

bdrodes and others added 30 commits November 23, 2022 12:01
your-name and others added 17 commits December 5, 2022 10:42
… adding 'isKnown' support to get the universe of possible options. Finally added an unknown algorithm stub, so if no match is found, we can consistently have a string representing unknown.
…te, and to have a fail safe 'unknown' option. If a block mode is unknown, the isWeak predicate will not stipulate the algorithm is weak by default. An isKnown predicate is added to determine if the algorithm is known.
… finding block modes that aren't known. This avoids cases where the library is updated and we don't recognize new modes as being weak or strong, instead they would've been ignored entirely.
@bdrodes bdrodes requested a review from a team as a code owner December 13, 2022 17:26
class Hashlibpbkdf2HMAC extends Cryptography::CryptographicOperation::Range, API::CallNode {
string hashName;

Hashlibpbkdf2HMAC() {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase.

Acronyms in Hashlibpbkdf2HMAC should be PascalCase/camelCase.
private API::CallNode hashlibpbkdf2HMACCall(string algorithmName)
{
algorithmName =
result.getParameter(0, "hash_name").getAValueReachingSink().asExpr().(StrConst).getText() and

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase.

Acronyms in hashlibpbkdf2HMACCall should be PascalCase/camelCase.
override Cryptography::BlockMode getBlockModeRaw() {
// `modeName` is of the form "MODE_<BlockMode>"
exists(string modeName |
if resolveModeName(modeName)

Check warning

Code scanning / CodeQL

Using implicit `this`

Use of implicit `this`.
*/
predicate isWeakCipherBlockModeAlgorithm(string name)
{
name = ["ECB"]

Check warning

Code scanning / CodeQL

Singleton set literal

Singleton set literal can be replaced by its member.
@RasmusWL RasmusWL self-assigned this Dec 15, 2022
@RasmusWL RasmusWL changed the title 1 python cryptography module upgrades Python: cryptography module upgrades Dec 15, 2022
@RasmusWL
Copy link
Member

as discussed offline, I'll take a look at how much of this we can easily accept, and how much might need further consideration.

class HMACDirectHash extends Cryptography::CryptographicOperation::Range, API::CallNode {
string hashName;

HMACDirectHash() {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase.

Acronyms in HMACDirectHash should be PascalCase/camelCase.
class HMACUpdateCall extends Cryptography::CryptographicOperation::Range, API::CallNode {
string hashName;

HMACUpdateCall() {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase.

Acronyms in HMACUpdateCall should be PascalCase/camelCase.
private API::CallNode baseHMACOperation(string algorithmName) {
(
result = API::moduleImport("hmac").getMember("new").getACall() or
result = API::moduleImport("hmac").getMember("digest").getACall() or

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase.

Acronyms in baseHMACOperation should be PascalCase/camelCase.
@RasmusWL
Copy link
Member

I've ported the improvements from this PR in #12165 and #12168. I can't accept the changes around unknown cryptographic algorithms as is, but as we discussed, it would be nice to improve our modeling around this in the future. Therefore I will close this PR now, but thanks for your contributions 🙏

@RasmusWL RasmusWL closed this Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants