This documentation is archived and is not being maintained.

AsymmetricAlgorithm.LegalKeySizes Property

Gets the key sizes that are supported by the asymmetric algorithm.

Namespace:  System.Security.Cryptography
Assembly:  mscorlib (in mscorlib.dll)

public virtual KeySizes[] LegalKeySizes { get; }

Property Value

Type: System.Security.Cryptography.KeySizes[]
An array that contains the key sizes supported by the asymmetric algorithm.

The asymmetric algorithm supports only key sizes that match an entry in this array.

The following code example demonstrates how to call the LegalKeySizes property to retrieve the MinSize, MaxSize, and SkipSize properties. This code example is part of a larger example provided for the AsymmetricAlgorithm class.

KeySizes[] legalKeySizes = customCrypto.LegalKeySizes;
if (legalKeySizes.Length > 0)
    for (int i=0; i < legalKeySizes.Length; i++)
        Console.Write("Keysize" + i + " min, max, step: ");
        Console.Write(legalKeySizes[i].MinSize + ", ");
        Console.Write(legalKeySizes[i].MaxSize + ", ");
        Console.WriteLine(legalKeySizes[i].SkipSize + ", ");

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.