Share via


AsymmetricKeyAlgorithmProvider.CreateKeyPairWithCurveParameters Method

Definition

Creates an asymmetric public/private key pair using curve parameters.

public:
 virtual CryptographicKey ^ CreateKeyPairWithCurveParameters(Platform::Array <byte> ^ parameters) = CreateKeyPairWithCurveParameters;
CryptographicKey CreateKeyPairWithCurveParameters(winrt::array_view <byte> const& parameters);
public CryptographicKey CreateKeyPairWithCurveParameters(byte[] parameters);
function createKeyPairWithCurveParameters(parameters)
Public Function CreateKeyPairWithCurveParameters (parameters As Byte()) As CryptographicKey

Parameters

parameters

Byte[]

byte[]

An array of bytes containing the curve parameters.

Returns

Represents the generated Elliptic Curve Digital Signature Algorithm (ECDSA) asymmetric key pair.

Examples

The following example creates a new ECDSA curve from curve parameters.

Byte[] myCurveParameters =
{
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xAC, 0x73,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3B, 0x4C, 0x38, 0x2C, 0xE3, 0x7A, 0xA1, 0x92,
0xA4, 0x01, 0x9E, 0x76, 0x30, 0x36, 0xF4, 0xF5, 0xDD, 0x4D, 0x7E, 0xBB, 0x93, 0x8C, 0xF9, 0x35,
0x31, 0x8F, 0xDC, 0xED, 0x6B, 0xC2, 0x82, 0x86, 0x53, 0x17, 0x33, 0xC3, 0xF0, 0x3C, 0x4F, 0xEE,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xB8, 0xFA, 0x16, 0xDF, 0xAB,
0x9A, 0xCA, 0x16, 0xB6, 0xB3, 0x01
};

AsymmetricKeyAlgorithmProvider eccAlgorithmProvider = 
                AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.EcdsaSha256);
CryptographicKey keyPair = eccAlgorithmProvider.CreateKeyPairWithCurveParameters(myCurveParameters);
Byte^ myCurveParameters[] =
{
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xAC, 0x73,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3B, 0x4C, 0x38, 0x2C, 0xE3, 0x7A, 0xA1, 0x92,
0xA4, 0x01, 0x9E, 0x76, 0x30, 0x36, 0xF4, 0xF5, 0xDD, 0x4D, 0x7E, 0xBB, 0x93, 0x8C, 0xF9, 0x35,
0x31, 0x8F, 0xDC, 0xED, 0x6B, 0xC2, 0x82, 0x86, 0x53, 0x17, 0x33, 0xC3, 0xF0, 0x3C, 0x4F, 0xEE,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xB8, 0xFA, 0x16, 0xDF, 0xAB,
0x9A, 0xCA, 0x16, 0xB6, 0xB3, 0x01
};

AsymmetricKeyAlgorithmProvider^ eccAlgorithmProvider = AsymmetricKeyAlgorithmProvider::OpenAlgorithm(
                                                                               AsymmetricAlgorithmNames::EcdsaSha256); 
CryptographicKey^ keyPair = eccAlgorithmProvider->CreateKeyPairWithCurveParameters(myCurveParameters);

Remarks

The private key generated is a random integer. The public key is a point, with X and Y coordinates, on an ECDSA curve.

Applies to