-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Quantum: Add OpenSSL key agreement instances and consumers #19632
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
nicolaswill
merged 9 commits into
github:main
from
bdrodes:openssl_keyagreement_instances_and_consumers
Jun 2, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
41f008d
Crypto: Adding initial openssl tests, fixing a bug in hash modeling f…
bdrodes b1ce44e
Crypto: Move openssl stubs to a shared stubs location. Include openss…
bdrodes 69e3a20
Crypto: Update crypto stubs location under 'crypto' and associate cod…
bdrodes cf015d1
Crypto: Add openssl key agreement instances and consumers (KEM and KE…
bdrodes f5d24c5
Crypto: Fix UnknownKeyAgreementType to OthernKeyAgreementType for JCA.
bdrodes 5a82246
Merge branch 'main' into openssl_keyagreement_instances_and_consumers
nicolaswill 23b6c78
Crypto: Revert CODEOWNERS change and remove redundant cast.
bdrodes 8b770bf
Crypto: Remove old crypto stubs, now part of experimental/stubs.
bdrodes 7e7dfeb
Merge branch 'main' into openssl_keyagreement_instances_and_consumers
nicolaswill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmInstances/KeyAgreementAlgorithmInstance.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import cpp | ||
private import experimental.quantum.Language | ||
private import KnownAlgorithmConstants | ||
private import experimental.quantum.OpenSSL.AlgorithmValueConsumers.OpenSSLAlgorithmValueConsumers | ||
private import experimental.quantum.OpenSSL.AlgorithmInstances.OpenSSLAlgorithmInstanceBase | ||
private import AlgToAVCFlow | ||
|
||
predicate knownOpenSSLConstantToKeyAgreementFamilyType( | ||
KnownOpenSSLKeyAgreementAlgorithmConstant e, Crypto::TKeyAgreementType type | ||
) { | ||
exists(string name | | ||
name = e.getNormalizedName() and | ||
( | ||
name = "ECDH" and type = Crypto::ECDH() | ||
or | ||
name = "DH" and type = Crypto::DH() | ||
or | ||
name = "EDH" and type = Crypto::EDH() | ||
or | ||
name = "ESDH" and type = Crypto::EDH() | ||
) | ||
) | ||
} | ||
|
||
class KnownOpenSSLHashConstantAlgorithmInstance extends OpenSSLAlgorithmInstance, | ||
Check warningCode scanning / CodeQL Acronyms should be PascalCase/camelCase. Warning
Acronyms in KnownOpenSSLHashConstantAlgorithmInstance should be PascalCase/camelCase.
|
||
Crypto::KeyAgreementAlgorithmInstance instanceof KnownOpenSSLKeyAgreementAlgorithmConstant | ||
{ | ||
OpenSSLAlgorithmValueConsumer getterCall; | ||
|
||
KnownOpenSSLHashConstantAlgorithmInstance() { | ||
// Two possibilities: | ||
// 1) The source is a literal and flows to a getter, then we know we have an instance | ||
// 2) The source is a KnownOpenSSLAlgorithm is call, and we know we have an instance immediately from that | ||
// Possibility 1: | ||
this instanceof Literal and | ||
exists(DataFlow::Node src, DataFlow::Node sink | | ||
// Sink is an argument to a CipherGetterCall | ||
sink = getterCall.getInputNode() and | ||
// Source is `this` | ||
src.asExpr() = this and | ||
// This traces to a getter | ||
KnownOpenSSLAlgorithmToAlgorithmValueConsumerFlow::flow(src, sink) | ||
) | ||
or | ||
// Possibility 2: | ||
this instanceof DirectAlgorithmValueConsumer and getterCall = this | ||
} | ||
|
||
override OpenSSLAlgorithmValueConsumer getAVC() { result = getterCall } | ||
Check warningCode scanning / CodeQL Acronyms should be PascalCase/camelCase. Warning
Acronyms in getAVC should be PascalCase/camelCase.
|
||
|
||
override Crypto::TKeyAgreementType getKeyAgreementType() { | ||
knownOpenSSLConstantToKeyAgreementFamilyType(this, result) | ||
or | ||
not knownOpenSSLConstantToKeyAgreementFamilyType(this, _) and | ||
result = Crypto::OtherKeyAgreementType() | ||
} | ||
|
||
override string getRawKeyAgreementAlgorithmName() { | ||
result = this.(Literal).getValue().toString() | ||
or | ||
result = this.(Call).getTarget().getName() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Acronyms should be PascalCase/camelCase. Warning