Insufficient Cryptographic Key Size

Insufficient cryptographic key size in C#

Description

The key size needed for encryption or signing depends on the algorithm. A short key may fall below the required security strength.

Potential impact

A compromised key may expose encrypted data or allow a forged signature to pass authentication.

Remediation

Choose an algorithm suited to your security policy. Start with at least 2048 bits for RSA or finite-field DH and 128 bits for modern symmetric algorithms. Under FIPS 186-5, use DSA only to verify signatures generated before the standard was implemented. Generate new signatures with another approved algorithm.

Examples

Before

csharp
using var rsa = new RSACryptoServiceProvider(1024);

After

csharp
using var rsa = new RSACryptoServiceProvider(2048);

RSACryptoServiceProvider(2048) requests a 2048-bit RSA key in place of the 1024-bit key.

References