Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

AsymmetricAlgorithm.LegalKeySizes Property

Definition

Namespace:
System.Security.Cryptography
Assemblies:
netstandard.dll, System.Security.Cryptography.dll
Assemblies:
netstandard.dll, System.Security.Cryptography.Primitives.dll
Assembly:
System.Security.Cryptography.Primitives.dll
Assembly:
mscorlib.dll
Assembly:
netstandard.dll
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

public:
 virtual property cli::array <System::Security::Cryptography::KeySizes ^> ^ LegalKeySizes { cli::array <System::Security::Cryptography::KeySizes ^> ^ get(); };
public virtual System.Security.Cryptography.KeySizes[] LegalKeySizes { get; }
member this.LegalKeySizes : System.Security.Cryptography.KeySizes[]
Public Overridable ReadOnly Property LegalKeySizes As KeySizes()

Property Value

An array that contains the key sizes supported by the asymmetric algorithm.

Examples

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 + ", ");
 }
}
Dim legalKeySizes() As KeySizes = customCrypto.LegalKeySizes
If (legalKeySizes.Length > 0) Then
 For i As Integer = 0 To legalKeySizes.Length - 1 Step 1
 Write("Keysize" + i.ToString() + " min, max, step: ")
 Write(legalKeySizes(i).MinSize.ToString() + ", ")
 Write(legalKeySizes(i).MaxSize.ToString() + ", ")
 Write(legalKeySizes(i).SkipSize.ToString() + ", ")
 WriteLine("")
 Next
End If

Remarks

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

Applies to

See also


Feedback

Was this page helpful?