Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Crypto: Improve literal filtering for OpenSSL for algorithms and generic sources #19553

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

Merged
merged 8 commits into from
May 22, 2025

Conversation

bdrodes
Copy link
Contributor

@bdrodes bdrodes commented May 21, 2025

No description provided.

… and known algorithm literals to improve dataflow performance.
@github-actions github-actions bot added the C++ label May 21, 2025
// curve is used.
this.getValue() != "EC"
}
ConstantDataSource() { this instanceof OpenSSLAlgorithmCandidateLiteral }
Copy link
Contributor

@nicolaswill nicolaswill May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be not this instanceof OpenSSLAlgorithmCandidateLiteral or even just any string or literal?
Editing for clarification: these could be any generic strings or integers used as inputs for artifacts (such as IVs, keys, RNG seeds, etc.). Maybe it's just the algorithm candidate literal language that seems too specific for what you're doing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right... yea I had blinders on to just getting the algorithm instances accounted for... the filter I had previously was the generic can't be "EC" that is in the candidate literal class now...if we are tracing any literal then my optimizations really don't matter much at least for ints...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to make sure it is an instance of an openssl generic. If other APIs have their own notion, we can add to it. The algorithm literals use this generic literal restriction, but generic inputs are not restricted to only those relevant to algorithms.

bdrodes added 2 commits May 21, 2025 18:25
… now relying on the charpred of OpenSSLAlgorithmCandidateLiteral.
…ltering all constants, not just for algorithms.
@bdrodes bdrodes marked this pull request as ready for review May 22, 2025 14:34
@bdrodes bdrodes requested a review from a team as a code owner May 22, 2025 14:34
# Conflicts:
#	cpp/ql/lib/experimental/quantum/Language.qll
#	cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmInstances/KnownAlgorithmConstants.qll
#	cpp/ql/lib/experimental/quantum/OpenSSL/OpenSSL.qll
* Note: this predicate should only consider restrictions with respect to strings only.
* General restrictions are in the OpenSSLGenericSourceCandidateLiteral class.
*/
private predicate isOpenSSLStringLiteralGenericSourceCandidate(StringLiteral s) {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in isOpenSSLStringLiteralGenericSourceCandidate should be PascalCase/camelCase.
* "AES" may be a legitimate algorithm literal, but the literal will not be used for an operation directly
* since it is in a equality comparison, hence this case would also be filtered.
*/
class OpenSSLGenericSourceCandidateLiteral extends Literal {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in OpenSSLGenericSourceCandidateLiteral should be PascalCase/camelCase.
@bdrodes bdrodes force-pushed the generic_constant_filtering branch from e007eff to 417734c Compare May 22, 2025 14:48
Squashed commits:

[417734c] Crypto: Fixing typo (+1 squashed commits)

Squashed commits:

[1ac3d5c] Crypto: Fixing typo caused by AI auto complete.
@bdrodes bdrodes force-pushed the generic_constant_filtering branch from 50c36a8 to 570fdeb Compare May 22, 2025 14:52
Copy link
Contributor

@nicolaswill nicolaswill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment + failing unit tests.

@nicolaswill nicolaswill changed the title Crypto: Advanced literal filtering for OpenSSL, used for both unknown… Crypto: Improve literal filtering for OpenSSL for algorithms and generic sources May 22, 2025
… constraints for generic input sources are heuristics to filter sources, and other constraints narrow the literals to a general type (ints). Also adding fixes in KnownAlgorithmConstants to classify some algorithms as key exchange and signature correctly, and added support for a signature constant wrapper.
* Note: this predicate should only consider restrictions with respect to integers only.
* General restrictions are in the OpenSSLGenericSourceCandidateLiteral class.
*/
private predicate isOpenSSLIntLiteralGenericSourceCandidate(IntLiteral l) {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in isOpenSSLIntLiteralGenericSourceCandidate should be PascalCase/camelCase.
@nicolaswill nicolaswill self-requested a review May 22, 2025 17:04
…d signature mapping for ED and X elliptic curve variants.
@@ -76,6 +76,15 @@ class KnownOpenSSLEllipticCurveAlgorithmConstant extends KnownOpenSSLAlgorithmCo
}
}

class KnownOpenSSLSignatureAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
string algType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a field if it's not the result of or used in a member predicate.

@nicolaswill nicolaswill self-requested a review May 22, 2025 18:08
}
}

class KnownOpenSSLSignatureAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in KnownOpenSSLSignatureAlgorithmConstant should be PascalCase/camelCase.
@nicolaswill nicolaswill merged commit 47ffa3c into github:main May 22, 2025
13 checks passed
@nicolaswill nicolaswill deleted the generic_constant_filtering branch May 22, 2025 22:34
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.