This documentation is archived and is not being maintained.

ECDsaCng Class

Provides a Cryptography Next Generation (CNG) implementation of the Elliptic Curve Digital Signature Algorithm (ECDSA).

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

'Declaration
<HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort := True)> _
Public NotInheritable Class ECDsaCng _
	Inherits ECDsa
'Usage
Dim instance As ECDsaCng

NoteNote:

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: MayLeakOnAbort. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

This class derives from the ECDsa abstract base class.

The following example shows how to use the ECDsaCng class to sign a message and how to use the signature to verify that the message has not been altered.

Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text

Class Alice

    Public Shared Sub Main(ByVal args() As String)
        Dim bob As New Bob()
        If (True) Then 
            Using dsa As New ECDsaCng()
                    dsa.HashAlgorithm = CngAlgorithm.Sha256
                    bob.key = dsa.Key.Export(CngKeyBlobFormat.EccPublicBlob)
                    Dim data() As Byte = {21, 5, 8, 12, 207}
                    Dim signature As Byte() = dsa.SignData(data)
                    bob.Receive(data, signature)
            End Using 
        End If 

    End Sub 'Main
End Class 'Alice 


Public Class Bob
    Public key() As Byte

    Public Sub Receive(ByVal data() As Byte, ByVal signature() As Byte)
        Using ecsdKey As New ECDsaCng(CngKey.Import(key, CngKeyBlobFormat.EccPublicBlob))
                If ecsdKey.VerifyData(data, signature) Then
                    Console.WriteLine("Data is good")
                Else
                    Console.WriteLine("Data is bad")
                End If 
        End Using 

    End Sub 'Receive
End Class 'Bob 

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

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

.NET Framework

Supported in: 3.5
Show: