1.30 CRYPT_ECC_PublicExport Function

C

int CRYPT_ECC_PublicExport(
    CRYPT_ECC_CTX* ecc, 
    unsigned char* out, 
    unsigned int outSz, 
    unsigned int* usedSz
);

Description

This function takes an ECC public key and exports it in ANSI X9.63 format.

Preconditions

The context must be initialized previously with a call to CRYPT_ECC_Initialize. The key must also have been constructed with a call to CRYPT_ECC_DHE_KeyMake. A random number generator must have been initialized with a call to CRYPT_RNG_Initialize.

Parameters

ParametersDescription
eccPointer to context which saves state between calls.
outBuffer in which to store the public key.
outSzThe available size of the buffer, in bytes.
usedSzReturn value indicating how many bytes were used.

Returns

  • BAD_FUNC_ARG - An invalid pointer was passed to the function.

  • BUFFER_E - The output buffer was too small to store the key.

  • 0 - An invalid ppointer was not passed to the function.

Remarks

None.

Example

CRYPT_ECC_CTX userA; 
int           ret;
byte          sharedA[100];
unsigned int  aSz = (unsigned int)sizeof(sharedA);
unsigned int  usedA = 0;

ret = CRYPT_ECC_Initialize(&userA);
ret = CRYPT_ECC_DHE_KeyMake(&userA, &mcRng, 32);
ret = CRYPT_ECC_PublicExport(&userA, sharedA, aSz, &usedA);