An RSA or DSA key shorter than 2048 bits is created

tx0/csharp:short-rsa-keydefaultwarningsecurity/cryptodepth fastsecurity, cwe-326

What it finds

RSA and DSA keys of 1024 bits and less can be factored with the means of a determined attacker. 2048 bits is the accepted minimum. The sizes checked are literal arguments of new RSACryptoServiceProvider(n), RSA.Create(n), new DSACryptoServiceProvider(n) and assignments of literals to KeySize.

From the rule's source, short_rsa_key.rs.

Example from the rule's tests
using System.Security.Cryptography; class Keys{    void Make()    {        var a = new RSACryptoServiceProvider(1024);tx0 reports: a key of 1024 bits is too short; use at least 2048        var b = RSA.Create(512);tx0 reports: a key of 512 bits is too short; use at least 2048        var c = RSA.Create(4096);        var rsa = RSA.Create();        rsa.KeySize = 1024;tx0 reports: a key of 1024 bits is too short; use at least 2048    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:short-rsa-key" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:short-rsa-key] reason="..."

tx0 explain tx0/csharp:short-rsa-key shows the same in the terminal. Found a false positive? Report it.