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

Parameters Description
ecc Pointer to context which saves state between calls.
out Buffer in which to store the public key.
outSz The available size of the buffer, in bytes.
usedSz Return value indicating how many bytes were used.

Returns

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