Compartilhar via


AsymmetricKeyAlgorithmProvider.CreateKeyPairWithCurveParameters Método

Definição

Cria um par de chaves públicas/privadas assimétricas usando parâmetros de curva.

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

Parâmetros

parameters

Byte[]

byte[]

Uma matriz de bytes que contém os parâmetros de curva.

Retornos

Representa o par de chaves ECDSA (Algoritmo de Assinatura Digital de Curva Elíptica) gerado.

Exemplos

O exemplo a seguir cria uma nova curva ECDSA com base em parâmetros de curva.

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);

Comentários

A chave privada gerada é um inteiro aleatório. A chave pública é um ponto, com coordenadas X e Y, em uma curva ECDSA.

Aplica-se a