Skip to content

Quantum: Initial support for C# #19905

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

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

fegge
Copy link
Contributor

@fegge fegge commented Jun 27, 2025

This PR adds support for parts of the .NET cryptographic libraries. Currently, it contains QL libraries and tests for

  • Symmetric ciphers
  • Signatures
  • Hash functions
  • MACs

fegge and others added 30 commits June 16, 2025 11:59
- Added support to get input consumers and output artifacts
- Added padding and cipher mode algorithm instances, as well as dataflow
  to link these to `CryptoStream` key operations
This commit also reorganizes the dotnet library to move utility classes
into the private Cryptography module.
@fegge fegge requested review from a team as code owners June 27, 2025 12:36
@github-actions github-actions bot added the C# label Jun 27, 2025
@fegge fegge marked this pull request as draft June 27, 2025 12:41
@bdrodes
Copy link
Contributor

bdrodes commented Jun 27, 2025

@fegge Check out my test cases. I do 3 tests, nodes, node edges, and node properties. That should cover everything. Can you update the PR to do that kind of test?

@bdrodes
Copy link
Contributor

bdrodes commented Jun 27, 2025

@fegge make sure to work with @nicolaswill to get all my PRs in first and double check if model updates on my part break anything.

Comment on lines +147 to +150
/**
* An instance of random number generation, modelled as the expression
* tied to an output node (i.e., the RNG output)
*/

Check warning

Code scanning / CodeQL

Misspelling Warning

This comment contains the non-US spelling 'modelled', which should instead be 'modeled'.
private import Cryptography
private import FlowAnalysis

class NamedCurveAlgorithmInstance extends Crypto::EllipticCurveInstance instanceof NamedCurvePropertyAccess

Check warning

Code scanning / CodeQL

Suggest using non-extending subtype relationships. Warning

Consider defining this class as non-extending subtype of
NamedCurvePropertyAccess
.
ECParameters() { this.hasName("ECParameters") }
}

class RSAParameters extends CryptographyType {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in RSAParameters should be PascalCase/camelCase.
ECDsaClass() { this.hasName("ECDsa") }
}

private class RSAClass extends CryptographyType {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in RSAClass should be PascalCase/camelCase.
RSAClass() { this.hasName("RSA") }
}

private class RSAPKCS1SignatureFormatter extends CryptographyType {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in RSAPKCS1SignatureFormatter should be PascalCase/camelCase.
override string getRawMACAlgorithmName() { result = super.getType().getName() }
}

class HMACAlgorithmQualifier extends Crypto::HMACAlgorithmInstance, Crypto::AlgorithmValueConsumer,

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in HMACAlgorithmQualifier should be PascalCase/camelCase.

module AeadFlow = CreationToUseFlow<AeadCreation, AeadUse>;

module HMACFlow = CreationToUseFlow<HMACCreation, MacUse>;

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in HMACFlow should be PascalCase/camelCase.
}

module SigningCreateToUseFlow {
private module SigningCreateToUseFlow implements DataFlow::ConfigSig {

Check warning

Code scanning / CodeQL

Data flow configuration module naming Warning

Modules implementing a data flow configuration should end in Config.
Comment on lines +266 to +276
/**
* An additional flow step across new object creations that use the original objects.
*
* Example:
* ```
* RSA rsa = RSA.Create()
* RSAPKCS1SignatureFormatter rsaFormatter = new(rsa);
* rsaFormatter.SetHashAlgorithm(nameof(SHA256));
* signedHash = rsaFormatter.CreateSignature(hash);
* ```
*/

Check warning

Code scanning / CodeQL

Predicate QLDoc style. Warning

The QLDoc for a predicate without a result should start with 'Holds'.
}
}

class HMACOperationInstance extends Crypto::MACOperationInstance instanceof MacUse {

Check warning

Code scanning / CodeQL

Acronyms should be PascalCase/camelCase. Warning

Acronyms in HMACOperationInstance should be PascalCase/camelCase.
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.

3 participants